Class: Effective::FormInputs::DatetimeField
- Inherits:
-
Effective::FormInput
- Object
- Effective::FormInput
- Effective::FormInputs::DatetimeField
- Defined in:
- app/models/effective/form_inputs/datetime_field.rb
Constant Summary
Constants inherited from Effective::FormInput
Effective::FormInput::BLANK, Effective::FormInput::EXCLUSIVE_CLASS_PREFIXES, Effective::FormInput::EXCLUSIVE_CLASS_SUFFIXES
Instance Attribute Summary
Attributes inherited from Effective::FormInput
Instance Method Summary collapse
- #build_input(&block) ⇒ Object
-
#datetime_to_s ⇒ Object
ruby.
-
#format ⇒ Object
moment.js.
- #input_group_options ⇒ Object
- #input_html_options ⇒ Object
- #input_js_options ⇒ Object
-
#pattern ⇒ Object
html.
Methods inherited from Effective::FormInput
#feedback_options, #hint_options, #initialize, #label_options, #to_html, #wrapper_options
Constructor Details
This class inherits a constructor from Effective::FormInput
Instance Method Details
#build_input(&block) ⇒ Object
20 21 22 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 20 def build_input(&block) @builder.super_text_field(name, [:input].merge(value: datetime_to_s)) end |
#datetime_to_s ⇒ Object
ruby
24 25 26 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 24 def datetime_to_s # ruby value&.strftime(am_pm? ? '%F %I:%M %p' : '%F %H:%M') end |
#format ⇒ Object
moment.js
32 33 34 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 32 def format # moment.js am_pm? ? 'YYYY-MM-DD LT' : 'YYYY-MM-DD HH:mm' end |
#input_group_options ⇒ Object
16 17 18 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 16 def { input_group: { class: 'input-group effective_date_time_picker_input_group' }, prepend: content_tag(:span, icon('calendar'), class: 'input-group-text') } end |
#input_html_options ⇒ Object
5 6 7 8 9 10 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 5 def { class: ['form-control', 'effective_date_time_picker', 'effective_datetime', ('not-date-linked' if not_date_linked?)].compact.join(' '), pattern: pattern } end |
#input_js_options ⇒ Object
12 13 14 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 12 def { format: format, sideBySide: true, showTodayButton: false, showClear: false, useCurrent: 'hour', disabledDates: disabled_dates.presence, minDate: min_date.presence, maxDate: max_date.presence, locale: I18n.locale }.compact end |
#pattern ⇒ Object
html
28 29 30 |
# File 'app/models/effective/form_inputs/datetime_field.rb', line 28 def pattern # html am_pm? ? '\d{4}(-\d{2})?(-\d{2})?( \d{1,2})?(:\d{2} [aApPmM]{2})?' : '\d{4}(\-d{2})?(-\d{2})?( \d{2})?(:\d{2})?' end |