Class: BetweenOrEqualDateInput
Overview
SimpleForm input wrapper: between or equal date.
Instance Method Summary
collapse
#input, #label_target, #literal_and, #span_gteq, #span_lteq
Instance Method Details
#clear_btn ⇒ Object
46
47
48
49
50
51
52
53
54
|
# File 'app/inputs/between_or_equal_date_input.rb', line 46
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-muted')
end
end
|
#gteq_field ⇒ Object
30
31
32
33
34
35
36
|
# File 'app/inputs/between_or_equal_date_input.rb', line 30
def gteq_field
template.content_tag(:div, class: 'flex-grow-1 gteq_field') do
options = gteq_input_html_options.dup
arel_predicate_gteq = options.delete(:arel_predicate_gteq).to_sym
@builder.input_field(arel_predicate_gteq, gteq_input_html_options)
end
end
|
4
5
6
7
8
9
10
|
# File 'app/inputs/between_or_equal_date_input.rb', line 4
def gteq_input_html_options
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 ⇒ Object
Cast as date, the field you're searching on might be a timestamp
21
22
23
|
# File 'app/inputs/between_or_equal_date_input.rb', line 21
def gteq_value
super.try(:to_date)
end
|
#lteq_field ⇒ Object
38
39
40
41
42
43
44
|
# File 'app/inputs/between_or_equal_date_input.rb', line 38
def lteq_field
template.content_tag(:div, class: 'flex-grow-1 lteq_field') do
options = lteq_input_html_options.dup
arel_predicate_lteq = options.delete(:arel_predicate_lteq).to_sym
@builder.input_field(arel_predicate_lteq, lteq_input_html_options)
end
end
|
12
13
14
15
16
17
18
|
# File 'app/inputs/between_or_equal_date_input.rb', line 12
def lteq_input_html_options
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 ⇒ Object
Cast as date, the field you're searching on might be a timestamp
26
27
28
|
# File 'app/inputs/between_or_equal_date_input.rb', line 26
def lteq_value
super.try(:to_date)
end
|