From c0a0dbf02ab6af91750f671bbc5a803ff367bbd5 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Wed, 15 Jan 2025 16:07:31 -0700 Subject: [PATCH 1/3] Retain :f filter on /org_admin/templates/ Search This commit retains the selected 'Published', 'Unpublished', or 'Not customized' filter when using the search on the paths /org_admin/templates, org_admin/templates/organisational, and org_admin/templates/customisable. Previously, the search would ignore the filter and return all templates. --- app/views/shared/_search.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/shared/_search.html.erb b/app/views/shared/_search.html.erb index f8e5c9f52e..a578103420 100644 --- a/app/views/shared/_search.html.erb +++ b/app/views/shared/_search.html.erb @@ -17,6 +17,8 @@ <%= label_tag(:filter_admin, _('Only Show Admins'), class: 'form-check-label') %> <% end %> + <%# :f corresponds to the "Published" vs "Unpublished" etc. filters defined on the org_admin/templates pages %> + <%= hidden_field_tag :f, params[:f] if params[:f].present? %> <%= submit_tag(_('Search'), class: 'btn btn-secondary ms-2') %> From d0fdcb766e035e7ccb16a53200001a2aca19d410 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Wed, 15 Jan 2025 16:33:46 -0700 Subject: [PATCH 2/3] Keep :f filter on /org_admin/templates/ "View All" This commit retains the selected 'Published', 'Unpublished', or 'Not customized' filter when using the "Select All" pagination option on the paths /org_admin/templates, org_admin/templates/organisational, and org_admin/templates/customisable. Previously, clicking "Select All" would ignore the filter and return all templates. --- app/controllers/concerns/paginable.rb | 2 ++ app/controllers/paginable/templates_controller.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/paginable.rb b/app/controllers/concerns/paginable.rb index 250f5038f0..90319cd486 100644 --- a/app/controllers/concerns/paginable.rb +++ b/app/controllers/concerns/paginable.rb @@ -99,6 +99,8 @@ def paginable_base_url(page = 1) action: @args[:action], page: page ) + # Retain :f if paginable/templates controller is using it to filter templates + url_params[:f] = @args[:f] if @args[:f].present? && @args[:controller] == 'paginable/templates' url_for(url_params) end diff --git a/app/controllers/paginable/templates_controller.rb b/app/controllers/paginable/templates_controller.rb index 8e691519ca..4904c2b801 100644 --- a/app/controllers/paginable/templates_controller.rb +++ b/app/controllers/paginable/templates_controller.rb @@ -25,7 +25,7 @@ def index paginable_renderise( partial: 'index', scope: templates, - query_params: { sort_field: 'templates.title', sort_direction: :asc }, + query_params: { sort_field: 'templates.title', sort_direction: :asc, f: params[:f] }, locals: { action: 'index' }, format: :json ) @@ -50,7 +50,7 @@ def organisational paginable_renderise( partial: 'organisational', scope: templates, - query_params: { sort_field: 'templates.title', sort_direction: :asc }, + query_params: { sort_field: 'templates.title', sort_direction: :asc, f: params[:f] }, locals: { action: 'organisational' }, format: :json ) @@ -78,7 +78,7 @@ def customisable paginable_renderise( partial: 'customisable', scope: templates.joins(:org).includes(:org), - query_params: { sort_field: 'templates.title', sort_direction: :asc }, + query_params: { sort_field: 'templates.title', sort_direction: :asc, f: params[:f] }, locals: { action: 'customisable', customizations: customizations }, format: :json ) From d4884fbc4931bffc3c7b68fd090f39e5aaaa2dd6 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Thu, 16 Jan 2025 10:00:54 -0700 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c1959f48f..c9f54bca2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Refactor Plan.deep_copy(plan) [#3469](https://github.com/DMPRoadmap/roadmap/pull/3469) - Fixed a bug in the deep copy of plans where the old identifier was being copied into the new plan. We now copy the generated id of the new plan to the identifier field. - Fixed bar chart click function in the Usage dashboard (GitHub issue #3443) +- Retain "Published" etc. Filter Setting When Applying Search or "View All" on `/org_admin/templates/` Pages [#3475](https://github.com/DMPRoadmap/roadmap/pull/3475) **Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.**