diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 48b544d..ac9ec75 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -254,6 +254,7 @@ @formatting = params[:export][:formatting] || @plan.settings(:export).formatting file_name = @plan.title.gsub(/ /, "_") + respond_to do |format| format.html { render layout: false } format.csv { send_data @plan.as_csv(@show_sections_questions), filename: "#{file_name}.csv" } @@ -261,13 +262,13 @@ format.docx { render docx: "#{file_name}.docx", content: render_to_string(partial: 'shared/export/plan') } format.pdf do render pdf: file_name, - margin: @formatting[:margin], - footer: { - center: _('Created using the %{application_name}. Last modified %{date}') % {application_name: Rails.configuration.branding[:application][:name], date: l(@plan.updated_at.to_date, formats: :short)}, - font_size: 8, - spacing: (Integer(@formatting[:margin][:bottom]) / 2) - 4, - right: '[page] of [topage]' - } + margin: @formatting[:margin], + footer: { + center: _('Created using the %{application_name}. Last modified %{date}') % {application_name: Rails.configuration.branding[:application][:name], date: l(@plan.updated_at.to_date, formats: :short)}, + font_size: 8, + spacing: (Integer(@formatting[:margin][:bottom]) / 2) - 4, + right: '[page] of [topage]' + } end end end diff --git a/app/views/shared/export/_plan.erb b/app/views/shared/export/_plan.erb index f9fdf65..fb9acb4 100644 --- a/app/views/shared/export/_plan.erb +++ b/app/views/shared/export/_plan.erb @@ -1,9 +1,30 @@ +<% + font_face = (@formatting[:font_face].present? ? "#{@formatting[:font_face]}" : 'Arial, Helvetica, Sans-Serif') + font_size = (@formatting[:font_size].present? ? "#{@formatting[:font_size]}" : '12') + margin_top = '5' + margin_bottom = '10' + margin_left = '12' + margin_right = '12' + + if @formatting[:margin].present? + margin_top = (@formatting[:margin][:top].is_a?(Integer) ? @formatting[:margin][:top] * 4 : @formatting[:margin][:top]) if @formatting[:margin][:top].present? + margin_right = (@formatting[:margin][:right].is_a?(Integer) ? @formatting[:margin][:right] * 4 : @formatting[:margin][:right]) if @formatting[:margin][:right].present? + margin_bottom = (@formatting[:margin][:bottom].is_a?(Integer) ? @formatting[:margin][:bottom] * 4 : @formatting[:margin][:bottom]) if @formatting[:margin][:bottom].present? + margin_left = (@formatting[:margin][:left].is_a?(Integer) ? @formatting[:margin][:left] * 4 : @formatting[:margin][:left]) if @formatting[:margin][:left].present? + end +%> + <%= @plan.title %> - <%= render partial: '/shared/export/plan_styling' %> + <%= render partial: '/shared/export/plan_styling', + locals: { + font_face: font_face, + font_size: "#{font_size}pt", + margin: "#{margin_top}px #{margin_right}px #{margin_bottom}px #{margin_left}px" + } %> <% if @show_coversheet %> @@ -13,10 +34,7 @@ <% @hash[:phases].each do |phase| %>
-

- <%= (@hash[:phases].length > 1 ? "#{@plan.title} - #{phase[:title]}" : @plan.title) %> -

- +

<%= (@hash[:phases].length > 1 ? "#{@plan.title} - #{phase[:title]}" : @plan.title) %>


<% phase[:sections].each do |section| %> <% if @show_sections_questions %> diff --git a/app/views/shared/export/_plan_coversheet.erb b/app/views/shared/export/_plan_coversheet.erb index 2111156..fef0952 100644 --- a/app/views/shared/export/_plan_coversheet.erb +++ b/app/views/shared/export/_plan_coversheet.erb @@ -1,10 +1,8 @@
-
-

<%= @plan.title %>

-

- <%= _("A Data Management Plan created using ") + Rails.configuration.branding[:application][:name] %> -

-
+

<%= @plan.title %>

+

+ <%= _("A Data Management Plan created using ") + Rails.configuration.branding[:application][:name] %> +


<%= @hash[:attribution].length > 1 ? _("Creators: ") : _('Creator:') %> <%= @hash[:attribution].join(', ') %>


diff --git a/app/views/shared/export/_plan_styling.erb b/app/views/shared/export/_plan_styling.erb index f33b2c2..3ed931b 100644 --- a/app/views/shared/export/_plan_styling.erb +++ b/app/views/shared/export/_plan_styling.erb @@ -1,65 +1,61 @@ -<% font_size = @formatting[:font_size].kind_of?(Integer) ? Integer(@formatting[:font_size]) : 10 %> - \ No newline at end of file diff --git a/lib/assets/stylesheets/application.scss b/lib/assets/stylesheets/application.scss index 778a270..d260a65 100644 --- a/lib/assets/stylesheets/application.scss +++ b/lib/assets/stylesheets/application.scss @@ -23,4 +23,4 @@ float: left; clear: left; margin-bottom: 10px; -} \ No newline at end of file +}