Class: ActionView::Helpers::EnhancedDateTimeSelector
- Inherits:
-
DateTimeSelector
- Object
- DateTimeSelector
- ActionView::Helpers::EnhancedDateTimeSelector
- Defined in:
- lib/enhanced_date_select.rb
Instance Method Summary collapse
Instance Method Details
#enhanced_select_date ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/enhanced_date_select.rb', line 49 def enhanced_select_date order = date_order.dup (order) # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are valid (otherwise it could be 31 and February wouldn't be a valid date) if @datetime && [:discard_day] && ![:discard_month] if @datetime.is_a?(Hash) @datetime[:day] = 1 else @datetime = @datetime.change(day: 1) end end %w(day month year).each do |o| order.unshift(o.to_sym) unless order.include?(o.to_sym) end build_selects_from_types(order) end |
#reset_options_enhanced(order) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/enhanced_date_select.rb', line 66 def (order) [:discard_hour] = true [:discard_minute] = true [:discard_second] = true [:discard_year] ||= true unless order.include?(:year) [:discard_month] ||= true unless order.include?(:month) [:discard_day] ||= true if [:discard_month] || !order.include?(:day) end |