diff --git a/lib/schedule_attributes.rb b/lib/schedule_attributes.rb index dbb24f3..5cbd45f 100644 --- a/lib/schedule_attributes.rb +++ b/lib/schedule_attributes.rb @@ -1,6 +1,5 @@ require 'schedule_attributes/model' require 'schedule_attributes/railtie' if defined? Rails -require 'schedule_attributes/form_builder' if defined? Formtastic if defined? Arel module Arel::Visitors diff --git a/lib/schedule_attributes/form_builder.rb b/lib/schedule_attributes/form_builder.rb deleted file mode 100644 index f10ac5a..0000000 --- a/lib/schedule_attributes/form_builder.rb +++ /dev/null @@ -1,42 +0,0 @@ -class ScheduleAttributes::FormBuilder < Formtastic::FormBuilder - - def weekdays - Hash[ I18n.t('date.day_names').zip(ScheduleAttributes::DAY_NAMES) ] - end - - def ordinal_month_days - (1..31).map { |d| [d.ordinalize, d] } - end - - def ordinal_month_weeks - Hash["first", 1, "second", 2, "third", 3, "fourth", 4, "last", -1] - end - - def one_time_fields(options={}, &block) - hidden = object.repeat.to_i == 1 - @template.content_tag :div, hiding_field_options("schedule_one_time_fields", hidden, options), &block - end - - def repeat_fields(options={}, &block) - hidden = object.repeat.to_i != 1 - @template.content_tag :div, hiding_field_options("schedule_repeat_fields", hidden, options), &block - end - - def ordinal_fields(options={}, &block) - hidden = object.interval_unit == 'month' && object.by_day_of == 'week' - @template.content_tag :div, hiding_field_options("schedule_ordinal_fields", hidden, options), &block - end - - def weekday_fields(options={}, &block) - hidden = false - @template.content_tag :div, hiding_field_options("schedule_weekday_fields", hidden, options), &block - end - - def hiding_field_options(class_name, hidden=false, options={}) - hidden_style = "display: none" if hidden - options.tap do |o| - o.merge!(style: [o[:style], hidden_style].compact.join('; ')) - o.merge!(class: [o[:class], class_name].compact.join(' ')) - end - end -end