Class: ActiveAdmin::Inputs::Filters::DateRangeInput
- Inherits:
-
Formtastic::Inputs::StringInput
- Object
- Formtastic::Inputs::StringInput
- ActiveAdmin::Inputs::Filters::DateRangeInput
show all
- Includes:
- Base
- Defined in:
- lib/active_admin/inputs/filters/date_range_input.rb
Instance Method Summary
collapse
Methods included from Base
#collection_from_options, #input_wrapping, #label_from_options, #required?, #wrapper_html_options
#column, #column_for, #has_predicate?, #humanized_method_name, #klass, #polymorphic_foreign_type?, #reflection_for, #scope?, #searchable_has_many_through?, #seems_searchable?
#input_wrapping
Instance Method Details
19
20
21
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 19
def gt_input_name
"#{method}_gteq"
end
|
45
46
47
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 45
def gt_input_placeholder
I18n.t("active_admin.filters.predicates.from")
end
|
28
29
30
31
32
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 28
def input_html_options
{ size: 12,
class: "datepicker",
maxlength: 10 }.merge(options[:input_html] || {})
end
|
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 34
def input_html_options_for(input_name, placeholder)
current_value = begin
@object.public_send(input_name).to_s.to_date
rescue
nil
end
{ placeholder: placeholder,
value: current_value ? current_value.strftime("%Y-%m-%d") : "" }.merge(input_html_options)
end
|
24
25
26
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 24
def lt_input_name
"#{method}_lteq"
end
|
49
50
51
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 49
def lt_input_placeholder
I18n.t("active_admin.filters.predicates.to")
end
|
#to_html ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/active_admin/inputs/filters/date_range_input.rb', line 8
def to_html
input_wrapping do
[ label_html,
'<div class="filter-input-group">',
builder.date_field(gt_input_name, input_html_options_for(gt_input_name, gt_input_placeholder)),
builder.date_field(lt_input_name, input_html_options_for(lt_input_name, lt_input_placeholder)),
'</div>'
].join("\n").html_safe
end
end
|