diff --git a/app/views/plans/_form_v2.html.erb b/app/views/plans/_form_v2.html.erb index 16da10b..92b1bd4 100644 --- a/app/views/plans/_form_v2.html.erb +++ b/app/views/plans/_form_v2.html.erb @@ -30,11 +30,8 @@ <%= _('Would you like to use the default template "Default Template"?') %>

- <%= hidden_field_tag('own_org_name', current_user.org.name) %> - <%= hidden_field_tag('own_org_id', current_user.org.id) %> -

- <%= _('Your organisation provides multiple templates, would you like to choose one of them') %> -

+ <%= hidden_field_tag('own_org_name', @default_org.name) %> + <%= hidden_field_tag('own_org_id', @default_org.id) %> @@ -51,9 +48,6 @@ required: true, error: _('You must select a research organisation from the list.'), tooltip: _('Please select a valid research organisation from the list.')} %> -

- <%= _('The chosen organisation has more than one template, please choose one of them') %> -

@@ -70,18 +64,21 @@ required: true, error: _('You must select a funding organisation from the list.'), tooltip: _('Please select a valid funding organisation from the list.')} %> -

- <%= _('The chosen funder has more than one template, please choose one of them') %> -

- <%= check_box_tag(:plan_no_org, '', false, style: 'display: block;') %> - <%= check_box_tag(:plan_no_funder, '', true, style: 'display: block;') %> - <%= hidden_field_tag 'template-option-target', org_admin_template_options_path %> - <%= select_tag( - :plan_template_id, options_from_collection_for_select( - @templates, 'id', 'title', @templates.first.id - )) %> + <% cb_display = (params[:debug] == "true" ? "block" : "none") %> + <%= check_box_tag(:plan_no_org, '', false, style: "display: #{cb_display};") %> + <%= check_box_tag(:plan_no_funder, '', true, style: "display: #{cb_display};") %> +
+

+ <%= _('Multiple templates where found for this organisation, which one would you like to use ?') %> +

+ <%= hidden_field_tag 'template-option-target', org_admin_template_options_path %> + <%= select_tag( + :plan_template_id, options_from_collection_for_select( + @templates, 'id', 'title', @templates.first.id + )) %> +
diff --git a/lib/assets/javascripts/views/plans/new.js b/lib/assets/javascripts/views/plans/new.js index 1ca7623..bd3fc76 100644 --- a/lib/assets/javascripts/views/plans/new.js +++ b/lib/assets/javascripts/views/plans/new.js @@ -105,7 +105,7 @@ // If the user clicks the no Org/Funder checkbox disable the dropdown // and hide clear button - $('#new_plan #plan_no_org, #new_plan #plan_no_funder').click((e) => { + $('#new_plan #plan_no_org, #new_plan #plan_no_funder').change((e) => { const whichOne = $(e.currentTarget).prop('id').split('_')[2]; handleCheckboxClick(whichOne, e.currentTarget.checked); }); @@ -144,13 +144,25 @@ // First and second tab are equivalent to checking the "No funder" checkbox $('a[href="#own_org"], a[href="#other_org"]').on('shown.bs.tab', () => { - $('#plan_no_funder').prop('checked', true); + $('#plan_no_org').prop('checked', false).change(); + $('#plan_no_funder').prop('checked', true).change(); + }); + + // Empty combobox on second tab activation + $('a[href="#other_org"]').on('shown.bs.tab', () => { + $('#plan_org_id').val('-1'); + $('#plan_org_name').val(''); }); // Restore default organisation when activating first tab $('a[href="#own_org"]').on('shown.bs.tab', () => { $('#plan_org_name').val($('#own_org_name').val()); $('#plan_org_id').val($('#own_org_id').val()); - handleComboboxChange(); + }); + + // Last tab is equivalent to checking the "No org" checkbox + $('a[href="#funder"]').on('shown.bs.tab', () => { + $('#plan_no_org').prop('checked', true).change(); + $('#plan_no_funder').prop('checked', false).change(); }); });