class ActionView::Helpers::EnhancedDateTimeSelector
Public Instance Methods
enhanced_select_date()
click to toggle source
# File lib/enhanced_date_select.rb, line 49 def enhanced_select_date order = date_order.dup reset_options_enhanced(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 && @options[:discard_day] && !@options[: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)
click to toggle source
# File lib/enhanced_date_select.rb, line 66 def reset_options_enhanced(order) @options[:discard_hour] = true @options[:discard_minute] = true @options[:discard_second] = true @options[:discard_year] ||= true unless order.include?(:year) @options[:discard_month] ||= true unless order.include?(:month) @options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day) end