Sha256: 7b35672676a0024d8884fad0cdbb5f2fd3197a67b1fba5a12dbacc77d81b3bfe

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

# Helper methods for the advanced search form
module AdvancedHelper

  # Fill in default from existing search, if present
  # -- if you are using same search fields for basic
  # search and advanced, will even fill in properly if existing
  # search used basic search on same field present in advanced. 
  def label_tag_default_for(key)
    if (! params[key].blank?)
      return params[key]
    elsif params["search_field"] == key
      return params["q"]
    else
      return nil
    end    
  end

  # Is facet value in adv facet search results?
  def facet_value_checked?(field, value)
    params[:f_inclusive] && params[:f_inclusive][field] && params[:f_inclusive][field][value]
  end

  # Current params without fields that will be over-written by adv. search,
  # or other fields we don't want. 
  def advanced_search_context
    my_params = params.dup
    [:page, :commit, :f_inclusive, :q, :search_field, :op, :action, :index, :sort, :controller].each do |bad_key|
      my_params.delete(bad_key)
    end
    search_fields_for_advanced_search.each do |key, field_def|
      my_params.delete( field_def[:key] )
    end
    my_params
  end

  def search_fields_for_advanced_search
    blacklight_config.search_fields
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight_advanced_search-1.2.3 app/helpers/advanced_helper.rb
blacklight_advanced_search-1.2.2 app/helpers/advanced_helper.rb
blacklight_advanced_search-1.2.1 app/helpers/advanced_helper.rb
blacklight_advanced_search-1.2.0 app/helpers/advanced_helper.rb