Sha256: edd237edcce7b73fb8440b3923175da36f128bb74b33443db9340598ec67680a

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module TaoForm
  module Components
    module MomentPicker
      class ResultComponent < TaoForm::Components::FieldComponent

        attr_reader :input_type, :value, :icon, :placeholder

        def initialize view, builder = nil, attribute_name = nil, options = {}
          super view, builder, attribute_name, options
          @input_type = options.delete(:input_type)
          @value = options.delete(:value)
          @icon = options.delete(:icon)
          @placeholder = options.delete(:placeholder)
        end

        def render &block
          if block_given?
            super
          elsif builder && attribute_name
            super {
              builder.send :"#{input_type}_field", attribute_name, field_options
            }
          end
        end

        def self.component_name
          :moment_picker_result
        end

        private

        def default_options
          {class: 'tao-moment-picker-result'}
        end

        def field_options
          opts = {disabled: options[:disabled]}
          opts[:value] = value if value.present?
          opts
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tao_form-1.0.0.beta.2 lib/tao_form/components/moment_picker/result_component.rb
tao_form-1.0.0.beta.1 lib/tao_form/components/moment_picker/result_component.rb
tao_form-0.2.3 lib/tao_form/components/moment_picker/result_component.rb
tao_form-0.2.2 lib/tao_form/components/moment_picker/result_component.rb
tao_form-0.2.1 lib/tao_form/components/moment_picker/result_component.rb
tao_form-0.2.0 lib/tao_form/components/moment_picker/result_component.rb
tao_form-0.1.10 lib/tao_form/components/moment_picker/result_component.rb