diff --git a/app/views/plans/_available_templates.html.erb b/app/views/plans/_available_templates.html.erb index d826258..900fded 100644 --- a/app/views/plans/_available_templates.html.erb +++ b/app/views/plans/_available_templates.html.erb @@ -5,7 +5,7 @@ <%= _('Select a template') %> - <%= raw @templates.collect{|t| "" }.join('') %> diff --git a/app/views/shared/_accessible_combobox.html.erb b/app/views/shared/_accessible_combobox.html.erb index e06ec20..4fe65ca 100644 --- a/app/views/shared/_accessible_combobox.html.erb +++ b/app/views/shared/_accessible_combobox.html.erb @@ -21,6 +21,8 @@ " name="<%= name.gsub("_#{attribute}]", "_id]") %>" value="<%= default_selection.id unless default_selection.nil? %>" /> + + " class="error-tooltip left-indent"> \ No newline at end of file diff --git a/app/views/templates/_show_template.html.erb b/app/views/templates/_show_template.html.erb index 33abaf6..e84fe6d 100644 --- a/app/views/templates/_show_template.html.erb +++ b/app/views/templates/_show_template.html.erb @@ -1,49 +1,39 @@ - -<% if template == current then %> - - <% if template.customization_of.nil? %> -
- <%= link_to _('Edit template details'), '# ', class: "btn btn-primary", id: "edit_template_button"%> -
- <% end %> -<% end %> -
- - - - - - - - - - - - - - - - - - - - - - -
<%= _('Title') %><%= template.title %>
<%= _('Description') %><% if !template.description.nil? && template.description != "" then %> - <%= raw template.description %> - <% else %> - - - <% end %> -
<%= _('Status') %> - <% if hash[:live].nil? %> - <%= _('Unpublished') %> +
+
+
+
<%= _('Title') %>
+
<%= template.title %>
+
<%= _('Description') %>
+
+ <%= (!template.description.nil? && template.description != "" ? raw( template.description) : '-') %> +
+
<%= _('Status') %>
+
+ <% if hash[:live].nil? %> + <%= _('Unpublished') %> - <% elsif hash[:current].dirty? %> - <%= _('You have un-published changes') %> + <% elsif hash[:current].dirty? %> + <%= _('You have un-published changes') %> - <% else %> - <%= _('Published') %> - <% end %> -
<%= _('Created at') %><%= l template.created_at.to_date, formats: :short %>
<%= _('Last updated') %><%= l template.updated_at.to_date, formats: :short %>
+ <% else %> + <%= _('Published') %> + <% end %> + +
<%= _('Created at') %>
+
<%= l template.created_at.to_date, formats: :short %>
+
<%= _('Last updated') %>
+
<%= l template.updated_at.to_date, formats: :short %>
+ +
+
+ <% if template == current then %> + + <% if template.customization_of.nil? %> + <%= _('Edit template details') %> + <% end %> + <% end %> +
+ + + diff --git a/lib/assets/javascripts/dmproadmap/forms.js b/lib/assets/javascripts/dmproadmap/forms.js index 3adfd82..5434b52 100644 --- a/lib/assets/javascripts/dmproadmap/forms.js +++ b/lib/assets/javascripts/dmproadmap/forms.js @@ -1,15 +1,39 @@ // --------------------------------------------------------------------------- +function toggleAutocompleteError(autocomplete, idbox, errorMessage){ + if(autocomplete.length > 0 && idbox.length > 0){ + var err = $(idbox).siblings("span.error-tooltip"); + if(err.length <= 0){ + err = $(idbox).siblings("span.error-tooltip-right"); + } + + // If an error element is available and the error message is not empty and the field + // is not empty + if(err.length > 0 && (errorMessage === '' || $(autocomplete).val().trim().length <= 0)){ + err.html('').attr('role', ''); + $(autocomplete).removeClass('red-border'); + }else{ + err.html(errorMessage).attr('role', 'tooltip'); + $(autocomplete).addClass('red-border'); + } + } +} + +// --------------------------------------------------------------------------- function toggleInputError(input, errorMessage){ var err = $(input).siblings("span.error-tooltip"); if(err.length <= 0){ err = $(input).siblings("span.error-tooltip-right"); } +console.log(err.length + ' - ' + errorMessage + ' - ' + $(input).val().trim().length); + + // If an error element is available and the error message is not empty and the field + // is not empty if(err.length > 0 && (errorMessage === '' || $(input).val().trim().length <= 0)){ err.html('').attr('role', ''); $(input).removeClass('red-border'); }else{ - err.html(__('Error: ') + errorMessage).attr('role', 'tooltip'); + err.html(errorMessage).attr('role', 'tooltip'); $(input).addClass('red-border'); } } diff --git a/lib/assets/javascripts/dmproadmap/utils.js b/lib/assets/javascripts/dmproadmap/utils.js index 240510d..d5f0fd4 100644 --- a/lib/assets/javascripts/dmproadmap/utils.js +++ b/lib/assets/javascripts/dmproadmap/utils.js @@ -23,7 +23,7 @@ $("[data-toggle='tooltip']").on('focus', function(e){ if($(this).attr('data-content') != undefined){ var y = $(this).width() + 35; - $(this).parent().append('
' + $(this).attr('data-content') + '' + $(this).attr('data-content') + '
'); } }).on('blur', function(e){ $(this).parent().find('div.tooltip-message').remove(); diff --git a/lib/assets/javascripts/views/plans/new.js b/lib/assets/javascripts/views/plans/new.js index 7bf6e19..5e97d3e 100644 --- a/lib/assets/javascripts/views/plans/new.js +++ b/lib/assets/javascripts/views/plans/new.js @@ -11,6 +11,16 @@ handleComboboxChange(); }); + // If there was no selection, highlight the box and display tooltip + $("#plan_org_id").change(function(){ + var msg = ($(this).val().trim().length <= 0 ? __('Please select a valid research institution from the list') : ''); + toggleAutocompleteError($("#plan_org_name"), $(this), msg); + }); + $("#plan_funder_id").change(function(){ + var msg = ($(this).val().trim().length <= 0 ? __('Please select a valid funding organisation from the list') : ''); + toggleAutocompleteError($("#plan_funder_name"), $(this), msg); + }); + // Make sure the checkbox is unchecked if we're entering text $(".js-combobox").keyup(function(){ var whichOne = $(this).prop('id').split('_')[1]; @@ -24,6 +34,7 @@ handleCheckboxClick(whichOne, this.checked); }); + // When the form receives a valid template id enable the button $("#plan_template_id").change(function(){ $("#create_plan_submit").attr('aria-disabled', ($(this).val().trim().length <= 0)); }); @@ -56,7 +67,8 @@ function handleCheckboxClick(name, checked){ $("#plan_" + name + "_name").prop("disabled", checked); $("#plan_template_id").val("").change(); - + $("#available-templates").fadeOut(); + if(checked){ $("#plan_" + name + "_name").val(""); $("#plan_" + name + "_id").val("").change(); diff --git a/lib/assets/stylesheets/dmproadmap/base.scss b/lib/assets/stylesheets/dmproadmap/base.scss index d4661cc..f7c7a2a 100644 --- a/lib/assets/stylesheets/dmproadmap/base.scss +++ b/lib/assets/stylesheets/dmproadmap/base.scss @@ -40,7 +40,8 @@ .top-indent { margin-top: 25px; } .right { - position: relative; + position: absolute; + top: 5px; right: 10px; } @@ -332,6 +333,7 @@ } div.page { + position: relative; width: 100%; background-color: $white; border-radius: 3px; @@ -350,6 +352,36 @@ margin-left: 35px; vertical-align: top; } + + /* Description Lists - Used to display the read-only version of forms */ + dl { + width: 100%; + margin: 0 auto; + + dt { + display: inline-block; + width: 15%; + text-align: right; + margin-right: 10px; + font-weight: bold; + } + dt:not(.dl-buttons):after { + content: ":"; + } + + dd { + display: inline-block; + width: 65%; + } + dd:after { + display: block; + content: " "; + margin-bottom: 10px; + } + dt.dl-buttons { + margin-top: 25px; + } + } } } } diff --git a/lib/assets/stylesheets/dmproadmap/forms.scss b/lib/assets/stylesheets/dmproadmap/forms.scss index 63995e0..2efe9d6 100644 --- a/lib/assets/stylesheets/dmproadmap/forms.scss +++ b/lib/assets/stylesheets/dmproadmap/forms.scss @@ -71,8 +71,7 @@ /* Roadmap Form Styling */ /* ------------------------------------------------ */ -form.roadmap-form, -div.read-only-form { +form.roadmap-form { text-align: top; fieldset.padded { @@ -110,8 +109,7 @@ /* Fieldset with labels to the left of inputs */ /* ------------------------------------------ */ - fieldset.side-by-side, - div.side-by-side { + fieldset.side-by-side { border: 0; .mce-tinymce {