Sha256: 9d6d4b4f92bff6cacf5739fde4578cf5dae494969fa52c69075254fb74b5fc0c

Contents?: true

Size: 1.05 KB

Versions: 17

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  module Inputs
    module Filters
      module Base
        include ::Formtastic::Inputs::Base
        include ::ActiveAdmin::Filters::FormtasticAddons

        extend ::ActiveSupport::Autoload
        autoload :SearchMethodSelect

        def input_wrapping(&block)
          template.content_tag :div, template.capture(&block), wrapper_html_options
        end

        def required?
          false
        end

        # Can pass proc to filter label option
        def label_from_options
          res = super
          res = res.call if res.is_a? Proc
          res
        end

        def wrapper_html_options
          opts = super
          (opts[:class] ||= "") << " filter_form_field filter_#{as}"
          opts
        end

        # Override the standard finder to accept a proc
        def collection_from_options
          if options[:collection].is_a?(Proc)
            template.instance_exec(&options[:collection])
          else
            super
          end
        end

      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
activeadmin-3.2.5 lib/active_admin/inputs/filters/base.rb
activeadmin-3.2.4 lib/active_admin/inputs/filters/base.rb
activeadmin-3.2.3 lib/active_admin/inputs/filters/base.rb
activeadmin-3.2.2 lib/active_admin/inputs/filters/base.rb
activeadmin-3.2.1 lib/active_admin/inputs/filters/base.rb
activeadmin-3.2.0 lib/active_admin/inputs/filters/base.rb
activeadmin-3.1.0 lib/active_admin/inputs/filters/base.rb
activeadmin-3.0.0 lib/active_admin/inputs/filters/base.rb
activeadmin-2.14.0 lib/active_admin/inputs/filters/base.rb
activeadmin-2.13.1 lib/active_admin/inputs/filters/base.rb
activeadmin-2.13.0 lib/active_admin/inputs/filters/base.rb
activeadmin-2.12.0 lib/active_admin/inputs/filters/base.rb
activeadmin-2.11.2 lib/active_admin/inputs/filters/base.rb
activeadmin-2.11.1 lib/active_admin/inputs/filters/base.rb
activeadmin-2.11.0 lib/active_admin/inputs/filters/base.rb
activeadmin-2.10.1 lib/active_admin/inputs/filters/base.rb
activeadmin-2.10.0 lib/active_admin/inputs/filters/base.rb