- <%= _('Only one DMP template is available for those research and funding organisations.') %><%= _('We found multiple DMP templates corresponding to your funder.') %>
diff --git a/lib/assets/javascripts/views/plans/new.js b/lib/assets/javascripts/views/plans/new.js
index 63ed8c9..9ab1310 100644
--- a/lib/assets/javascripts/views/plans/new.js
+++ b/lib/assets/javascripts/views/plans/new.js
@@ -5,6 +5,11 @@
import { isValidText } from '../../utils/isValidInputType';
$(() => {
+ // AJAX error function for available template search
+ const error = () => {
+ // TODO: add error handling
+ };
+
// AJAX success function for available template search
const success = (data) => {
if (isObject(data) &&
@@ -14,28 +19,21 @@
data.templates.forEach((t) => {
$('#plan_template_id').append(``);
});
- // If there is only one template, show it but disable the dropdown and hide
- // the 'Multiple templates found message'
+ // If there is only one template, set the input field value and submit the form
+ // otherwise show the dropdown list and the 'Multiple templates found message'
if (data.templates.length === 1) {
$('#plan_template_id option').attr('selected', 'true');
- $('#single-template').show();
$('#multiple-templates').hide();
} else {
- $('#single-template').hide();
$('#multiple-templates').show();
+ $('#available-templates').fadeIn();
}
- $('#available-templates').fadeIn();
} else {
- $('#available-templates').fadeOut();
- // TODO adequate error handling for no templates returned
- // (this would mean there is no default template!)
+ error();
}
}
};
- // AJAX error function for available template search
- const error = () => {
- // TODO adequate error handling for network error
- };
+
const getAction = jQueryForm => jQueryForm.attr('action');
const getMethod = jQueryForm => jQueryForm.attr('method');