Class: Blacklight::Configuration::FacetField
- Inherits:
 - 
      Field
      
        
- Object
 - OpenStruct
 - OpenStructWithHashAccess
 - Field
 - Blacklight::Configuration::FacetField
 
 
- Defined in:
 - lib/blacklight/configuration/facet_field.rb
 
Instance Attribute Summary collapse
- 
  
    
      #collapse  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Whether to display the facet in a collapsed state by default.
 - 
  
    
      #collapsing  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Display pivot facets with an expand / collapse toggle.
 - #component ⇒ Blacklight::FacetFieldListComponent
 - 
  
    
      #date  ⇒ Symbol|Hash 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The i18n localization option for a date or time value; used as the second parameter for the I18n.l method.
 - #ex ⇒ String
 - 
  
    
      #filter_class  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
@ return [nil, Blacklight::SearchState::FilterField] a class that implements the ‘FilterField`’s’ API to manage URL parameters for a facet.
 - 
  
    
      #filter_query_builder  ⇒ nil, #call 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
A Proc (or other object responding to #call) that receives as parameters: 1) the search builder, 2) the Blacklight::FilterField instance and 3) the solr parameters hash.
 - 
  
    
      #helper_method  ⇒ Symbol 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The name of a helper method used to display the facet’s value to the user; it receives the facet value.
 - 
  
    
      #icons  ⇒ Hash 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Icons to use for pivot facet expand + collapse.
 - 
  
    
      #index_range  ⇒ Enumerable 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
A list of facet prefixes (default: A-Z) to allow users to ‘jump’ to particular values.
 - #item_component ⇒ Blacklight::FacetItemComponent
 - #item_presenter ⇒ Blacklight::FacetItemPresenter
 - #link_to_facet ⇒ Boolean
 - 
  
    
      #partial  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Rails view partial used to render the facet field.
 - 
  
    
      #pivot  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
[].
 - #presenter ⇒ Blacklight::FacetFieldPresenter
 - 
  
    
      #query  ⇒ Hash{String => Hash} 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Provides support for facet queries; the keys are mapped to user-facing parameters, and the values are a hash containing: label (a label to show the user in the facet interface), fq (a string passed into solr as an fq (when selected) or a facet.query).
 - 
  
    
      #show  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Whether to show the facet to the user or not (very similar to the more generic if/unless).
 - 
  
    
      #single  ⇒ Boolean 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Whether the facet values are mutually exclusive; or, for more granular control, see tag + ex.
 - 
  
    
      #sort  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The ordering of the facet field constraints; when using Solr, this is either ‘count’ or ‘index’.
 - #tag ⇒ String
 - 
  
    
      #url_method  ⇒ Symbol 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
The name of a helper to use for getting the url for a facet link; the method will receive the facet field’s key and value.
 
Attributes inherited from Field
#field, #if, #key, #label, #unless
Instance Method Summary collapse
- 
  
    
      #normalize!(blacklight_config = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
 
Methods inherited from Field
#default_label, #display_label, #validate!
Methods inherited from OpenStructWithHashAccess
#deep_dup, #deep_transform_values, #merge, #merge!, #reverse_merge, #select, #sort_by, #sort_by!, #to_h, #try
Instance Attribute Details
#collapse ⇒ Boolean
Returns whether to display the facet in a collapsed state by default.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#collapsing ⇒ Boolean
Returns display pivot facets with an expand / collapse toggle.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#component ⇒ Blacklight::FacetFieldListComponent
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 55
     | 
  
#date ⇒ Symbol|Hash
Returns the i18n localization option for a date or time value; used as the second parameter for the I18n.l method.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#ex ⇒ String
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#filter_class ⇒ Object
@ return [nil, Blacklight::SearchState::FilterField] a class that implements the ‘FilterField`’s’ API to manage URL parameters for a facet
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#filter_query_builder ⇒ nil, #call
Returns a Proc (or other object responding to #call) that receives as parameters: 1) the search builder, 2) the Blacklight::FilterField instance and 3) the solr parameters hash. The Proc returns a string suitable for e.g. Solr’s fq parameter, or a 2-element array of the string and a hash of additional parameters to include with the query (i.e. for referenced subqueries); note that implementations are responsible for ensuring the additional parameter keys are unique.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#helper_method ⇒ Symbol
Returns the name of a helper method used to display the facet’s value to the user; it receives the facet value.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#icons ⇒ Hash
Returns Icons to use for pivot facet expand + collapse.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#index_range ⇒ Enumerable
Returns a list of facet prefixes (default: A-Z) to allow users to ‘jump’ to particular values.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#item_component ⇒ Blacklight::FacetItemComponent
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 55
     | 
  
#item_presenter ⇒ Blacklight::FacetItemPresenter
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 55
     | 
  
#link_to_facet ⇒ Boolean
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#partial ⇒ String
Returns Rails view partial used to render the facet field.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 55
     | 
  
#pivot ⇒ Object
Returns [].
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#presenter ⇒ Blacklight::FacetFieldPresenter
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 55
     | 
  
#query ⇒ Hash{String => Hash}
Returns Provides support for facet queries; the keys are mapped to user-facing parameters, and the values are a hash containing: label (a label to show the user in the facet interface), fq (a string passed into solr as an fq (when selected) or a facet.query).
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#show ⇒ Boolean
Returns whether to show the facet to the user or not (very similar to the more generic if/unless).
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
#single ⇒ Boolean
Returns whether the facet values are mutually exclusive; or, for more granular control, see tag + ex.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#sort ⇒ String
Returns the ordering of the facet field constraints; when using Solr, this is either ‘count’ or ‘index’.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#tag ⇒ String
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 32
     | 
  
#url_method ⇒ Symbol
Returns The name of a helper to use for getting the url for a facet link; the method will receive the facet field’s key and value.
| 
       | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 11
     | 
  
Instance Method Details
#normalize!(blacklight_config = nil) ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
      69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90  | 
    
      # File 'lib/blacklight/configuration/facet_field.rb', line 69 def normalize! blacklight_config = nil query.stringify_keys! if query normalize_pivot_config! if pivot self.collapse = true if collapse.nil? self.show = true if show.nil? self.if = show if self.if.nil? self.index_range = 'A'..'Z' if index_range == true self.presenter ||= Blacklight::FacetFieldPresenter self.item_presenter ||= Blacklight::FacetItemPresenter self.component = Blacklight::FacetFieldListComponent if component.nil? || component == true self.advanced_search_component ||= Blacklight::FacetFieldCheckboxesComponent self.item_component ||= Blacklight::FacetItemComponent super if single && tag.blank? && ex.blank? self.tag = "#{key}_single" self.ex = "#{key}_single" end self end  |