Class: RangeSelectInput

Inherits:
Formtastic::Inputs::StringInput
  • Object
show all
Includes:
ActiveAdmin::Inputs::Filters::Base
Defined in:
app/inputs/range_select_input.rb

Instance Method Summary collapse

Instance Method Details

#gt_input_nameObject Also known as: input_name



15
16
17
# File 'app/inputs/range_select_input.rb', line 15

def gt_input_name
  "#{method}_gteq"
end

#input_html_options(input_name = gt_input_name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'app/inputs/range_select_input.rb', line 25

def input_html_options(input_name = gt_input_name)
  is_gt = (input_name == gt_input_name)

  {
    type: "number",
    step: "any",
    value: @object.public_send(input_name),
    placeholder: is_gt ? "min" : "max"
  }
end

#lt_input_nameObject



21
22
23
# File 'app/inputs/range_select_input.rb', line 21

def lt_input_name
  "#{method}_lteq"
end

#to_htmlObject



4
5
6
7
8
9
10
11
12
13
# File 'app/inputs/range_select_input.rb', line 4

def to_html
  input_wrapping do
    [
      label_html,
      builder.text_field(gt_input_name, input_html_options(gt_input_name)),
      template.(:span, "-", class: "separator"),
      builder.text_field(lt_input_name, input_html_options(lt_input_name)),
    ].join("\n").html_safe
  end
end