-
Notifications
You must be signed in to change notification settings - Fork 118
Redesigned plan-creation page to enforce template access rules and simplify UI #3580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
johnpinto1
wants to merge
5
commits into
main
Choose a base branch
from
issue/new-3534
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b48244f
Redesigned plan-creation page to enforce template access rules and si…
4ce0dea
Issue #3534 - Add the template filtering code to only display funder …
martaribeiro 0046b36
Issue #3534 - Add fix for user own org template query list.
gjacob24 3aef6d2
Issue #3534 - Added server-side validation to ensure that an user can
johnpinto1 191c8f6
Issue #3534 - Added a new RSpec test file plans_controller_templates_…
johnpinto1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,55 @@ | ||
| @use '../variables/colours' as *; | ||
|
|
||
| .form-control { | ||
| border: 0px; | ||
| } | ||
|
|
||
| .form-control input, .form-control textarea, .form-control select{ | ||
| border: 2px solid $color-border-light; | ||
|
|
||
| .form-control input, | ||
| .form-control textarea, | ||
| .form-control select { | ||
| border: 2px solid $color-border-light; | ||
| } | ||
|
|
||
| .form-check { | ||
| padding-left: 0rem; | ||
| padding-left: 0rem; | ||
| } | ||
|
|
||
| .form-inline{ | ||
| margin-bottom: 5px; | ||
| .form-inline { | ||
| margin-bottom: 5px; | ||
| } | ||
|
|
||
| .form-check-label { | ||
| padding-left: 5px; | ||
| padding-left: 5px; | ||
| } | ||
|
|
||
| // Added for new plan create page app/views/plans/new.html.erb | ||
| .roadmap-form { | ||
| margin-bottom: 1rem; | ||
|
|
||
| legend { | ||
| padding-inline: 2px; | ||
| float: none; | ||
| width: auto; | ||
| padding: 0.5rem; | ||
| font-size: 1rem; | ||
| background-color: $color-primary-background; | ||
| color: $color-primary-text; | ||
| } | ||
|
|
||
| fieldset { | ||
| border: 2px solid #555555; | ||
| padding: 1rem; | ||
| margin-bottom: 1rem; | ||
| } | ||
|
|
||
| .form-row { | ||
| margin-bottom: 1rem; | ||
| } | ||
|
|
||
| .form-row:last-child { | ||
| margin-bottom: 0; | ||
| } | ||
|
|
||
| .form-check .form-check-input { | ||
| float: left; | ||
| margin-left: 0.5rem; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,125 +1,90 @@ | ||
| <% title _('Create a new plan') %> | ||
| <% required_project_title_tooltip = _('This field is required.') %> | ||
| <% project_title_tooltip = _('If applying for funding, state the project title exactly as in the proposal.') %> | ||
| <% required_research_org_tooltip = _('You must select a research organisation from the list or click the checkbox.') %> | ||
| <% research_org_tooltip = _('Please select a valid research organisation from the list.') %> | ||
| <% required_primary_funding_tooltip = _('You must select a funder from the list or click the checkbox.') %> | ||
| <% primary_funding_tooltip = _('Please select a valid funding organisation from the list.') %> | ||
|
|
||
| <div class="row"> | ||
| <div class="col-md-12"> | ||
| <h1><%= _('Create a new plan') %></h1> | ||
|
|
||
| <p class="start-indent"> | ||
| <%= _("Before you get started, we need some information about your research project to set you up with the best DMP template for your needs.") %> | ||
| </p> | ||
| <form action="<%= plans_path %>" method="post" class="roadmap-form"> | ||
| <div class="row form-row"> | ||
| <div class="col-12"> | ||
| <h1><%= _('Create a new plan') %></h1> | ||
| <p> | ||
| <%= _("Before you get started, we need some information about your research project to set you up with the best DMP template for your needs.") %> | ||
| </p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="row"> | ||
| <div class="col-md-12"> | ||
| <%= form_for Plan.new, url: plans_path do |f| %> | ||
| <!-- Plan name section --> | ||
| <h2 id="project-title"><span class="red" title="<%= required_project_title_tooltip %>">*<em class="sr-only"><%= required_project_title_tooltip %></em> </span><%= _('What research project are you planning?') %></h2> | ||
| <div class="row"> | ||
| <div class="form-control mb-3 col-md-8"> | ||
| <%= f.text_field(:title, class: 'form-control', 'aria-labelledby': 'project-title', 'aria-required': 'true', 'aria-label': 'project-title', | ||
| 'data-toggle': 'tooltip', | ||
| 'data-placement': 'bottom', | ||
| spellcheck: true, | ||
| title: project_title_tooltip ) %> | ||
| </div> | ||
| <div class="form-control mb-3 col-md-6"> | ||
| <div class="checkbox"> | ||
| <%= label_tag(:is_test) do %> | ||
| <%= check_box_tag(:is_test, "1", false) %> | ||
| <%= _('mock project for testing, practice, or educational purposes') %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <fieldset> | ||
| <div class="row form-row"> | ||
| <div class="col-12"> | ||
| <!-- Rails form authenticity token --> | ||
| <%= hidden_field_tag :authenticity_token, form_authenticity_token %> | ||
| <label for="plan_title" id="project-title" class="form-label"> | ||
| <%= _('Enter project title') %> | ||
| </label> | ||
| <input type="text" | ||
| id="plan_title" | ||
| name="plan[title]" | ||
| class="form-control" | ||
| required | ||
| aria-labelledby="project-title" | ||
| aria-required="true" | ||
| aria-label="project-title" | ||
| data-toggle="tooltip" | ||
| data-placement="bottom" | ||
| spellcheck="true"> | ||
| </div> | ||
|
|
||
| <!-- Organisation selection --> | ||
| <h2 id="research-org"> | ||
| <span class="red" title="<%= required_research_org_tooltip %>">*<em class="sr-only"><%= required_research_org_tooltip %></em> </span> | ||
| <%= _('Select the primary research organisation') %> | ||
| </h2> | ||
| <div id="research-org-controls" class="row"> | ||
| <div class="form-control mb-3 col-md-6"> | ||
| <em class="sr-only"><%= research_org_tooltip %></em> | ||
| <% dflt = @orgs.include?(current_user.org) ? current_user.org : nil %> | ||
| <%= f.fields_for :org, @plan.org do |org_fields| %> | ||
| <%= render partial: "shared/org_selectors/local_only", | ||
| locals: { | ||
| form: org_fields, | ||
| id_field: :id, | ||
| default_org: dflt, | ||
| orgs: @orgs, | ||
| required: false | ||
| } %> | ||
| <% end %> | ||
| </div> | ||
| <div class="col-md-3 text-center"><strong>- <%= _('or') %> -</strong></div> | ||
| <div class="form-control mb-3 col-md-3"> | ||
| <div class="form-check"> | ||
| <% primary_research_org_message = _('No research organisation associated with this plan or my research organisation is not listed') %> | ||
| <%= label_tag(:plan_no_org) do %> | ||
| <%= check_box_tag(:plan_no_org, "0", false, class: "toggle-autocomplete") %> | ||
| <%= primary_research_org_message %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <div class="row form-row"> | ||
| <div class="col-12"> | ||
| <div class="form-check"> | ||
| <input type="checkbox" | ||
| class="form-check-input" | ||
| id="is_test" | ||
| value="1"> | ||
| <label class="form-check-label" for="is_test"> | ||
| <%= _('Mock project for testing, practice, or educational purposes') %> | ||
| </label> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Funder selection --> | ||
| <h2 id="funder-org"><span class="red" title="<%= required_primary_funding_tooltip %>">* <em class="sr-only"><%= required_primary_funding_tooltip %></em> </span><%= _('Select the primary funding organisation') %></h2> | ||
| <div id="funder-org-controls" class="row"> | ||
| <div class="form-control mb-3 col-md-6"> | ||
| <em class="sr-only"><%= primary_funding_tooltip %></em> | ||
| <%= f.fields_for :funder, @plan.funder = Org.new do |funder_fields| %> | ||
| <%= render partial: "shared/org_selectors/local_only", | ||
| locals: { | ||
| form: funder_fields, | ||
| id_field: :id, | ||
| label: _("Funder"), | ||
| default_org: nil, | ||
| orgs: @funders, | ||
| required: false | ||
| } %> | ||
| <% end %> | ||
| </div> | ||
| <div class="col-md-3 text-center"><strong>- <%= _('or') %> -</strong></div> | ||
| <div class="form-control mb-3 col-md-3"> | ||
| <div class="form-check"> | ||
| <% primary_funding_message = _('No funder associated with this plan or my funder is not listed') %> | ||
| <%= label_tag(:plan_no_funder) do %> | ||
| <%= check_box_tag(:plan_no_funder, "0", false, class: "toggle-autocomplete") %> | ||
| <%= primary_funding_message %> | ||
| </div> | ||
| </div> | ||
| </fieldset> | ||
| <fieldset class="form-group"> | ||
| <legend> | ||
| <%= _('Select a DMP template') %> | ||
| </legend> | ||
| <div class="row form-row"> | ||
| <div class="col-12"> | ||
| <% @templates_grouped.each do |group_label, group_templates| %> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
| <div class="mb-3"> | ||
| <div class="form-label fw-bold"> | ||
| <%= group_label %> | ||
| </div> | ||
| <% group_templates.each do |template_title, template_id| %> | ||
| <div class="form-check"> | ||
| <input | ||
| class="form-check-input" | ||
| type="radio" | ||
| id="template_<%= template_id %>" | ||
| name="plan[template_id]" | ||
| value="<%= template_id %>" | ||
| required | ||
| aria-labelledby="template_<%= template_id %>" | ||
| > | ||
| <label | ||
| class="form-check-label fw-normal" | ||
| id="template_<%= template_id %>" | ||
| for="template_<%= template_id %>" | ||
| > | ||
| <%= template_title %> | ||
| </label> | ||
| </div> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <% end %> | ||
|
|
||
| <!-- Template selection --> | ||
| <div id="available-templates" style="visibility: none;"> | ||
| <%= hidden_field_tag 'template-option-target', template_options_path %> | ||
| <h2 id="template-selection"><%= _('Which DMP template would you like to use?') %></h2> | ||
| <div class="form-control mb-3 row"> | ||
| <div class="col-md-6"> | ||
| <%= select_tag(:plan_template_id, "<option value=\"\">#{_('Please select a template')}</option>", name: 'plan[template_id]', | ||
| class: 'form-select', 'aria-labelledby': 'template-selection') %> | ||
| </div> | ||
| <div class="col-md-6"> | ||
| <span id="multiple-templates"> | ||
| <%= _('We found multiple DMP templates corresponding to your funder.') %> | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <%= f.hidden_field(:visibility, value: @is_test ? 'is_test' : Rails.configuration.x.plans.default_visibility) %> | ||
| <%= f.button(_('Create plan'), class: "btn btn-primary", type: "submit") %> | ||
| <%= link_to _('Cancel'), plans_path, class: 'btn btn-secondary' %> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| </fieldset> | ||
| <div class="row form-row"> | ||
| <div class="col-12"> | ||
| <button type="submit" class="btn btn-primary"> | ||
| <%= _('Create') %> | ||
| </button> | ||
| <%= link_to _('Cancel'), plans_path, class: 'btn btn-secondary' %> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </form> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added commits appear to address some of my earlier concerns regarding duplicate templates, so thank you for that.
That said, I still notice that the
upgrade_customization?handling fromTemplateOptionsControllerisn’t being used here, and it’s unclear what other behavioural differences now exist compared to that controller.I am wondering if, instead of a complete rework of the template selection logic, we could instead pass
user.orgtoTemplateOptionsController. And if there is in fact any required behavioural changes (e.g. always return default/global templates, grouping the templates into the three categories, etc.) then the code could be changed there. Re-using the existing logic could also help mitigate any further regressions or follow-up fixes, and keep template-selection behaviour consistent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look at this.