Class: Formatic::Date
- Inherits:
-
Base
show all
- Defined in:
- app/components/formatic/date.rb
Overview
Defined Under Namespace
Classes: Day
Instance Method Summary
collapse
Methods inherited from Base
#input_name, #param_key, #value, #wrapper
#initialize
Instance Method Details
#calendar(now: ::Time.current) ⇒ Object
89
90
91
92
93
94
95
96
|
# File 'app/components/formatic/date.rb', line 89
def calendar(now: ::Time.current)
from = 5.days.ago.to_date
till = now.beginning_of_month.advance(months: 2).end_of_month.to_date
(from..till).map do |date|
::Formatic::Date::Day.new(date:)
end
end
|
#calendar? ⇒ Boolean
46
47
48
49
50
51
|
# File 'app/components/formatic/date.rb', line 46
def calendar?
return false if show_calendar == false
return false if discard_day
true
end
|
#css_classes ⇒ Object
42
43
44
|
# File 'app/components/formatic/date.rb', line 42
def css_classes
i[c-formatic-date__input]
end
|
#day_attribute_name ⇒ Object
65
66
67
|
# File 'app/components/formatic/date.rb', line 65
def day_attribute_name
"#{f.object.model_name.param_key}[#{attribute_name}(3i)]"
end
|
77
78
79
|
# File 'app/components/formatic/date.rb', line 77
def day_input_id
"#{f.object.model_name.param_key}_#{attribute_name}_3i"
end
|
#month_attribute_name ⇒ Object
69
70
71
|
# File 'app/components/formatic/date.rb', line 69
def month_attribute_name
"#{f.object.model_name.param_key}[#{attribute_name}(2i)]"
end
|
81
82
83
|
# File 'app/components/formatic/date.rb', line 81
def month_input_id
"#{f.object.model_name.param_key}_#{attribute_name}_2i"
end
|
#options_for_day ⇒ Object
53
54
55
|
# File 'app/components/formatic/date.rb', line 53
def options_for_day
options_for_select collection_for_day, f.object.public_send(attribute_name)&.day
end
|
#options_for_month ⇒ Object
57
58
59
|
# File 'app/components/formatic/date.rb', line 57
def options_for_month
options_for_select collection_for_month, f.object.public_send(attribute_name)&.month
end
|
#options_for_year ⇒ Object
61
62
63
|
# File 'app/components/formatic/date.rb', line 61
def options_for_year
options_for_select collection_for_year, f.object.public_send(attribute_name)&.year
end
|
#year_attribute_name ⇒ Object
73
74
75
|
# File 'app/components/formatic/date.rb', line 73
def year_attribute_name
"#{f.object.model_name.param_key}[#{attribute_name}(1i)]"
end
|
85
86
87
|
# File 'app/components/formatic/date.rb', line 85
def year_input_id
"#{f.object.model_name.param_key}_#{attribute_name}_1i"
end
|