Sha256: 55c364bece2bb46e3f2e5d56b047856573d4d603be865a2a39023d7276a514f9

Contents?: true

Size: 701 Bytes

Versions: 5

Compression:

Stored size: 701 Bytes

Contents

module ActiveAdmin
  module Inputs
    class FilterStringInput < ::Formtastic::Inputs::StringInput
      include FilterBase
      include FilterBase::SearchMethodSelect

      filter :contains, :equals, :starts_with, :ends_with

      # If the filter method includes a search condition, build a normal string search field.
      # Else, build a search field with a companion dropdown to choose a search condition from.
      def to_html
        if @object.respond_to? method
          input_wrapping do
            label_html <<
            builder.text_field(method, input_html_options)
          end
        else
          super # SearchMethodSelect#to_html
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activeadmin-0.6.5 lib/active_admin/inputs/filter_string_input.rb
activeadmin-0.6.4 lib/active_admin/inputs/filter_string_input.rb
activeadmin-0.6.3 lib/active_admin/inputs/filter_string_input.rb
activeadmin-0.6.2 lib/active_admin/inputs/filter_string_input.rb
activeadmin-0.6.1 lib/active_admin/inputs/filter_string_input.rb