Browse Source

Fix filter links

pull/2038/head
Kat 3 years ago
parent
commit
fd6083342c
  1. 4
      app/helpers/filters_helper.rb
  2. 4
      app/views/schemes/_scheme_filters.html.erb
  3. 4
      app/views/users/_user_filters.html.erb
  4. 2
      spec/features/schemes_spec.rb
  5. 4
      spec/features/user_spec.rb

4
app/helpers/filters_helper.rb

@ -139,6 +139,10 @@ module FiltersHelper
request.path.include?("/lettings-logs")
end
def specific_organisation_path?
request.path.include?("/organisations")
end
def applied_filters_count(filter_type)
filters_count(applied_filters(filter_type))
end

4
app/views/schemes/_scheme_filters.html.erb

@ -5,13 +5,13 @@
</div>
<div class="app-filter__content">
<%= form_with url: schemes_path, html: { method: :get } do |f| %>
<%= form_with url: specific_organisation_path? ? schemes_organisation_path(@organisation) : schemes_path, html: { method: :get } do |f| %>
<div class="govuk-grid-row" style="white-space: nowrap">
<p class="govuk-grid-column-one-half">
<%= filters_applied_text(@filter_type) %>
</p>
<p class="govuk-!-text-align-right govuk-grid-column-one-half">
<%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %>
<%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>
</p>
</div>

4
app/views/users/_user_filters.html.erb

@ -5,13 +5,13 @@
</div>
<div class="app-filter__content">
<%= form_with url: users_path, html: { method: :get } do |f| %>
<%= form_with url: specific_organisation_path? ? users_organisation_path(@organisation) : users_path, html: { method: :get } do |f| %>
<div class="govuk-grid-row" style="white-space: nowrap">
<p class="govuk-grid-column-one-half">
<%= filters_applied_text(@filter_type) %>
</p>
<p class="govuk-!-text-align-right govuk-grid-column-one-half">
<%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %>
<%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>
</p>
</div>

2
spec/features/schemes_spec.rb

@ -81,7 +81,7 @@ RSpec.describe "Schemes scheme Features" do
it "displays the filters component with a correct count and clear button" do
expect(page).to have_content("2 filters applied")
expect(page).to have_link("Clear", href: "/clear-filters?filter_type=schemes")
expect(page).to have_link("Clear", href: /clear-filters\?filter_type=schemes/)
end
context "when clearing the filters" do

4
spec/features/user_spec.rb

@ -252,7 +252,7 @@ RSpec.describe "User Features" do
context "when no filters are selected" do
it "displays the filters component with no clear button" do
expect(page).to have_content("No filters applied")
expect(page).not_to have_link("Clear", href: "/clear-filters?filter_type=users")
expect(page).not_to have_link("Clear", href: /clear-filters\?filter_type=users/)
end
end
@ -265,7 +265,7 @@ RSpec.describe "User Features" do
it "displays the filters component with a correct count and clear button" do
expect(page).to have_content("2 filters applied")
expect(page).to have_link("Clear", href: "/clear-filters?filter_type=users")
expect(page).to have_link("Clear", href: /clear-filters\?filter_type=users/)
end
context "when clearing the filters" do

Loading…
Cancel
Save