Class: Effective::FormInputs::DatetimeField

Inherits:
Effective::FormInput show all
Defined in:
app/models/effective/form_inputs/datetime_field.rb

Direct Known Subclasses

DateField, TimeField

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

#name, #options

Instance Method Summary collapse

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, options[:input].merge(value: datetime_to_s))
end

#datetime_to_sObject



24
25
26
# File 'app/models/effective/form_inputs/datetime_field.rb', line 24

def datetime_to_s
  value&.strftime('%F %H:%M')
end

#input_group_optionsObject



16
17
18
# File 'app/models/effective/form_inputs/datetime_field.rb', line 16

def input_group_options
  { input_group: { class: 'input-group' }, prepend: (:span, icon('calendar'), class: 'input-group-text') }
end

#input_html_optionsObject



5
6
7
8
9
10
# File 'app/models/effective/form_inputs/datetime_field.rb', line 5

def input_html_options
  {
    class: ['form-control', 'effective_date_time_picker', 'effective_datetime', ('not-date-linked' if not_date_linked?)].compact.join(' '),
    pattern: '\d{4}(-\d{2})?-(\d{2})?( \d+)?(:\d{2})?'
  }
end

#input_js_optionsObject



12
13
14
# File 'app/models/effective/form_inputs/datetime_field.rb', line 12

def input_js_options
  { format: 'YYYY-MM-DD HH:mm', sideBySide: true, showTodayButton: true, showClear: true, useCurrent: 'hour', disabledDates: disabled_dates.presence }.compact
end