diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb
index 93b9508..164ad71 100644
--- a/app/controllers/plans_controller.rb
+++ b/app/controllers/plans_controller.rb
@@ -217,12 +217,12 @@
end
end
- def show_export
+ def download
@plan = Plan.find(params[:id])
authorize @plan
@phase_options = @plan.phases.order(:number).pluck(:title,:id)
@export_settings = @plan.settings(:export)
- render 'show_export'
+ render 'download'
end
diff --git a/app/policies/plan_policy.rb b/app/policies/plan_policy.rb
index d320fc2..b15c6e4 100644
--- a/app/policies/plan_policy.rb
+++ b/app/policies/plan_policy.rb
@@ -21,7 +21,7 @@
@plan.readable_by?(@user.id) && Role.find_by(user_id: @user.id, plan_id: @plan.id).active
end
- def show_export?
+ def download?
@plan.readable_by?(@user.id) && Role.find_by(user_id: @user.id, plan_id: @plan.id).active
end
diff --git a/app/views/layouts/_es5_scripts.html.erb b/app/views/layouts/_es5_scripts.html.erb
index f293a65..b00fd5d 100644
--- a/app/views/layouts/_es5_scripts.html.erb
+++ b/app/views/layouts/_es5_scripts.html.erb
@@ -40,7 +40,6 @@
<%= javascript_include_tag 'views/orgs/admin_edit.js' %>
<%= javascript_include_tag 'views/orgs/shibboleth_ds.js' %>
<%= javascript_include_tag 'views/plans/available_templates.js' %>
- <%= javascript_include_tag 'views/plans/export_configure.js' %>
<%= javascript_include_tag 'views/plans/index.js' %>
<%= javascript_include_tag 'views/plans/new.js' %>
<%= javascript_include_tag 'views/registrations/sign_in_sign_up.js' %>
diff --git a/app/views/plans/_download.html.erb b/app/views/plans/_download.html.erb
deleted file mode 100644
index e69de29..0000000
--- a/app/views/plans/_download.html.erb
+++ /dev/null
diff --git a/app/views/plans/_download_form.html.erb b/app/views/plans/_download_form.html.erb
new file mode 100644
index 0000000..03449f9
--- /dev/null
+++ b/app/views/plans/_download_form.html.erb
@@ -0,0 +1,102 @@
+<%= form_tag( export_plan_path(@plan), method: :get) do |f| %>
+
<%= _("Download Settings") %>
+
+ <% if @phase_options.length > 1 %>
+
+ <%= label_tag(:phase_id, _("Select phase to download")) %>
+ <%= select_tag(:phase_id, options_for_select(@phase_options, @phase_options[0])) %>
+
+ <% else %>
+ <%= hidden_field_tag(:phase_id, @phase_options[0][1]) %>
+ <% end %>
+
+ <%= _("Optional plan components") %>
+
+ <%= label_tag 'export[project_details]', raw("#{check_box_tag 'export[project_details]', true, false} #{_('project details coversheet')}") %>
+
+
+ <%= label_tag 'export[question_headings]', raw("#{check_box_tag 'export[question_headings]', true, true} #{_('question text and section headings')}") %>
+
+
+ <%= label_tag 'export[unanswered_questions]', raw("#{check_box_tag 'export[unanswered_questions]', true, true} #{_('unanswered questions')}") %>
+
+ <% if @plan.template.customization_of.present? %>
+
+ <%= label_tag 'export[custom_sections]', raw("#{check_box_tag 'export[custom_sections]', true, false} #{_('supplementary section(s) not requested by funding organisation')}") %>
+
+ <% end %>
+
+ <%= _('Format') %>
+
+
+ <%= select_tag :format, options_for_select(ExportedPlan::VALID_FORMATS, :pdf),
+ class: 'form-control' %>
+
+
+
+ <%= _('PDF Formatting') %>
+
+
+
+ <%= label_tag "export[formatting][font_face]", _('Face'), class: 'control-label' %>
+ <%= select_tag "export[formatting][font_face]",
+ options_for_select(Settings::Template::VALID_FONT_FACES,
+ @export_settings.formatting[:font_face]),
+ class: 'form-control',
+ "data-default": @plan.template.settings(:export).formatting[:font_face] %>
+
+
+ <%= label_tag "export[formatting][font_size]", _('Size') + " (pt)", class: 'control-label' %>
+ <%= select_tag "export[formatting][font_size]",
+ options_for_select(Settings::Template::VALID_FONT_SIZE_RANGE.to_a, @export_settings.formatting[:font_size]),
+ class: 'form-control',
+ "data-default": @plan.template.settings(:export).formatting[:font_size] %>
+
+
+
+ <%= label_tag "export[formatting][margin][top]", _('Top'),
+ class: 'control-label' %>
+ <%= select_tag "export[formatting][margin][top]",
+ options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a,
+ @export_settings.formatting[:margin][:top]),
+ class: 'form-control',
+ "data-default": @plan.template.settings(:export).formatting[:margin][:top] %>
+
+
+ <%= label_tag "export[formatting][margin][bottom]", _('Bottom'),
+ class: 'control-label' %>
+ <%= select_tag "export[formatting][margin][bottom]",
+ options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a,
+ @export_settings.formatting[:margin][:bottom]),
+ class: 'form-control',
+ "data-default": @plan.template.settings(:export).formatting[:margin][:bottom] %>
+
+
+ <%= label_tag "export[formatting][margin][left]", _('Left'),
+ class: 'control-label' %>
+ <%= select_tag "export[formatting][margin][left]",
+ options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a,
+ @export_settings.formatting[:margin][:left]),
+ class: 'form-control',
+ "data-default": @plan.template.settings(:export).formatting[:margin][:left] %>
+
+
+ <%= label_tag "export[formatting][margin][right]", _('Right'),
+ class: 'control-label' %>
+ <%= select_tag "export[formatting][margin][right]",
+ options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a,
+ @export_settings.formatting[:margin][:right]),
+ class: 'form-control',
+ "data-default": @plan.template.settings(:export).formatting[:margin][:rigth] %>
+
+
+
+ <%= button_tag(_('Download Plan'), class: "btn btn-primary", type: "submit") %>
+<% end %>
diff --git a/app/views/plans/download.html.erb b/app/views/plans/download.html.erb
new file mode 100644
index 0000000..f971efe
--- /dev/null
+++ b/app/views/plans/download.html.erb
@@ -0,0 +1,12 @@
+
+
+
+
<%= @plan.title %>
+
+
+
+
+
+ <%= render partial: 'download_form', layout: '/shared/plan_navigation', locals: { plan: @plan } %>
+
+
diff --git a/app/views/plans/show_export.html.erb b/app/views/plans/show_export.html.erb
deleted file mode 100644
index 3a2253a..0000000
--- a/app/views/plans/show_export.html.erb
+++ /dev/null
@@ -1,124 +0,0 @@
-<%- model_class = Plan -%>
-
-
-
-
-
<%= @plan.title %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<%= _("Download Settings") %>
-
- <%= form_tag( export_plan_path(@plan), method: :get, html: {class: "roadmap-form"}) do |f| %>
- <% if @phase_options.length > 1 %>
-
- <%= label_tag(:phase_id, _("Select phase to download")) %>
- <%= select_tag(:phase_id, options_for_select(@phase_options, @phase_options[0])) %>
-
- <% else %>
- <%= hidden_field_tag(:phase_id, @phase_options[0][1]) %>
- <% end %>
- <%= _("Optional plan components") %>
-
- <%= check_box_tag 'export[project_details]', true, false %>
- <%= label_tag 'export[project_details]', _('project details coversheet'), class: 'checkbox-label' %>
-
-
- <%= check_box_tag 'export[question_headings]', true, true, class: 'question-headings'%>
- <%= label_tag 'export[question_headings]', _('question text and section headings'), class: 'checkbox-label' %>
-
-
- <%= check_box_tag 'export[unanswered_questions]', true, true, class: 'unanswered-questions' %>
- <%= label_tag 'export[unanswered_questions]', _('unanswered questions'), class: 'checkbox-label' %>
-
- <% if @plan.template.customization_of.present? %>
-
- <%= check_box_tag 'export[custom_sections]', true, false %>
- <%= label_tag 'export[custom_sections]', _('supplementary section(s) not requested by funding organisation'), class: 'checkbox-label' %>
-
- <% end %>
-
-
-
-
- <%= label_tag(:format, _('Format')) %>
- <%= select_tag(:format, options_for_select(ExportedPlan::VALID_FORMATS, :pdf), class: 'export-format-selection') %>
-
-
-
-
-
-
-
- <% end %>
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/views/shared/_plan_navigation.html.erb b/app/views/shared/_plan_navigation.html.erb
index 1c65b33..a6ffbd4 100644
--- a/app/views/shared/_plan_navigation.html.erb
+++ b/app/views/shared/_plan_navigation.html.erb
@@ -12,8 +12,8 @@
<%= _('Share') %>
-
- <%= _('Download') %>
+
+ <%= _('Download') %>
diff --git a/config/routes.rb b/config/routes.rb
index 343704b..218ec8f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -212,7 +212,7 @@
get 'warning'
get 'section_answers'
get 'share'
- get 'show_export'
+ get 'download'
post 'duplicate'
get 'export'
post 'invite'
diff --git a/lib/assets/javascripts/application.js b/lib/assets/javascripts/application.js
index 58a9708..a974141 100644
--- a/lib/assets/javascripts/application.js
+++ b/lib/assets/javascripts/application.js
@@ -3,5 +3,6 @@
import './views/devise/passwords/edit';
import './views/devise/passwords/new';
import './views/phases/edit';
+import './views/plans/download';
import './views/plans/edit_details';
import './views/plans/share';
diff --git a/lib/assets/javascripts/views/plans/download.js b/lib/assets/javascripts/views/plans/download.js
new file mode 100644
index 0000000..1c787ab
--- /dev/null
+++ b/lib/assets/javascripts/views/plans/download.js
@@ -0,0 +1,10 @@
+$(() => {
+ // Hide the PDF Formatting section if 'pdf' is not the desired format
+ $('select#format').on('change', (e) => {
+ if ($(e.currentTarget).val() === 'pdf') {
+ $('#pdf-formatting').show();
+ } else {
+ $('#pdf-formatting').hide();
+ }
+ });
+});
diff --git a/lib/assets/javascripts/views/plans/export_configure.js b/lib/assets/javascripts/views/plans/export_configure.js
deleted file mode 100644
index 5e7bf31..0000000
--- a/lib/assets/javascripts/views/plans/export_configure.js
+++ /dev/null
@@ -1,131 +0,0 @@
-$(document).ready(function() {
-
- // Prevent the click handler from being registered multiple times.
- // This is due to the buggy way this is included.
- if (window['has_export_js'])
- return;
-
- window['has_export_js'] = true;
-
- $.expr.filters.indeterminate = function(element) {
- return $(element).prop('indeterminate');
- };
-
- $("select#format").change(function(){
- if ($(this).val() == 'pdf') {
- $("#pdf-format-options").show();
- $("#settings-toggle > small").show();
- }
- else {
- $("#pdf-format-options").hide();
- $("#settings-toggle > small").hide();
- }
- });
-
- $("input:checkbox, select:not(#format)").change(function(){
- $(".unsaved_changes_alert").show();
- });
-
- $("select:not(#format)").change(function(){
- $(".unsaved_changes_alert").show();
- });
-
- $('.check_select > legend').append(' ');
-
- $('.resetbutton').click(function(){
- $('input:checkbox').prop('checked',true);
- $("select:not(#format)").each(function(){
- $(this).val($(this).data("default"));
- });
- $(".unsaved_changes_alert").hide();
- $("#settings-toggle > small").text(__('(Using template PDF formatting values)'));
- });
-
- $('.savebutton').click(function(){
- var custom = false;
- $("select:not(#format)").each(function(){
- if ($(this).val() != $(this).data("default")) {
- custom = true;
- }
- });
- if (custom) {
- $("#settings-toggle > small").text(__('(Using custom PDF formatting values)'));
- }
- else {
- $("#settings-toggle > small").text(__('(Using template PDF formatting values)'));
- }
- $(".unsaved_changes_alert").hide();
- });
-
- $('.check_select').each(function() {
- var container = $(this),
- toggle = container.find('> legend > .toggle'),
- checks = container.find('> ol > li > input[type=checkbox], li > fieldset > legend > input[type=checkbox]');
-
-
- function checked(toggle) {
- var checks = toggle.prop('checks'),
- checked = checks.filter(':checked').length,
- indeterminate = checks.filter(':indeterminate').length;
-
- return {
- 'indeterminate' : ((checked > 0 && checked < checks.length) || indeterminate > 0),
- 'checked' : (checked == checks.length)
- };
- }
-
- function toggleParent(toggle) {
- var parent_toggle = toggle.prop('toggle');
-
- if (parent_toggle)
- parent_toggle.prop(checked(parent_toggle));
- }
-
- checks.prop('toggle', toggle);
- toggle.prop('checks', checks);
- toggle.prop('id', container.find('> legend > label').prop('for'));
- toggle.prop(checked(toggle));
- toggleParent(toggle);
-
- checks.change(function() {
- toggle.prop(checked(toggle));
- toggleParent(toggle);
- });
-
- toggle.change(function() {
- $(".unsaved_changes_alert").show();
- checks.prop({ 'checked': toggle.is(':checked'), 'indeterminate': false});
-
- checks.each(function() {
- var child_checks = $(this).prop('checks');
-
- if (child_checks)
- child_checks.prop({ 'checked': toggle.is(':checked'), 'indeterminate': toggle.is(':indeterminate') });
-
- });
- });
- });
- /*----------------
- Listener for select that displays the formatting options (e.g. csv, html, pdf, txt, etc.)
- ------------------*/
- $('.export-format-selection').click(function(e){
- e.preventDefault();
- if($(this).val() === 'pdf'){
- $('#pdf-format-options').show();
- }else{
- $('#pdf-format-options').hide();
- }
- });
-
- /*----------------
- Listener for select that disables the unanswered questions
- ------------------*/
- $('.question-headings').click(function(e){
- if($(this).is(':checked')){
- $('.unanswered-questions').removeAttr("disabled");
- }else{
- $('.unanswered-questions').prop("checked", false);
- $('.unanswered-questions').prop("disabled", true);
- }
- });
-});
\ No newline at end of file
diff --git a/lib/assets/javascripts/views/plans/share.js b/lib/assets/javascripts/views/plans/share.js
index 7b54f68..e85491e 100644
--- a/lib/assets/javascripts/views/plans/share.js
+++ b/lib/assets/javascripts/views/plans/share.js
@@ -1,6 +1,6 @@
import ariatiseForm from '../../utils/ariatiseForm';
-$().ready(() => {
+$(() => {
// Invite Collaborators form on the Share page
ariatiseForm({ selector: '#new_role' });
});