Sha256: 4b97b02419ae73a42e5739e54d01e7071cd66788702094aaf04dd3ed59976d39

Contents?: true

Size: 958 Bytes

Versions: 6

Compression:

Stored size: 958 Bytes

Contents

module ActiveAdmin
  module Inputs
    class FilterDateRangeInput < ::Formtastic::Inputs::StringInput
      include FilterBase

      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 => "seperator"),
            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)
        current_value = @object.send(input_name)
        { :size => 12,
          :class => "datepicker",
          :max => 10,
          :value => current_value.respond_to?(:strftime) ? current_value.strftime("%Y-%m-%d") : "" }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
yousty-activeadmin-1.0.4.pre lib/active_admin/inputs/filter_date_range_input.rb
yousty-activeadmin-1.0.3.pre lib/active_admin/inputs/filter_date_range_input.rb
yousty-activeadmin-1.0.2.pre lib/active_admin/inputs/filter_date_range_input.rb
yousty-activeadmin-1.0.1.pre lib/active_admin/inputs/filter_date_range_input.rb
yousty-activeadmin-1.0.0.pre lib/active_admin/inputs/filter_date_range_input.rb
aa-rails4-0.6.0 lib/active_admin/inputs/filter_date_range_input.rb