Sha256: a553e95aa3972130e1495e31e525392c3e776a8a8331cf5a181949e0f8361137

Contents?: true

Size: 1.02 KB

Versions: 22

Compression:

Stored size: 1.02 KB

Contents

class AdminAssistant
  class DefaultSearchColumn < Column
    def initialize(model_class, opts)
      @model_class = model_class
      @fields_to_match = opts[:fields_to_match] || []
    end
    
    def add_to_query_condition(ar_query_condition, search)
      unless search.params.blank?
        ar_query_condition.ar_query.boolean_join = :and
        ar_query_condition.boolean_join = :or
        @fields_to_match.each do |field_name|
          ar_query_condition.sqls << "LOWER(#{field_name}) like LOWER(?)"
          ar_query_condition.bind_vars << "%#{search.params}%"
        end
      end
    end
    
    def attributes_for_search_object(search_params, compare_to_range)
      {}
    end
      
    def search_view(action_view, admin_assistant, opts={})
      View.new self, action_view
    end
    
    class View
      def initialize(column, action_view)
        @column, @action_view = column, action_view
      end
      
      def html(form)
        @action_view.text_field_tag("search", form.object.params)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
admin_assistant-2.4.0 lib/admin_assistant/default_search_column.rb
admin_assistant-2.3.2 lib/admin_assistant/default_search_column.rb
admin_assistant-2.3.1 lib/admin_assistant/default_search_column.rb
admin_assistant-2.3.0 lib/admin_assistant/default_search_column.rb
admin_assistant-1.0.4 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.8 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.7 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.6 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.5 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.4 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.3 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.2 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.1 lib/admin_assistant/default_search_column.rb
admin_assistant-2.2.0 lib/admin_assistant/default_search_column.rb
admin_assistant-2.1.1 lib/admin_assistant/default_search_column.rb
admin_assistant-2.1.0 lib/admin_assistant/default_search_column.rb
admin_assistant-2.0.1 lib/admin_assistant/default_search_column.rb
admin_assistant-2.0.0 lib/admin_assistant/default_search_column.rb
admin_assistant-2.0.0.pre2 lib/admin_assistant/default_search_column.rb
admin_assistant-2.0.0.pre1 lib/admin_assistant/default_search_column.rb