Browse Source

Clear filter for a specific organisation

pull/2038/head
Kat 3 years ago
parent
commit
c6bf803031
  1. 6
      app/controllers/sessions_controller.rb
  2. 2
      app/views/logs/_log_filters.html.erb
  3. 10
      spec/requests/organisations_controller_spec.rb

6
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

2
app/views/logs/_log_filters.html.erb

@ -12,7 +12,7 @@
<%= 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>
<% if bulk_upload_options(@bulk_upload).present? %>

10
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

Loading…
Cancel
Save