Sha256: 801fe47af851707a77d2bbc0caad0625156faf6cc4dac372734f987ce40f92b8

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

module Headmin
  module Form
    class ColorView < ViewModel
      include Headmin::Form::Hintable
      include Headmin::Form::Labelable
      include Headmin::Form::Validatable
      include Headmin::Form::Wrappable

      def input_options
        keys = attributes - %i[attribute form label validate wrapper]
        options = to_h.slice(*keys)
        default_input_options.deep_merge(options)
      end

      def label_options
        {
          class: ["form-label"],
          attribute: attribute,
          form: form,
          required: required,
          text: label
        }
      end

      def value
        @form.object&.send(@attribute) || "#000000"
      end

      def wrapper_options
        default_wrapper_options.deep_merge(
          {
          }
        ).deep_merge(@wrapper || {})
      end

      private

      def default_input_options
        {
          aria: {describedby: validation_id},
          class: ["form-control form-control-color", validation_class],
          placeholder: placeholder,
          title: value
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
headmin-0.5.9 app/models/headmin/form/color_view.rb
headmin-0.5.8 app/models/headmin/form/color_view.rb
headmin-0.5.7 app/models/headmin/form/color_view.rb
headmin-0.5.6 app/models/headmin/form/color_view.rb
headmin-0.5.5 app/models/headmin/form/color_view.rb
headmin-0.5.4 app/models/headmin/form/color_view.rb
headmin-0.5.3 app/models/headmin/form/color_view.rb
headmin-0.5.2 app/models/headmin/form/color_view.rb
headmin-0.5.1 app/models/headmin/form/color_view.rb