Sha256: a512fb9130d4818e5dacd453aba9749dcf36e9a466b2665e2d12964fcde3e8d3

Contents?: true

Size: 1.02 KB

Versions: 46

Compression:

Stored size: 1.02 KB

Contents

module ActiveAdmin
  module Inputs
    class FilterBooleanInput < ::Formtastic::Inputs::BooleanInput
      include FilterBase

      def to_html
        input_wrapping do 
          [ label_html,
            check_box_html
          ].join("\n").html_safe
        end
      end

      def check_box_html
        template.check_box_tag("#{object_name}[#{method}]", checked_value, checked?, input_html_options)
      end

      def search_method
        method.to_s.match(metasearch_conditions) ? method : "#{method}_eq"
      end

      def checked?
        if defined? ActionView::Helpers::InstanceTag
          object && ActionView::Helpers::InstanceTag.check_box_checked?(object.send(search_method), checked_value)
        else
          object && boolean_checked?(object.send(search_method), checked_value)
        end
      end

      def input_html_options
        { :name => "q[#{search_method}]" }
      end

      def metasearch_conditions
        /(is_true|is_false|is_present|is_blank|is_null|is_not_null)$/
      end

    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
lalala-4.0.0.dev.141 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.134 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/lib/active_admin/inputs/filter_boolean_input.rb