Class: Formatic::Time

Inherits:
Base show all
Defined in:
app/components/formatic/time.rb

Overview

Date/calendar

Instance Method Summary collapse

Methods inherited from Base

#input_name, #param_key, #value, #wrapper

Methods inherited from ApplicationComponent

#initialize

Constructor Details

This class inherits a constructor from Formatic::ApplicationComponent

Instance Method Details

#hour_attribute_nameObject



55
56
57
# File 'app/components/formatic/time.rb', line 55

def hour_attribute_name
  "#{f.object.model_name.param_key}[#{attribute_name}(4i)]"
end

#hour_input_idObject



63
64
65
# File 'app/components/formatic/time.rb', line 63

def hour_input_id
  "#{f.object.model_name.param_key}_#{attribute_name}_4i"
end

#labelObject

Usually the time component is used below the date component (for a DateTime attribute). So, normally we don’t want the label to be shown twice.



43
44
45
# File 'app/components/formatic/time.rb', line 43

def label # rubocop:disable Naming/PredicateMethod
  false
end

#minute_attribute_nameObject



59
60
61
# File 'app/components/formatic/time.rb', line 59

def minute_attribute_name
  "#{f.object.model_name.param_key}[#{attribute_name}(5i)]"
end

#minute_input_idObject



67
68
69
# File 'app/components/formatic/time.rb', line 67

def minute_input_id
  "#{f.object.model_name.param_key}_#{attribute_name}_5i"
end

#options_for_hourObject



47
48
49
# File 'app/components/formatic/time.rb', line 47

def options_for_hour
  options_for_select collection_for_hour, f.object.public_send(attribute_name)&.hour
end

#options_for_minuteObject



51
52
53
# File 'app/components/formatic/time.rb', line 51

def options_for_minute
  options_for_select collection_for_minute, f.object.public_send(attribute_name)&.min
end