From fbe41885f8f9aa43d809b5c953f3ae095ab026d3 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 20 Nov 2023 11:45:29 +0000 Subject: [PATCH] CLDC-2739 Clear filter for a specific organisation (#2038) * Clear filter for a specific organisation * Fix filter links --- app/controllers/sessions_controller.rb | 6 +++++- app/helpers/filters_helper.rb | 4 ++++ app/views/logs/_log_filters.html.erb | 2 +- app/views/schemes/_scheme_filters.html.erb | 4 ++-- app/views/users/_user_filters.html.erb | 4 ++-- spec/features/schemes_spec.rb | 2 +- spec/features/user_spec.rb | 4 ++-- spec/requests/organisations_controller_spec.rb | 10 ++++++++++ 8 files changed, 27 insertions(+), 9 deletions(-) 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 @@<%= 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) %>
<%= 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) %>