Class: Avo::Filters::DateTimeFilter

Inherits:
BaseFilter show all
Defined in:
lib/avo/filters/date_time_filter.rb

Constant Summary

Constants inherited from BaseFilter

BaseFilter::PARAM_KEY

Instance Attribute Summary

Attributes inherited from BaseFilter

#arguments

Instance Method Summary collapse

Methods inherited from BaseFilter

#applied_filters, #applied_or_default_value, #apply_query, #current_user, decode_filters, encode_filters, get_empty_message, #id, #initialize, #visible_in_view

Constructor Details

This class inherits a constructor from Avo::Filters::BaseFilter

Instance Method Details

#has_time?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/avo/filters/date_time_filter.rb', line 35

def has_time?
  @has_time ||= type.in?([:time, :date_time])
end

#picker_formatObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/avo/filters/date_time_filter.rb', line 11

def picker_format
  case type
  when :date
    "Y-m-d"
  when :date_time
    "Y-m-d H:i:S"
  when :time
    "H:i:S"
  end
end

#picker_options(value) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/avo/filters/date_time_filter.rb', line 22

def picker_options(value)
  {
    defaultDate: value,
    enableTime: has_time?,
    enableSeconds: has_time?,
    time_24hr: has_time? ? true : nil,
    noCalendar: type == :time,
    mode: mode,
    dateFormat: picker_format,
    minuteIncrement: has_time? ? 1 : nil
  }.compact
end