lib/blacklight/configuration/facet_field.rb in blacklight-7.40.0 vs lib/blacklight/configuration/facet_field.rb in blacklight-8.0.0.beta1

- old
+ new

@@ -1,6 +1,7 @@ # frozen_string_literal: true + module Blacklight class Configuration::FacetField < Blacklight::Configuration::Field ## # The following is a non-exhaustive list of facet config parameters that are used # by Blacklight directly. Application-specific code or plugins may add or replace @@ -17,13 +18,10 @@ # @return [Enumerable] a list of facet prefixes (default: A-Z) to allow users to 'jump' to particular values # @!attribute date # @return [Symbol|Hash] the i18n localization option for a date or time value; used as the second parameter for the I18n.l method # @!attribute link_to_facet # @return [Boolean] - # @!attribute link_to_search - # @deprecated use link_to_facet instead. - # @return [Boolean] # @!attribute helper_method # @return [Symbol] the name of a helper method used to display the facet's value to the user; it receives the facet value. # @!attribute url_method # @return [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. # @!attribute collapsing @@ -65,32 +63,40 @@ # @!attribute item_component # @return [Blacklight::FacetItemComponent] # @!attribute partial # @return [String] Rails view partial used to render the facet field - extend Deprecation - + # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity 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 - - if link_to_search - Deprecation.warn(Blacklight::Configuration::FacetField, '`link_to_search:` is deprecated, use `link_to_facet:` instead') - self.link_to_facet = link_to_search if link_to_facet.nil? - end - + 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 + # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + + private + + def normalize_pivot_config! + self.item_presenter ||= Blacklight::FacetItemPivotPresenter + self.item_component ||= Blacklight::FacetItemPivotComponent + self.filter_class ||= Blacklight::SearchState::PivotFilterField + self.filter_query_builder ||= Blacklight::SearchState::PivotFilterField::QueryBuilder end end end