Class: TaoForm::Components::DatetimePickerComponent
- Inherits:
-
FieldComponent
- Object
- TaoOnRails::Components::Base
- FieldComponent
- TaoForm::Components::DatetimePickerComponent
show all
- Defined in:
- lib/tao_form/components/datetime_picker_component.rb
Instance Attribute Summary collapse
#attribute_name, #builder
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(view, builder, attribute_name, options = {}, html_options = {}) ⇒ DatetimePickerComponent
Returns a new instance of DatetimePickerComponent.
7
8
9
10
11
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 7
def initialize view, builder, attribute_name, options = {}, html_options = {}
super view, builder, attribute_name, options
@html_options = transform_html_options html_options
@disabled = @html_options[:disabled].presence || false
end
|
Instance Attribute Details
#disabled ⇒ Object
Returns the value of attribute disabled.
5
6
7
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 5
def disabled
@disabled
end
|
#html_options ⇒ Object
Returns the value of attribute html_options.
5
6
7
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 5
def html_options
@html_options
end
|
Class Method Details
.component_name ⇒ Object
44
45
46
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 44
def self.component_name
:datetime_picker
end
|
Instance Method Details
#render(&block) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 13
def render &block
if block_given?
super
else
super {
builder.send :datetime_field, attribute_name, {disabled: disabled}
}
end
end
|
#render_date_picker ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 23
def render_date_picker
date_options = {
placeholder: options[:date_placeholder]
}
date_html_options = {disabled: disabled}
view.tao_date_picker nil, nil, date_options, date_html_options do
view.date_field_tag nil, nil, class: 'date-field', disabled: disabled
end
end
|
#render_time_picker ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/tao_form/components/datetime_picker_component.rb', line 33
def render_time_picker
time_options = {
placeholder: options[:time_placeholder],
minute_step: options[:minute_step]
}
time_html_options = {disabled: disabled}
view.tao_time_picker nil, nil, time_options, time_html_options do
view.time_field_tag nil, nil, class: 'time-field', disabled: disabled
end
end
|