From 1c804ca15ae00e581271d12f247210f03447a4fd Mon Sep 17 00:00:00 2001 From: Aaron Contreras Date: Mon, 17 Jul 2023 14:31:30 -0500 Subject: [PATCH] Keep project filters section hidden when using predefined filters from sidebar As per requirements and the highlight presented [here](https://community.openproject.org/projects/openproject/work_packages/47850/activity#activity-61), ensuring that the filters section remains hidden when using the filters from the sidebar. Added some specs to demonstrate the undesired behavior and the subsequent code that fulfills the expectations. --- app/helpers/projects_helper.rb | 6 +++--- app/views/projects/filters/_form.html.erb | 2 +- app/views/projects/index.html.erb | 2 +- spec/features/projects/projects_index_spec.rb | 12 ++++++++---- spec/support/pages/projects/index.rb | 13 +++++++++++++ 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index cd162abe597f..754cb74ad0bb 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -29,8 +29,8 @@ module ProjectsHelper include WorkPackagesFilterHelper - def filter_set? - params[:filters].present? + def show_filters_section? + params[:filters].present? && !params.key?(:hide_filters_section) end def allowed_filters(query) @@ -127,7 +127,7 @@ def global_menu_archived_projects_item def projects_path_with_filters(filters) return projects_path if filters.empty? - projects_path(filters: filters.to_json) + projects_path(filters: filters.to_json, hide_filters_section: true) end def global_menu_item_css_class(path) diff --git a/app/views/projects/filters/_form.html.erb b/app/views/projects/filters/_form.html.erb index 52ac0f001ef5..906ee00b0bbd 100644 --- a/app/views/projects/filters/_form.html.erb +++ b/app/views/projects/filters/_form.html.erb @@ -1,6 +1,6 @@ <%= form_tag({}, method: :get, - class: "project-filters #{filter_set? ? '-expanded' : ''}", + class: "project-filters #{show_filters_section? ? '-expanded' : ''}", data: { 'project-target': 'filterForm', action: 'submit->project#sendForm:prevent' diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index ae67536976e0..69ca8ccf5bfd 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -44,7 +44,7 @@ See COPYRIGHT and LICENSE files for more details. <% end %>