Class: TaoForm::Components::MomentPicker::Base

Inherits:
FieldComponent
  • Object
show all
Defined in:
lib/tao_form/components/moment_picker/base.rb

Instance Attribute Summary collapse

Attributes inherited from FieldComponent

#attribute_name, #builder

Instance Method Summary collapse

Constructor Details

#initialize(view, builder, attribute_name, options = {}, html_options = {}) ⇒ Base

Returns a new instance of Base.



12
13
14
15
16
# File 'lib/tao_form/components/moment_picker/base.rb', line 12

def initialize view, builder, attribute_name, options = {}, html_options = {}
  super view, builder, attribute_name, options
  @html_options = transform_html_options default_html_options, html_options
  @disabled = @html_options[:disabled].presence || false
end

Instance Attribute Details

#block_for_renderObject (readonly)

Returns the value of attribute block_for_render.



10
11
12
# File 'lib/tao_form/components/moment_picker/base.rb', line 10

def block_for_render
  @block_for_render
end

#disabledObject (readonly)

Returns the value of attribute disabled.



10
11
12
# File 'lib/tao_form/components/moment_picker/base.rb', line 10

def disabled
  @disabled
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



10
11
12
# File 'lib/tao_form/components/moment_picker/base.rb', line 10

def html_options
  @html_options
end

#placeholderObject (readonly)

Returns the value of attribute placeholder.



10
11
12
# File 'lib/tao_form/components/moment_picker/base.rb', line 10

def placeholder
  @placeholder
end

Instance Method Details

#default_segmentObject



26
27
28
# File 'lib/tao_form/components/moment_picker/base.rb', line 26

def default_segment
  # to be implemented
end

#input_typeObject



18
19
20
# File 'lib/tao_form/components/moment_picker/base.rb', line 18

def input_type
  # to be implemented
end

#render(&block) ⇒ Object



30
31
32
33
# File 'lib/tao_form/components/moment_picker/base.rb', line 30

def render &block
  @block_for_render = block
  render_template 'moment_picker', &block
end

#render_resultObject



35
36
37
38
39
40
# File 'lib/tao_form/components/moment_picker/base.rb', line 35

def render_result
  view.tao_moment_picker_result(
    builder, attribute_name, input_type: input_type, icon: options[:icon],
    placeholder: placeholder, disabled: disabled, &block_for_render
  )
end

#render_segment_listObject



42
43
44
45
# File 'lib/tao_form/components/moment_picker/base.rb', line 42

def render_segment_list
  view.tao_moment_picker_segment_list segments: segments,
    default_segment: default_segment
end

#segmentsObject



22
23
24
# File 'lib/tao_form/components/moment_picker/base.rb', line 22

def segments
  # to be implemented
end