Class: BlacklightRangeLimit::RangeFacetComponent
- Inherits:
-
Blacklight::Component
- Object
- Blacklight::Component
- BlacklightRangeLimit::RangeFacetComponent
- Defined in:
- app/components/blacklight_range_limit/range_facet_component.rb
Instance Method Summary collapse
-
#initialize(facet_field:, layout: nil, classes: BlacklightRangeLimit.classes) ⇒ RangeFacetComponent
constructor
A new instance of RangeFacetComponent.
-
#load_distribution_link ⇒ Object
URL that will return the distribution list of range seguments.
- #range_config ⇒ Object
- #range_limit_url(options = {}) ⇒ Object
-
#render? ⇒ Boolean
Don’t render if we have no values at all – most commonly on a zero results page.
- #uses_distribution? ⇒ Boolean
Constructor Details
#initialize(facet_field:, layout: nil, classes: BlacklightRangeLimit.classes) ⇒ RangeFacetComponent
Returns a new instance of RangeFacetComponent.
7 8 9 10 11 |
# File 'app/components/blacklight_range_limit/range_facet_component.rb', line 7 def initialize(facet_field:, layout: nil, classes: BlacklightRangeLimit.classes) @facet_field = facet_field @layout = layout == false ? Blacklight::FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent @classes = classes end |
Instance Method Details
#load_distribution_link ⇒ Object
URL that will return the distribution list of range seguments
36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/blacklight_range_limit/range_facet_component.rb', line 36 def load_distribution_link # For open-ended ranges, the selected range should take priority for the boundary # over actual response min/max. Matters for multi-valued fields. min = @facet_field.selected_range_facet_item&.value&.begin || @facet_field.min max = @facet_field.selected_range_facet_item&.value&.end || @facet_field.max return nil unless (min && max) range_limit_url(range_start: min, range_end: max) end |
#range_config ⇒ Object
22 23 24 |
# File 'app/components/blacklight_range_limit/range_facet_component.rb', line 22 def range_config @facet_field.range_config end |
#range_limit_url(options = {}) ⇒ Object
26 27 28 29 |
# File 'app/components/blacklight_range_limit/range_facet_component.rb', line 26 def range_limit_url( = {}) helpers.main_app.url_for(@facet_field.search_state.to_h.merge(range_field: @facet_field.key, action: 'range_limit').merge()) end |
#render? ⇒ Boolean
Don’t render if we have no values at all – most commonly on a zero results page. Normally we’ll have at least a min and a max (of values in result set, solr returns), OR a count of objects missing a value – if we don’t have ANY of that, there is literally nothing we can display, and we’re probably in a zero results situation.
17 18 19 20 |
# File 'app/components/blacklight_range_limit/range_facet_component.rb', line 17 def render? (@facet_field.min.present? && @facet_field.max.present?) || @facet_field.missing_facet_item.present? end |
#uses_distribution? ⇒ Boolean
31 32 33 |
# File 'app/components/blacklight_range_limit/range_facet_component.rb', line 31 def uses_distribution? range_config[:chart_js] || range_config[:textual_facets] end |