Class: BetweenOrEqualInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- BetweenOrEqualInput
show all
- Defined in:
- app/inputs/between_or_equal_input.rb
Instance Method Summary
collapse
Instance Method Details
#gteq_field ⇒ Object
13
14
15
|
# File 'app/inputs/between_or_equal_input.rb', line 13
def gteq_field
@builder.input_field(:"#{attribute_name}_gteq", gteq_input_html_options)
end
|
27
28
29
|
# File 'app/inputs/between_or_equal_input.rb', line 27
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
17
18
19
20
|
# File 'app/inputs/between_or_equal_input.rb', line 17
def gteq_value
return unless object
object.send(:"#{attribute_name}_gteq".to_sym)
end
|
2
3
4
5
6
7
8
9
10
11
|
# File 'app/inputs/between_or_equal_input.rb', line 2
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
52
53
54
|
# File 'app/inputs/between_or_equal_input.rb', line 52
def label_target
:"#{attribute_name}_gteq"
end
|
#literal_and ⇒ Object
43
44
45
|
# File 'app/inputs/between_or_equal_input.rb', line 43
def literal_and
template.content_tag(:span, ' and ', class: 'input-group-text rounded-0',)
end
|
#lteq_field ⇒ Object
31
32
33
|
# File 'app/inputs/between_or_equal_input.rb', line 31
def lteq_field
@builder.input_field(:"#{attribute_name}_lteq", lteq_input_html_options)
end
|
35
36
37
|
# File 'app/inputs/between_or_equal_input.rb', line 35
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
22
23
24
25
|
# File 'app/inputs/between_or_equal_input.rb', line 22
def lteq_value
return unless object
object.send(:"#{attribute_name}_lteq".to_sym)
end
|
#span_gteq ⇒ Object
39
40
41
|
# File 'app/inputs/between_or_equal_input.rb', line 39
def span_gteq
template.content_tag(:span, '>=', class: 'input-group-text')
end
|
#span_lteq ⇒ Object
47
48
49
|
# File 'app/inputs/between_or_equal_input.rb', line 47
def span_lteq
template.content_tag(:span, '<=', class: 'input-group-text')
end
|