Class: Blacklight::Configuration::FacetField

Inherits:
Field show all
Defined in:
lib/blacklight/configuration/facet_field.rb

Instance Attribute Summary collapse

Attributes inherited from Field

#field, #if, #key, #label, #unless

Instance Method Summary collapse

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

#collapseBoolean

Returns whether to display the facet in a collapsed state by default.

Returns:

  • (Boolean)

    whether to display the facet in a collapsed state by default



# File 'lib/blacklight/configuration/facet_field.rb', line 11

#collapsingBoolean

Returns display pivot facets with an expand / collapse toggle.

Returns:

  • (Boolean)

    display pivot facets with an expand / collapse toggle



# File 'lib/blacklight/configuration/facet_field.rb', line 11

#componentBlacklight::FacetFieldListComponent



# File 'lib/blacklight/configuration/facet_field.rb', line 55

#dateSymbol|Hash

Returns the i18n localization option for a date or time value; used as the second parameter for the I18n.l method.

Returns:

  • (Symbol|Hash)

    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

#exString



# File 'lib/blacklight/configuration/facet_field.rb', line 32

#filter_classObject

@ 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_buildernil, #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.

Returns:

  • (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. 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_methodSymbol

Returns the name of a helper method used to display the facet’s value to the user; it receives the facet value.

Returns:

  • (Symbol)

    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

#iconsHash

Returns Icons to use for pivot facet expand + collapse.

Returns:

  • (Hash)

    Icons to use for pivot facet expand + collapse



# File 'lib/blacklight/configuration/facet_field.rb', line 11

#index_rangeEnumerable

Returns a list of facet prefixes (default: A-Z) to allow users to ‘jump’ to particular values.

Returns:

  • (Enumerable)

    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_componentBlacklight::FacetItemComponent



# File 'lib/blacklight/configuration/facet_field.rb', line 55

#item_presenterBlacklight::FacetItemPresenter



# File 'lib/blacklight/configuration/facet_field.rb', line 55

Returns:

  • (Boolean)


# File 'lib/blacklight/configuration/facet_field.rb', line 11

#partialString

Returns Rails view partial used to render the facet field.

Returns:

  • (String)

    Rails view partial used to render the facet field



# File 'lib/blacklight/configuration/facet_field.rb', line 55

#pivotObject

Returns [].

Returns:



# File 'lib/blacklight/configuration/facet_field.rb', line 32

#presenterBlacklight::FacetFieldPresenter



# File 'lib/blacklight/configuration/facet_field.rb', line 55

#queryHash{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).

Returns:

  • (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)



# File 'lib/blacklight/configuration/facet_field.rb', line 32

#showBoolean

Returns whether to show the facet to the user or not (very similar to the more generic if/unless).

Returns:

  • (Boolean)

    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

#singleBoolean

Returns whether the facet values are mutually exclusive; or, for more granular control, see tag + ex.

Returns:

  • (Boolean)

    whether the facet values are mutually exclusive; or, for more granular control, see tag + ex



# File 'lib/blacklight/configuration/facet_field.rb', line 32

#sortString

Returns the ordering of the facet field constraints; when using Solr, this is either ‘count’ or ‘index’.

Returns:

  • (String)

    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

#tagString



# File 'lib/blacklight/configuration/facet_field.rb', line 32

#url_methodSymbol

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.

Returns:

  • (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.



# 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