Class: ActiveAdmin::Inputs::FilterDateRangeInput

Inherits:
Formtastic::Inputs::StringInput
  • Object
show all
Includes:
FilterBase
Defined in:
lib/active_admin/inputs/filter_date_range_input.rb

Instance Method Summary collapse

Methods included from FilterBase

#collection_from_options, #humanized_method_name, #input_wrapping, #reflection_for, #required?, #wrapper_html_options

Instance Method Details

#gt_input_nameObject Also known as: input_name



16
17
18
# File 'lib/active_admin/inputs/filter_date_range_input.rb', line 16

def gt_input_name
  "#{method}_gte"
end

#input_html_options(input_name = gt_input_name) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/active_admin/inputs/filter_date_range_input.rb', line 25

def input_html_options(input_name = gt_input_name)
  current_value = @object.send(input_name)
  { :size => 12,
    :class => "datepicker",
    :max => 10,
    :value => current_value.respond_to?(:strftime) ? current_value.strftime("%Y-%m-%d") : "" }
end

#lt_input_nameObject



21
22
23
# File 'lib/active_admin/inputs/filter_date_range_input.rb', line 21

def lt_input_name
  "#{method}_lte"
end

#to_htmlObject



6
7
8
9
10
11
12
13
14
# File 'lib/active_admin/inputs/filter_date_range_input.rb', line 6

def to_html
  input_wrapping do
    [ label_html,
      builder.text_field(gt_input_name, input_html_options(gt_input_name)),
      template.(:span, "-", :class => "seperator"),
      builder.text_field(lt_input_name, input_html_options(lt_input_name)),
    ].join("\n").html_safe
  end
end