Sha256: 1dac1d9fdd9d0ef84ec7a169d3e408eed403dde3ab253a8bcfdc6aa849bd661b

Contents?: true

Size: 1.42 KB

Versions: 20

Compression:

Stored size: 1.42 KB

Contents

module ActiveAdmin
  module Inputs
    module Filters
      class SelectInput < ::Formtastic::Inputs::SelectInput
        include Base

        def input_name
          return method if seems_searchable?

          searchable_method_name.concat multiple? ? '_in' : '_eq'
        end

        def searchable_method_name
          if searchable_has_many_through?
            "#{reflection.through_reflection.name}_#{reflection.foreign_key}"
          else
            name = method.to_s
            name.concat '_id' if reflection
            name
          end
        end

        # Provide the AA translation to the blank input field.
        def include_blank
          I18n.t 'active_admin.any' if super
        end

        def input_html_options_name
          "#{object_name}[#{input_name}]" # was "#{object_name}[#{association_primary_key}]"
        end

        # Would normally return true for has_many and HABTM, which would subsequently
        # cause the select field to be multi-select instead of a dropdown.
        def multiple_by_association?
          false
        end

        # Provides an efficient default lookup query if the attribute is a DB column.
        def collection
          if !options[:collection] && column
            pluck_column
          else
            super
          end
        end

        def pluck_column
          klass.reorder("#{method} asc").uniq.pluck method
        end

      end
    end
  end
end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/inputs/filters/select_input.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.17.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/inputs/filters/select_input.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/inputs/filters/select_input.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/inputs/filters/select_input.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.15.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.14.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.13.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.12.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.11.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.10.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.9.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.8.pre lib/active_admin/inputs/filters/select_input.rb
activeadmin-1.0.0.pre2 lib/active_admin/inputs/filters/select_input.rb
activeadmin-1.0.0.pre1 lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.7.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.6.pre lib/active_admin/inputs/filters/select_input.rb
yousty-activeadmin-1.0.5.pre lib/active_admin/inputs/filters/select_input.rb