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

#data, #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



57
58
59
# File 'app/components/formatic/time.rb', line 57

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

#hour_input_idObject



65
66
67
# File 'app/components/formatic/time.rb', line 65

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.



45
46
47
# File 'app/components/formatic/time.rb', line 45

def label # rubocop:disable Naming/PredicateMethod
  false
end

#minute_attribute_nameObject



61
62
63
# File 'app/components/formatic/time.rb', line 61

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

#minute_input_idObject



69
70
71
# File 'app/components/formatic/time.rb', line 69

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

#options_for_hourObject



49
50
51
# File 'app/components/formatic/time.rb', line 49

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

#options_for_minuteObject



53
54
55
# File 'app/components/formatic/time.rb', line 53

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