Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
All of the work for changing static content is done. Here is where we
switch branches to look for problem in template translations
  • Loading branch information
lagoan committed Jun 11, 2021
1 parent e764910 commit 619e47b
Show file tree
Hide file tree
Showing 15 changed files with 2,599 additions and 2,507 deletions.
3 changes: 2 additions & 1 deletion app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def new
flash[:notice] = "#{_('This is a')} <strong>#{_('test plan')}</strong>"
end
@is_test = params[:test] ||= false
respond_to :html

render :new_plan
end

# POST /plans
Expand Down
7 changes: 5 additions & 2 deletions app/javascript/views/plans/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ $(() => {
// When one of the autocomplete fields changes, fetch the available templates
const handleComboboxChange = debounce(() => {
const validOrg = (isValidText($('#plan_org_id').val()) || $('#plan_no_org').prop('checked'));
const validFunder = (isValidText($('#plan_funder_id').val()) || $('#plan_no_funder').prop('checked'));
// const validFunder = (isValidText($('#plan_funder_id').val())
// || $('#plan_no_funder').prop('checked'));

if (!validOrg || !validFunder) {
// before we were checking also "|| !validFunder " but our current version
// does not take into account funders for creating plans
if (!validOrg) {
$('#available-templates').fadeOut();
$('#plan_template_id').val('');
} else {
Expand Down
29 changes: 1 addition & 28 deletions app/views/plans/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<%= render partial: "shared/accessible_combobox",
locals: {name: 'plan[org_name]',
id: 'plan_org_name',
default_selection: nil,
models: @orgs,
attribute: 'name',
required: true,
Expand All @@ -71,34 +72,6 @@
</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 class="row">
<div class="form-group col-xs-6">
<em class="sr-only"><%= primary_funding_tooltip %></em>
<%= render partial: "shared/accessible_combobox",
locals: {name: 'plan[funder_name]',
id: 'plan_funder_name',
default_selection: nil,
models: @funders,
attribute: 'name',
required: true,
error: _('You must select a funding organisation from the list.'),
tooltip: primary_funding_tooltip,
placement: 'bottom'} %>
</div>
<div class="col-md-1 create-plan-or"><strong>- <%= _('or') %> -</strong></div>
<div class="form-group col-xs-5 create-plan-checkbox">
<div class="checkbox">
<% 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) %>
<%= primary_funding_message %>
<% end %>
</div>
</div>
</div>

<!-- Template selection -->
<div id="available-templates" style="visibility: none;">
<%= hidden_field_tag 'template-option-target', template_options_path %>
Expand Down
97 changes: 97 additions & 0 deletions app/views/plans/new_plan.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<% 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="left-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>
</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-group col-xs-6">
<em class="sr-only"><%= project_title_tooltip %></em>
<%= f.text_field(:title, class: 'form-control', 'aria-describedby': 'project-title', 'aria-required': 'true', 'aria-label': 'project-title',
'data-toggle': 'tooltip',
'data-placement': 'bottom',
spellcheck: true,
title: project_title_tooltip ) %>
</div>
<div class="col-md-1">&nbsp;</div>
<div class="form-group col-xs-5">
<div class="checkbox create-plan-mock">
<%= label_tag(:is_test) do %>
<%= check_box_tag(:is_test, "1", false) %>
<%= _('mock project for testing, practice, or educational purposes') %>
<% end %>
</div>
</div>
</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>
<%= _('Indicate the primary research organisation') %>
</h2>
<div class="row">
<div class="form-group col-md-6">
<em class="sr-only"><%= research_org_tooltip %></em>
<%= render partial: "shared/accessible_combobox",
locals: {name: 'plan[org_name]',
id: 'plan_org_name',
default_selection: nil,
models: @orgs,
attribute: 'name',
required: true,
error: _('You must select a research organisation from the list.'),
tooltip: research_org_tooltip,
placement: 'bottom'} %>
</div>
<div class="col-md-1 pad-top-10 create-plan-or"><strong>- <%= _('or') %> -</strong></div>
<div class="form-group col-md-5 create-plan-checkbox">
<div class="checkbox">
<% 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) %>
<%= primary_research_org_message %>
<% end %>
</div>
</div>
</div>

<!-- 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-group row">
<div class="col-xs-6">
<%= select_tag(:plan_template_id, "<option value=\"\">#{_('Please select a template')}</option>", name: 'plan[template_id]',
class: 'form-control', 'aria-describedby': 'template-selection') %>
</div>
<div class="col-xs-6">
<span id="multiple-templates">
<%= _('We found multiple DMP templates corresponding to your primary research organisation') %>
</span>
</div>
</div>
</div>

<%= f.hidden_field(:visibility, value: @is_test ? 'is_test' : Rails.application.config.default_plan_visibility) %>
<%= f.button(_('Create plan'), class: "btn btn-primary", type: "submit") %>
<%= link_to _('Cancel'), plans_path, class: 'btn btn-default' %>
<% end %>
</div>
</div>
Loading

0 comments on commit 619e47b

Please sign in to comment.