diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 3710ff5..caac402 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -283,6 +283,8 @@ def show_export @plan = Plan.find(params[:id]) authorize @plan + @phase_options = @plan.phases.order(:number).pluck(:title,:id) + @export_settings = @plan.settings(:export) render 'show_export' end @@ -291,10 +293,14 @@ def export @plan = Plan.find(params[:id]) authorize @plan + # what if the user passes a phase which is not in the plan? hard to auth with pundit + raise Pundit::NotAuthorizedError, "invalid phase" unless @plan.phases.pluck(:id).include?(params[:phase_id]) # If no format is specified, default to PDF params[:format] = 'pdf' if params[:format].nil? + # We should re-work this into something more useful than creating a new one + # every time a plan gets exported @exported_plan = ExportedPlan.new.tap do |ep| ep.plan = @plan ep.phase_id = params[:phase_id] @@ -329,6 +335,7 @@ end end rescue ActiveRecord::RecordInvalid => e + @phase_options = @plan.phases.order(:number).pluck(:title,:id) redirect_to show_export_plan_path(@plan), alert: _('%{format} is not a valid exporting format. Available formats to export are %{available_formats}.') % {format: params[:format], available_formats: ExportedPlan::VALID_FORMATS.to_s} end @@ -375,6 +382,7 @@ end end rescue ActiveRecord::RecordInvalid => e + @phase_options = @plan.phases.order(:number).pluck(:title,:id) redirect_to show_export_plan_path(@plan), alert: _('Unable to download the DMP at this time.') end end diff --git a/app/controllers/settings/plans_controller.rb b/app/controllers/settings/plans_controller.rb index c406401..07b2789 100644 --- a/app/controllers/settings/plans_controller.rb +++ b/app/controllers/settings/plans_controller.rb @@ -36,6 +36,7 @@ flash[:alert] = _('An error has occurred while saving/resetting your export settings.') end respond_to do |format| + @phase_options = @plan.phases.order(:number).pluck(:title,:id) format.html { redirect_to(show_export_plan_path(@plan.id)) } # format.json { render json: settings_json } end diff --git a/app/views/plans/show_export.html.erb b/app/views/plans/show_export.html.erb index f0224a0..baf78ed 100644 --- a/app/views/plans/show_export.html.erb +++ b/app/views/plans/show_export.html.erb @@ -1,4 +1,5 @@ <%- model_class = Plan -%> +<% javascript('views/plans/export_configure.js') %> <%= render :partial => "plan_title", locals: {plan: @plan} %> @@ -6,17 +7,18 @@
+
\ No newline at end of file diff --git a/app/views/settings/phases/_export_formatting_form.html.erb b/app/views/settings/phases/_export_formatting_form.html.erb index 915bce1..91b1bb8 100644 --- a/app/views/settings/phases/_export_formatting_form.html.erb +++ b/app/views/settings/phases/_export_formatting_form.html.erb @@ -1,5 +1,5 @@ <% - @export_settings ||= plan.settings(:export) + admin_settings = @export_settings.fields[:admin] question_settings = @export_settings.fields[:questions] || :all filename = @export_settings.title.present? ? @export_settings.title : plan.title @@ -72,39 +72,7 @@ <% end %> -
-

<%= _('PDF Formatting') %>

-
- <%= _('Font') -%> -
- <%= label_tag("export[formatting][font_face]", _('Face')) %> - <%= select_tag("export[formatting][font_face]", options_for_select(Settings::Template::VALID_FONT_FACES, @export_settings.formatting[:font_face]), { "data-default" => plan.template.settings(:export).formatting[:font_face] }) %> -
-
- <%= label_tag("export[formatting][font_size]", _('Size') + " (pt)") %> - <%= select_tag("export[formatting][font_size]", options_for_select(Settings::Template::VALID_FONT_SIZE_RANGE.to_a, @export_settings.formatting[:font_size]), { "data-default" => plan.template.settings(:export).formatting[:font_size] }) %> -
-
-
- <%= _('Margin') -%> (mm) -
- <%= label_tag("export[formatting][margin][top]", _('Top')) %> - <%= select_tag("export[formatting][margin][top]", options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a, @export_settings.formatting[:margin][:top]), { "data-default" => plan.template.settings(:export).formatting[:margin][:top] }) %> -
-
- <%= label_tag("export[formatting][margin][bottom]", _('Bottom')) %> - <%= select_tag("export[formatting][margin][bottom]", options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a, @export_settings.formatting[:margin][:bottom]), { "data-default" => plan.template.settings(:export).formatting[:margin][:bottom] }) %> -
-
- <%= label_tag("export[formatting][margin][left]", _('Left')) %> - <%= select_tag("export[formatting][margin][left]", options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a, @export_settings.formatting[:margin][:left]), { "data-default" => plan.template.settings(:export).formatting[:margin][:left] }) %> -
-
- <%= label_tag("export[formatting][margin][right]", _('Right')) %> - <%= select_tag("export[formatting][margin][right]", options_for_select(Settings::Template::VALID_MARGIN_RANGE.to_a, @export_settings.formatting[:margin][:right]), { "data-default" => plan.template.settings(:export).formatting[:margin][:rigth] }) %> -
-
-
+
<%= submit_tag(_('Reset'), class: "btn btn-primary", role:'button') %> <%= submit_tag(_('Save'), class: "btn btn-primary", "data-toggle" => "collapse", "data-target" => "#settings-accordion-plan-#{plan.template.id}", role:"button") %> diff --git a/app/views/users/_notification_preferences.html.erb b/app/views/users/_notification_preferences.html.erb index ef6e11a..46051d2 100644 --- a/app/views/users/_notification_preferences.html.erb +++ b/app/views/users/_notification_preferences.html.erb @@ -1,6 +1,6 @@

- <%= link_to 'Select all', '#', id: 'select_all' %> | - <%= link_to 'Deselect all', '#', id: 'deselect_all' %> + <%= link_to _('Select all'), '#', id: 'select_all' %> | + <%= link_to _('Deselect all'), '#', id: 'deselect_all' %>

@@ -12,17 +12,17 @@
<%= hidden_field_tag 'prefs[users][new_comment]', false %> <%= check_box_tag 'prefs[users][new_comment]', true, @prefs[:users][:new_comment] %> - <%= label_tag 'prefs[users][new_comment]', 'A new comment has been added to my DMP', :class => 'checkbox-label' %> + <%= label_tag 'prefs[users][new_comment]', _('A new comment has been added to my DMP'), :class => 'checkbox-label' %>
<%= hidden_field_tag 'prefs[users][added_as_coowner]', false %> <%= check_box_tag 'prefs[users][added_as_coowner]', true, @prefs[:users][:added_as_coowner] %> - <%= label_tag 'prefs[users][added_as_coowner]', 'A plan has been shared with me', :class => 'checkbox-label' %> + <%= label_tag 'prefs[users][added_as_coowner]', _('A plan has been shared with me'), :class => 'checkbox-label' %>
<%= hidden_field_tag 'prefs[users][admin_privileges]', false %> <%= check_box_tag 'prefs[users][admin_privileges]', true, @prefs[:users][:admin_privileges] %> - <%= label_tag 'prefs[users][admin_privileges]', 'Admin privileges granted to me', :class => 'checkbox-label' %> + <%= label_tag 'prefs[users][admin_privileges]', _('Admin privileges granted to me'), :class => 'checkbox-label' %>

@@ -30,7 +30,7 @@
<%= hidden_field_tag 'prefs[owners_and_coowners][visibility_changed]', false %> <%= check_box_tag 'prefs[owners_and_coowners][visibility_changed]', true, @prefs[:owners_and_coowners][:visibility_changed] %> - <%= label_tag 'prefs[owners_and_coowners][visibility_changed]', "My DMP's visibility has changed", :class => 'checkbox-label' %> + <%= label_tag 'prefs[owners_and_coowners][visibility_changed]', _("My DMP's visibility has changed"), :class => 'checkbox-label' %>

@@ -38,23 +38,23 @@
<%= hidden_field_tag 'prefs[admins][template_published]', false %> <%= check_box_tag 'prefs[admins][template_published]', true, @prefs[:admins][:template_published] %> - <%= label_tag 'prefs[admins][template_published]', 'An organisational template is published', :class => 'checkbox-label' %> + <%= label_tag 'prefs[admins][template_published]', _('An organisational template is published'), :class => 'checkbox-label' %>
<%= hidden_field_tag 'prefs[admins][template_unpublished]', false %> <%= check_box_tag 'prefs[admins][template_unpublished]', true, @prefs[:admins][:template_unpublished] %> - <%= label_tag 'prefs[admins][template_unpublished]', 'An organisational template is unpublished', :class => 'checkbox-label' %> + <%= label_tag 'prefs[admins][template_unpublished]', _('An organisational template is unpublished'), :class => 'checkbox-label' %>
<%= hidden_field_tag 'prefs[admins][feedback_requested]', false %> <%= check_box_tag 'prefs[admins][feedback_requested]', true, @prefs[:admins][:feedback_requested] %> - <%= label_tag 'prefs[admins][feedback_requested]', 'A user has requested feedback on a DMP', :class => 'checkbox-label' %> + <%= label_tag 'prefs[admins][feedback_requested]', _('A user has requested feedback on a DMP'), :class => 'checkbox-label' %>

 
- <%= submit_tag 'Save', class: 'btn btn-primary', role: 'button' %> + <%= submit_tag _('Save'), class: 'btn btn-primary', role: 'button' %>
<% end %> diff --git a/lib/assets/javascripts/views/plans/export_configure.js b/lib/assets/javascripts/views/plans/export_configure.js index 2229eee..5e7bf31 100644 --- a/lib/assets/javascripts/views/plans/export_configure.js +++ b/lib/assets/javascripts/views/plans/export_configure.js @@ -116,4 +116,16 @@ $('#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/stylesheets/dmproadmap.scss b/lib/assets/stylesheets/dmproadmap.scss index 5a89958..2772abb 100644 --- a/lib/assets/stylesheets/dmproadmap.scss +++ b/lib/assets/stylesheets/dmproadmap.scss @@ -14,7 +14,7 @@ $medium-grey: #827D7E; $light-grey: #CCC; -$primary-color: #4f5253; +$primary-color: #f49700; $highlight-color: $black; $highlight-background-color: #F36F24; diff --git a/lib/assets/stylesheets/dmproadmap/forms.scss b/lib/assets/stylesheets/dmproadmap/forms.scss index fef96ea..12e30d8 100644 --- a/lib/assets/stylesheets/dmproadmap/forms.scss +++ b/lib/assets/stylesheets/dmproadmap/forms.scss @@ -692,4 +692,21 @@ #banner-text div.inline { width: 70%; } +} + +/* Plan Export Page */ +/* ------------------------------------------------ */ +#pdf-format-options { + select, label{ + display: block; + height: 30px; + width: 100%; + min-width: initial; + } + .font, .margins { + display: inline-block; + div{ + display: inline-block; + } + } } \ No newline at end of file