Sha256: 12af15f29bb97eaf371bdc326f53b370dd21cc9ae6a2cb95b845d187e0ee4b1e

Contents?: true

Size: 807 Bytes

Versions: 23

Compression:

Stored size: 807 Bytes

Contents

class RangeSelectInput < Formtastic::Inputs::StringInput
  include ActiveAdmin::Inputs::Filters::Base

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

  def gt_input_name
    "#{method}_gteq"
  end

  alias :input_name :gt_input_name

  def lt_input_name
    "#{method}_lteq"
  end

  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
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
activeadmin_addons-0.12.0 app/inputs/range_select_input.rb
activeadmin_addons-0.11.0 app/inputs/range_select_input.rb
activeadmin_addons-0.10.1 app/inputs/range_select_input.rb
activeadmin_addons-0.10.0 app/inputs/range_select_input.rb
activeadmin_addons-0.9.3 app/inputs/range_select_input.rb
activeadmin_addons-0.9.2 app/inputs/range_select_input.rb
activeadmin_addons-0.9.1 app/inputs/range_select_input.rb
activeadmin_addons-0.9.0 app/inputs/range_select_input.rb
activeadmin_addons-0.8.0 app/inputs/range_select_input.rb
activeadmin_addons-0.7.0 app/inputs/range_select_input.rb
activeadmin_addons-0.6.4 app/inputs/range_select_input.rb
activeadmin_addons-0.6.3 app/inputs/range_select_input.rb
activeadmin_addons-0.6.2 app/inputs/range_select_input.rb
activeadmin_addons-0.6.1 app/inputs/range_select_input.rb
activeadmin_addons-0.6.0 app/inputs/range_select_input.rb
activeadmin_addons-0.5.0 app/inputs/range_select_input.rb
activeadmin_addons-0.4.0 app/inputs/range_select_input.rb
activeadmin_addons-0.3.4 app/inputs/range_select_input.rb
activeadmin_addons-0.3.3 app/inputs/range_select_input.rb
activeadmin_addons-0.3.2 app/inputs/range_select_input.rb