diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 1e350829a..868b4936d 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -3,7 +3,11 @@ class SessionsController < ApplicationController
session[session_name_for(params[:filter_type])] = "{}"
path_params = params[:path_params].presence || {}
- redirect_to send("#{params[:filter_type]}_path", scheme_id: path_params[:scheme_id], search: path_params[:search])
+ if path_params[:organisation_id].present?
+ redirect_to send("#{params[:filter_type]}_organisation_path", id: path_params[:organisation_id], scheme_id: path_params[:scheme_id], search: path_params[:search])
+ else
+ redirect_to send("#{params[:filter_type]}_path", scheme_id: path_params[:scheme_id], search: path_params[:search])
+ end
end
private
diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb
index 91038dbc9..2df2d21b1 100644
--- a/app/helpers/filters_helper.rb
+++ b/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
diff --git a/app/views/logs/_log_filters.html.erb b/app/views/logs/_log_filters.html.erb
index 96e9eeeff..72f73e47c 100644
--- a/app/views/logs/_log_filters.html.erb
+++ b/app/views/logs/_log_filters.html.erb
@@ -12,7 +12,7 @@
<%= filters_applied_text(@filter_type) %>
- <%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %>
+ <%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>
<% if bulk_upload_options(@bulk_upload).present? %>
diff --git a/app/views/schemes/_scheme_filters.html.erb b/app/views/schemes/_scheme_filters.html.erb
index 6e66e38ba..af9ed093f 100644
--- a/app/views/schemes/_scheme_filters.html.erb
+++ b/app/views/schemes/_scheme_filters.html.erb
@@ -5,13 +5,13 @@
- <%= 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| %>
<%= filters_applied_text(@filter_type) %>
- <%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %>
+ <%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>
diff --git a/app/views/users/_user_filters.html.erb b/app/views/users/_user_filters.html.erb
index 9547cbc86..d047beac7 100644
--- a/app/views/users/_user_filters.html.erb
+++ b/app/views/users/_user_filters.html.erb
@@ -5,13 +5,13 @@
- <%= 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| %>
<%= filters_applied_text(@filter_type) %>
- <%= reset_filters_link(@filter_type, { search: request.params["search"] }.compact) %>
+ <%= reset_filters_link(@filter_type, { search: request.params["search"], organisation_id: @organisation&.id }.compact) %>
diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb
index d7a9609f8..5d57b31e6 100644
--- a/spec/features/schemes_spec.rb
+++ b/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
diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb
index ce0e1317f..2da53970b 100644
--- a/spec/features/user_spec.rb
+++ b/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
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index 340f1facf..4bd6e0eb6 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -1440,6 +1440,16 @@ RSpec.describe OrganisationsController, type: :request do
}.to enqueue_job(EmailCsvJob).with(user, nil, {}, false, organisation, codes_only_export_type)
end
end
+
+ context "when filters are applied" do
+ before do
+ get lettings_logs_organisation_path(organisation, status: %w[completed])
+ end
+
+ it "has clear filters link" do
+ expect(page).to have_link("Clear", href: clear_filters_path(filter_type: "lettings_logs", path_params: { organisation_id: organisation.id }))
+ end
+ end
end
context "when they view the sales logs tab" do