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 19643eb commit f82ebb1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
@include govuk-visually-hidden;
}

.govuk-link {
&--reset-fields {
@include govuk-font($size: 19, $line-height: 2em);
display: inline-block;
@include govuk-responsive-margin(2, "left");
}
}

@mixin chevron($dir) {
&:before {
border-style: solid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@
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 govuk-link--reset-fields" %>


<% 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 @@ -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 f82ebb1

Please sign in to comment.