Class: BetweenOrEqualInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- BetweenOrEqualInput
show all
- Defined in:
- app/inputs/between_or_equal_input.rb
Overview
SimpleForm input wrapper: between or equal.
Instance Method Summary
collapse
Instance Method Details
#gteq_field ⇒ Object
15
16
17
|
# File 'app/inputs/between_or_equal_input.rb', line 15
def gteq_field
@builder.input_field(:"#{attribute_name}_gteq", gteq_input_html_options)
end
|
31
32
33
|
# File 'app/inputs/between_or_equal_input.rb', line 31
def gteq_input_html_options
input_html_options.merge({ as: :integer, placeholder: 'Greater than or equal to', value: gteq_value, class: 'form-control gteq_field' })
end
|
#gteq_value ⇒ Object
19
20
21
22
23
|
# File 'app/inputs/between_or_equal_input.rb', line 19
def gteq_value
return unless object
object.send(:"#{attribute_name}_gteq")
end
|
4
5
6
7
8
9
10
11
12
13
|
# File 'app/inputs/between_or_equal_input.rb', line 4
def input(_wrapper_options)
template.content_tag(:div, class: 'input-group') do
template.concat span_gteq
template.concat gteq_field
template.concat literal_and
template.concat lteq_field
template.concat span_lteq
end
end
|
#label_target ⇒ Object
Make the label be for the first of the two fields
56
57
58
|
# File 'app/inputs/between_or_equal_input.rb', line 56
def label_target
:"#{attribute_name}_gteq"
end
|
#literal_and ⇒ Object
47
48
49
|
# File 'app/inputs/between_or_equal_input.rb', line 47
def literal_and
template.content_tag(:span, ' and ', class: 'input-group-text rounded-0')
end
|
#lteq_field ⇒ Object
35
36
37
|
# File 'app/inputs/between_or_equal_input.rb', line 35
def lteq_field
@builder.input_field(:"#{attribute_name}_lteq", lteq_input_html_options)
end
|
39
40
41
|
# File 'app/inputs/between_or_equal_input.rb', line 39
def lteq_input_html_options
input_html_options.merge({ as: :integer, placeholder: 'Less than or equal to', value: lteq_value, class: 'form-control lteq_field' })
end
|
#lteq_value ⇒ Object
25
26
27
28
29
|
# File 'app/inputs/between_or_equal_input.rb', line 25
def lteq_value
return unless object
object.send(:"#{attribute_name}_lteq")
end
|
#span_gteq ⇒ Object
43
44
45
|
# File 'app/inputs/between_or_equal_input.rb', line 43
def span_gteq
template.content_tag(:span, '>=', class: 'input-group-text')
end
|
#span_lteq ⇒ Object
51
52
53
|
# File 'app/inputs/between_or_equal_input.rb', line 51
def span_lteq
template.content_tag(:span, '<=', class: 'input-group-text')
end
|