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

Also handle 'inclusive' facets in deprecated #render_filter_element m… #2734

Merged
merged 1 commit into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions app/helpers/blacklight/render_constraints_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,13 @@ def render_filter_element(facet, values, search_state)
safe_join(Array(values).map do |val|
next if val.blank? # skip empty string

presenter = facet_item_presenter(facet_config, val, facet)

Deprecation.silence(Blacklight::RenderConstraintsHelperBehavior) do
presenter = if val.is_a? Array
inclusive_facet_item_presenter(facet_config, val, facet)
else
facet_item_presenter(facet_config, val, facet)
end

render_constraint_element(presenter.field_label,
presenter.label,
remove: presenter.remove_href(search_state),
Expand All @@ -118,6 +122,10 @@ def render_filter_element(facet, values, search_state)
end, "\n")
end

def inclusive_facet_item_presenter(facet_config, facet_item, facet_field)
Blacklight::InclusiveFacetItemPresenter.new(facet_item, facet_config, self, facet_field)
end

# Render a label/value constraint on the screen. Can be called
# by plugins and such to get application-defined rendering.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz"
end
end

context 'with multivalued facets' do
subject { helper.render_filter_element('type', [%w[journal book]], path) }

it "handles such values gracefully" do
expect(subject).to have_link "Remove constraint Item Type: journal OR book", href: "/catalog?q=biz"
end
end
end

describe "#render_constraints_filters" do
Expand Down