From cbdf208de1b55cb4463c44a31eb517338c0f7a28 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Wed, 10 Apr 2024 12:43:34 -0600 Subject: [PATCH 1/3] Handle template sorting when "No Org" is checked Commit d1274442c8324167cc4ab23f0d2fbd3cff797820 implemented the template sorting as described here: https://github.com/portagenetwork/roadmap/issues/685 However, the fix did not address the template sorting when "No research organization associated with this plan or my research organization is not listed" is checked. This commit does. --- app/controllers/template_options_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/template_options_controller.rb b/app/controllers/template_options_controller.rb index c196e74864..0b087e13f5 100644 --- a/app/controllers/template_options_controller.rb +++ b/app/controllers/template_options_controller.rb @@ -51,7 +51,9 @@ def index else # if'No Primary Research Institution' checkbox is checked, # only show publicly available template without customization - @templates = Template.published.publicly_visible.where(org_id: funder.id, customization_of: nil) + @templates << Template.default if Template.default.present? + @templates << Template.published.publicly_visible.where(org_id: funder.id, customization_of: nil, is_default: false).sort_by(&:title).to_a + @templates = @templates.flatten.uniq end # DMP Assistant: We do not want to include not customized templates from default funder # Include customizable funder templates From 35eb4bd5e9059f57e47bce9039025f66ba7c5545 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Wed, 10 Apr 2024 13:09:25 -0600 Subject: [PATCH 2/3] `rubocop -A` and remove redundant .uniq call `@templates = @templates.uniq` is executed in line 69. Thus, `@templates = @templates.flatten.uniq` would be redundant in line 57. --- app/controllers/template_options_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/template_options_controller.rb b/app/controllers/template_options_controller.rb index 0b087e13f5..c6cb567d1a 100644 --- a/app/controllers/template_options_controller.rb +++ b/app/controllers/template_options_controller.rb @@ -47,14 +47,14 @@ def index # Retrieve the Org's templates @templates << Template.published.organisationally_visible.where(org_id: org.id, customization_of: nil).sort_by(&:title).to_a - @templates = @templates.flatten.uniq else # if'No Primary Research Institution' checkbox is checked, # only show publicly available template without customization @templates << Template.default if Template.default.present? - @templates << Template.published.publicly_visible.where(org_id: funder.id, customization_of: nil, is_default: false).sort_by(&:title).to_a - @templates = @templates.flatten.uniq + @templates << Template.published.publicly_visible.where(org_id: funder.id, customization_of: nil, + is_default: false).sort_by(&:title).to_a end + @templates = @templates.flatten # DMP Assistant: We do not want to include not customized templates from default funder # Include customizable funder templates # @templates << funder_templates = Template.latest_customizable From a01695f00d0a01a87b47df0bf092fbea0cf5fe07 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Wed, 10 Apr 2024 13:30:43 -0600 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55feb6cc3a..ba659da412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - Edit Gemfile config for 'rollbar' to enable app tracking on rollbar.com [#687](https://github.com/portagenetwork/roadmap/pull/687) - - Fxed ordering of templates within the "Create a new plan" template dropdown [#706](https://github.com/portagenetwork/roadmap/pull/706) + - Fixed ordering of templates within the "Create a new plan" template dropdown [#706](https://github.com/portagenetwork/roadmap/pull/706) and [#718](https://github.com/portagenetwork/roadmap/pull/718) ## [4.0.2+portage-4.0.0] - 2024-02-01