Skip to content

Commit

Permalink
Merge pull request #3468 from alphagov/filter-panel-facets
Browse files Browse the repository at this point in the history
All content finder: Show filters based on actual facets
  • Loading branch information
csutter authored Sep 23, 2024
2 parents 4d005fd + c47f591 commit 33c6b93
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= render "components/filter_section", {
heading_text: date_facet.name,
visually_hidden_heading_prefix: "Filter by",
id: "facet_date_#{date_facet.key}"
} do %>
TODO: Date facet
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%# TODO: Hidden clearable facet %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= render "components/filter_section", {
heading_text: option_select_facet.name,
visually_hidden_heading_prefix: "Filter by",
id: "facet_option_select_#{option_select_facet.key}"
} do %>
TODO: Option select facet
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%= render "components/filter_section", {
heading_text: taxon_facet.name,
visually_hidden_heading_prefix: "Filter by",
id: "facet_taxon_#{taxon_facet.key}"
} do %>
TODO: Taxon facet
<% end %>
31 changes: 6 additions & 25 deletions app/views/finders/show_all_content_finder.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,12 @@
button_text: "Filter and sort",
result_text: result_set_presenter.displayed_total,
} do %>
<%= render "components/filter_section", {
open: true,
heading_text: "Filter 1"
} do %>
<span>filter section content</span>
<% end %>
<%= render "components/filter_section", {
status_text: "1 Selected",
heading_text: "Filter 2"
} do %>
<span>filter section content</span>
<% end %>
<%= render "components/filter_section", {
heading_text: "Filter 3"
} do %>
<span>filter section content</span>
<% end %>
<%= render "components/filter_section", {
status_text: "1 Selected",
heading_text: "Filter 4"
} do %>
<span>filter section content</span>
<% facets.each_with_index_and_count do |facet, index, count| %>
<%=
render partial: "finders/all_content_finder_facets/#{facet.to_partial_path}",
object: facet,
locals: { index:, count: }
%>
<% end %>
<% end %>
Expand Down
5 changes: 5 additions & 0 deletions features/all_content_finder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Feature: All content finder ("site search")
Then I can see results for my search
And I can see how many results there are
Scenario: Filtering results
When I search all content for "how to walk silly"
And I open the filter panel
Then I can see a filter section for every visible facet on the all content finder
Scenario: Spelling suggestion
When I search all content for "drving"
Then I see a "driving" spelling suggestion
16 changes: 16 additions & 0 deletions features/step_definitions/site_search_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,19 @@
Then("I can see how many results there are") do
expect(page).to have_selector("h2", text: "2 results")
end

When("I open the filter panel") do
click_on "Filter and sort"
end

Then("I can see a filter section for every visible facet on the all content finder") do
# These are visible filter types and should have a section
expect(page).to have_selector("h2", text: "Filter by Topic")
expect(page).to have_selector("h2", text: "Filter by Type")
expect(page).to have_selector("h2", text: "Filter by Updated")

# These are hidden clearable filters and should not have a section
expect(page).not_to have_selector("h2", text: "Filter by Organisation")
expect(page).not_to have_selector("h2", text: "Filter by World location")
expect(page).not_to have_selector("h2", text: "Filter by Topical event")
end

0 comments on commit 33c6b93

Please sign in to comment.