Skip to content

Conversation

@johnpinto1
Copy link
Contributor

@johnpinto1 johnpinto1 commented Oct 27, 2025

Redesigned plan-creation page to enforce template access rules and simplify UI #3534
Co-authored-by: don-stuckey dstuckey@ed.ac.uk

This feature was contributed to DMPonline by @don-stuckey.

Changes:

  • Complete re-write of 'Create a new plan' view app/views/plans/new.html.erb.
  • The Plans controller app/controllers/plans_controller.rb has be greatly simplified to get three types og templates for selection in view: The global templates, the user's org templates and the funder templates available.
  • The seeds.rb file has been updated to include templates for the three groups.
  • The tests has been updated.

New Create a new plan page
Selection_142

Screenshot when running RSpec test in spec/features/plans_spec.rb
screenshot1

@johnpinto1 johnpinto1 changed the title Feature that re-designs Plan creation page to enforce template access Redesigned plan-creation page to enforce template access rules and simplify UI Oct 27, 2025
@johnpinto1 johnpinto1 force-pushed the issue/new-3534 branch 2 times, most recently from 908c3e8 to 000c04a Compare October 27, 2025 16:16
…mplify UI [#3534](#3534)

Co-authored-by: don-stuckey dstuckey@ed.ac.uk

This feature was contributed to DMPonline by @don-stuckey.

Changes:
- Complete re-write of 'Create a new plan' view
  app/views/plans/new.html.erb.
- The Plans controller app/controllers/plans_controller.rb has be
  greatly simplified to get three types og templates for selection in
view: The global templates, the user's org templates and the funder
templates available.
- The seeds.rb file has been updated to include templates for the three
  groups.
- The tests has been updated.
Comment on lines +37 to +51
# get funder templates
funder_templates = Template.published
.joins(:org)
.merge(Org.funder)
.distinct

# get global templates
global_templates = Template.published
.where(is_default: true)
.distinct

# get templates of user's org
user_org_templates = Template.published
.where(org: current_user.org)
.distinct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm comparing this simplified logic with what we were previously using (https://github.com/DMPRoadmap/roadmap/blob/main/app/controllers/template_options_controller.rb).

One thing I am concerned about with this new logic is the same template being listed in two, or all three sections. For example, what if Org.funder has a default template (which is the case with DMP Assistant). Then that same template is listed in both funder_templates and global_templates. And if user.org == Org.funder (again the case with DMP Assistant), then funder_templates and user_org_templates will have identical lists.

TemplateOptionsController also performed special handling for template customisations. Specifically, if an org had a customisation of the most recent version of a funder_template, then only that customisation would appear as an template option. With this logic, it looks like the most recent customisation will appear in user_org_templates, but the non-customised version of it will also be listed as an option in funder_templates.

</legend>
<div class="row form-row">
<div class="col-12">
<% @templates_grouped.each do |group_label, group_templates| %>
Copy link
Contributor

@aaronskiba aaronskiba Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the label grouping. Maybe we should also be ordering the templates by title?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants