Skip to content

Commit

Permalink
Add a link to reset the fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pezholio committed Nov 7, 2024
1 parent 02071dc commit a0bc929
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@
],
} %>

<%= render "govuk_publishing_components/components/button", {
text: "View results",
margin_bottom: 4,
} %>
<div class="govuk-button-group">
<%= render "govuk_publishing_components/components/button", {
text: "View results",
margin_bottom: 4,
} %>

<%= link_to "Reset all fields",
helpers.content_block_manager.content_block_manager_root_path(reset_fields: true),
class: "govuk-link" %>
</div>

<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def index
@filters = params_filters
@content_block_documents = ContentBlockManager::ContentBlock::Document::DocumentFilter.new(@filters).documents
render :index
elsif session_filters.any?
elsif params[:reset_fields].blank? && session_filters.any?
redirect_to content_block_manager.content_block_manager_root_path(session_filters)
else
redirect_to content_block_manager.content_block_manager_root_path(default_filters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent
ContentBlockManager::ContentBlock::Document::Index::FilterOptionsComponent.any_instance.stubs(:helpers).returns(helper_mock)
helper_mock.stubs(:content_block_manager).returns(helper_mock)
helper_mock.stubs(:content_block_manager_content_block_documents_path).returns("path")
helper_mock.stubs(:content_block_manager_root_path).returns("path")

helper_mock.stubs(:taggable_organisations_container).returns(
[["Department of Placeholder", 1], ["Ministry of Example", 2]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,21 @@ class ContentBlockManager::ContentBlock::DocumentsTest < ActionDispatch::Integra
end

describe "when there are session filters" do
it "adds them to the params by default the next time user visits" do
before do
visit content_block_manager.content_block_manager_content_block_documents_path({ keyword: "something" })
end

it "adds them to the params by default the next time user visits" do
visit content_block_manager.content_block_manager_content_block_documents_path

assert_current_path content_block_manager.content_block_manager_root_path({ keyword: "something" })
end

it "resets the filters when reset_fields is set" do
visit content_block_manager.content_block_manager_content_block_documents_path({ reset_fields: true })

assert_current_path content_block_manager.content_block_manager_root_path({ lead_organisation: @organisation.id.to_s })
end
end
end

Expand Down

0 comments on commit a0bc929

Please sign in to comment.