Class: BetweenOrEqualDateInput
- Inherits:
-
BetweenOrEqualInput
- Object
- SimpleForm::Inputs::Base
- BetweenOrEqualInput
- BetweenOrEqualDateInput
- Defined in:
- app/inputs/between_or_equal_date_input.rb
Overview
SimpleForm input wrapper for a between-or-equal date range filter.
Direct Known Subclasses
Instance Method Summary collapse
-
#clear_btn ⇒ ActiveSupport::SafeBuffer
Renders the clear button.
-
#gteq_field ⇒ ActiveSupport::SafeBuffer
Renders the GTEQ input field wrapper.
-
#gteq_input_html_options ⇒ Hash
HTML options for the greater-than-or-equal date input.
-
#gteq_value ⇒ Date?
Casts the GTEQ value to a date.
-
#lteq_field ⇒ ActiveSupport::SafeBuffer
Renders the LTEQ input field wrapper.
-
#lteq_input_html_options ⇒ Hash
HTML options for the less-than-or-equal date input.
-
#lteq_value ⇒ Date?
Casts the LTEQ value to a date.
Methods inherited from BetweenOrEqualInput
#input, #label_target, #literal_and, #span_gteq, #span_lteq
Instance Method Details
#clear_btn ⇒ ActiveSupport::SafeBuffer
Renders the clear button.
70 71 72 73 74 75 76 77 78 |
# File 'app/inputs/between_or_equal_date_input.rb', line 70 def clear_btn template.content_tag(:a, { class: 'btn btn-outline-primary input-button date-clear-btn h-100 rounded-0', title: 'clear', data: { clear: true } }) do template.fa_icon('times', class: 'text-body-secondary') end end |
#gteq_field ⇒ ActiveSupport::SafeBuffer
Renders the GTEQ input field wrapper.
48 49 50 51 52 53 54 |
# File 'app/inputs/between_or_equal_date_input.rb', line 48 def gteq_field template.content_tag(:div, class: 'flex-grow-1 gteq_field') do = .dup arel_predicate_gteq = .delete(:arel_predicate_gteq).to_sym @builder.input_field(arel_predicate_gteq, ) end end |
#gteq_input_html_options ⇒ Hash
HTML options for the greater-than-or-equal date input.
8 9 10 11 12 13 14 |
# File 'app/inputs/between_or_equal_date_input.rb', line 8 def opts = super.reverse_merge({ arel_predicate_gteq: :"#{attribute_name}_gteq", placeholder: 'After or on', class: 'flex-grow-1' }) opts[:as] = :date_picker opts end |
#gteq_value ⇒ Date?
Casts the GTEQ value to a date.
The field being searched may be a timestamp, so we normalize to a date.
32 33 34 |
# File 'app/inputs/between_or_equal_date_input.rb', line 32 def gteq_value super.try(:to_date) end |
#lteq_field ⇒ ActiveSupport::SafeBuffer
Renders the LTEQ input field wrapper.
59 60 61 62 63 64 65 |
# File 'app/inputs/between_or_equal_date_input.rb', line 59 def lteq_field template.content_tag(:div, class: 'flex-grow-1 lteq_field') do = .dup arel_predicate_lteq = .delete(:arel_predicate_lteq).to_sym @builder.input_field(arel_predicate_lteq, ) end end |
#lteq_input_html_options ⇒ Hash
HTML options for the less-than-or-equal date input.
19 20 21 22 23 24 25 |
# File 'app/inputs/between_or_equal_date_input.rb', line 19 def opts = super.reverse_merge({ arel_predicate_lteq: :"#{attribute_name}_lteq", placeholder: 'Before or on', class: 'flex-grow-1' }) opts[:as] = :date_picker opts end |
#lteq_value ⇒ Date?
Casts the LTEQ value to a date.
The field being searched may be a timestamp, so we normalize to a date.
41 42 43 |
# File 'app/inputs/between_or_equal_date_input.rb', line 41 def lteq_value super.try(:to_date) end |