Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting essential blacklight range limit functionality #3098

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding documentation.
  • Loading branch information
cgalarza committed Oct 12, 2023
commit 223ec9d95c5ef4c9bce23a4d4be21de89196c85e
6 changes: 6 additions & 0 deletions app/presenters/blacklight/facet_field_range_presenter.rb
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ class FacetFieldRangePresenter < Blacklight::FacetFieldPresenter
delegate :response, to: :display_facet
delegate :blacklight_config, to: :search_state

# Paginator will return the selected item or if no facet is selected, the [Missing] facet.
def paginator
return unless display_facet

@@ -21,12 +22,17 @@ def selected_range
values&.first
end

# Wraps selected range in Blacklight::Solr::Response::Facets::FacetItem object.
#
# @return [Blacklight::Solr::Response::Facets::FacetItem] if range is selected
# @return [NilClass] if no range is selected
def selected_item
return unless selected_range

Blacklight::Solr::Response::Facets::FacetItem.new(value: selected_range, hits: response.total)
end

# Returns true if [Missing] facet is selected.
def missing_selected?
selected_range == Blacklight::SearchState::FilterField::MISSING
end