Sha256: 83f2685ad8ff5ecc0ccfcc9545881a05e9293f2dee819cc34cb2979c292b0679

Contents?: true

Size: 978 Bytes

Versions: 16

Compression:

Stored size: 978 Bytes

Contents

module Formstrap
  class ColorView < ViewModel
    include Formstrap::Hintable
    include Formstrap::Labelable
    include Formstrap::Validatable
    include Formstrap::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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
formstrap-0.4.5 app/models/formstrap/color_view.rb
formstrap-0.4.4 app/models/formstrap/color_view.rb
formstrap-0.4.3 app/models/formstrap/color_view.rb
formstrap-0.4.2 app/models/formstrap/color_view.rb
formstrap-0.3.5 app/models/formstrap/color_view.rb
formstrap-0.3.4 app/models/formstrap/color_view.rb
formstrap-0.3.3 app/models/formstrap/color_view.rb
formstrap-0.3.2 app/models/formstrap/color_view.rb
formstrap-0.3.1 app/models/formstrap/color_view.rb
formstrap-0.3.0 app/models/formstrap/color_view.rb
formstrap-0.2.1 app/models/formstrap/color_view.rb
formstrap-0.2.0 app/models/formstrap/color_view.rb
formstrap-0.1.3 app/models/formstrap/color_view.rb
formstrap-0.1.2 app/models/formstrap/color_view.rb
formstrap-0.1.1 app/models/formstrap/color_view.rb
formstrap-0.1.0 app/models/formstrap/color_view.rb