Sha256: cb38f0575601937c4bd503b117acdcfb04954f9dceceee8a85cd530d645ac769
Contents?: true
Size: 1.4 KB
Versions: 1
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module BlacklightRangeLimit # Override the default item presenter to provide custom labels for # range data. class FacetItemPresenter < Blacklight::FacetItemPresenter def label label_for_range || super end # Very hacky way to keep params used for ajax query for segments out # of our generated facet links. Sorry this seems to be the best way! # # https://github.com/projectblacklight/blacklight_range_limit/issues/296 def href(path_options = {}) override_to_nil = BlacklightRangeLimit::ControllerOverride::RANGE_LIMIT_FIELDS.collect { |f| [f, nil] }.to_h super(path_options.merge(override_to_nil)) end private def label_for_range return unless value.is_a? Range view_context.t( range_limit_label_key, begin: format_range_display_value(value.begin), begin_value: value.begin, end: format_range_display_value(value.end), end_value: value.end ) end def range_limit_label_key if value.begin == value.end 'blacklight.range_limit.single_html' else 'blacklight.range_limit.range_html' end end ## # A method that is meant to be overridden downstream to format how a range # label might be displayed to a user. By default it just returns the value. def format_range_display_value(value) value end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blacklight_range_limit-9.0.0.beta2 | app/presenters/blacklight_range_limit/facet_item_presenter.rb |