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.** 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 ) 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') %>