Class: Formstrap::FlatpickrRangeView

Inherits:
ViewModel
  • Object
show all
Includes:
Hintable, InputGroupable, Labelable, Listable, Placeholderable, Validatable, Wrappable
Defined in:
app/models/formstrap/flatpickr_range_view.rb

Instance Method Summary collapse

Methods inherited from ViewModel

#attributes, #initialize, #to_hash

Constructor Details

This class inherits a constructor from ViewModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ViewModel

Instance Method Details

#attributeObject



11
12
13
# File 'app/models/formstrap/flatpickr_range_view.rb', line 11

def attribute
  @attribute || :period
end

#end_attributeObject



19
20
21
# File 'app/models/formstrap/flatpickr_range_view.rb', line 19

def end_attribute
  @end.dig(:attribute) || :end_date
end

#end_optionsObject



27
28
29
# File 'app/models/formstrap/flatpickr_range_view.rb', line 27

def end_options
  default_end_options.deep_merge(@end || {})
end

#input_group_optionsObject



37
38
39
40
41
# File 'app/models/formstrap/flatpickr_range_view.rb', line 37

def input_group_options
  default_input_group_options
    .deep_merge(label_input_group_options)
    .deep_merge(@input_group || {})
end

#input_optionsObject



31
32
33
34
35
# File 'app/models/formstrap/flatpickr_range_view.rb', line 31

def input_options
  keys = attributes - %i[append attribute end float form input_group label prepend start validate wrapper]
  options = to_h.slice(*keys)
  default_input_options.deep_merge(options)
end

#start_attributeObject



15
16
17
# File 'app/models/formstrap/flatpickr_range_view.rb', line 15

def start_attribute
  @start.dig(:attribute) || :start_date
end

#start_optionsObject



23
24
25
# File 'app/models/formstrap/flatpickr_range_view.rb', line 23

def start_options
  default_start_options.deep_merge(@start || {})
end

#wrapper_optionsObject



43
44
45
46
47
# File 'app/models/formstrap/flatpickr_range_view.rb', line 43

def wrapper_options
  default_wrapper_options.deep_merge({
    class: ["mb-3", ("form-floating" if float)]
  }).deep_merge(@wrapper || {})
end