Class: ScheduleAttributes::FormBuilder
- Inherits:
-
Formtastic::FormBuilder
- Object
- Formtastic::FormBuilder
- ScheduleAttributes::FormBuilder
- Defined in:
- lib/schedule_attributes/form_builder.rb
Instance Method Summary collapse
- #hiding_field_options(class_name, hidden = false, options = {}) ⇒ Object
- #one_time_fields(options = {}, &block) ⇒ Object
- #ordinal_fields(options = {}, &block) ⇒ Object
- #ordinal_month_days ⇒ Object
- #ordinal_month_weeks ⇒ Object
- #repeat_fields(options = {}, &block) ⇒ Object
- #weekday_fields(options = {}, &block) ⇒ Object
- #weekdays ⇒ Object
Instance Method Details
#hiding_field_options(class_name, hidden = false, options = {}) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/schedule_attributes/form_builder.rb', line 35 def (class_name, hidden=false, ={}) hidden_style = "display: none" if hidden .tap do |o| o.merge!(style: [o[:style], hidden_style].compact.join('; ')) o.merge!(class: [o[:class], class_name].compact.join(' ')) end end |
#one_time_fields(options = {}, &block) ⇒ Object
15 16 17 18 |
# File 'lib/schedule_attributes/form_builder.rb', line 15 def one_time_fields(={}, &block) hidden = object.repeat.to_i == 1 @template.content_tag :div, ("schedule_one_time_fields", hidden, ), &block end |
#ordinal_fields(options = {}, &block) ⇒ Object
25 26 27 28 |
# File 'lib/schedule_attributes/form_builder.rb', line 25 def ordinal_fields(={}, &block) hidden = object.interval_unit == 'month' && object.by_day_of == 'week' @template.content_tag :div, ("schedule_ordinal_fields", hidden, ), &block end |
#ordinal_month_days ⇒ Object
7 8 9 |
# File 'lib/schedule_attributes/form_builder.rb', line 7 def ordinal_month_days (1..31).map { |d| [d.ordinalize, d] } end |
#ordinal_month_weeks ⇒ Object
11 12 13 |
# File 'lib/schedule_attributes/form_builder.rb', line 11 def ordinal_month_weeks Hash["first", 1, "second", 2, "third", 3, "fourth", 4, "last", -1] end |
#repeat_fields(options = {}, &block) ⇒ Object
20 21 22 23 |
# File 'lib/schedule_attributes/form_builder.rb', line 20 def repeat_fields(={}, &block) hidden = object.repeat.to_i != 1 @template.content_tag :div, ("schedule_repeat_fields", hidden, ), &block end |
#weekday_fields(options = {}, &block) ⇒ Object
30 31 32 33 |
# File 'lib/schedule_attributes/form_builder.rb', line 30 def weekday_fields(={}, &block) hidden = false @template.content_tag :div, ("schedule_weekday_fields", hidden, ), &block end |
#weekdays ⇒ Object
3 4 5 |
# File 'lib/schedule_attributes/form_builder.rb', line 3 def weekdays Hash[ I18n.t('date.day_names').zip(ScheduleAttributes::DAY_NAMES) ] end |