From 86854b015d5d7a893ab5025dd9aa037d2719cd22 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Thu, 29 Apr 2021 15:21:58 +0200 Subject: [PATCH] Add third template to reports [SCI-5618] --- app/assets/javascripts/reports/new.js | 4 +- app/controllers/reports_controller.rb | 4 +- .../templates/template_2/cover.html.erb | 5 +- .../templates/template_3/cover.html.erb | 90 +++++++++++++++++++ .../templates/template_3/edit.html.erb | 14 +++ .../templates/template_3/footer.html.erb | 36 ++++++++ .../templates/template_3/header.html.erb | 26 ++++++ .../_project_template_selector.html.erb | 2 +- config/initializers/extends.rb | 3 +- 9 files changed, 175 insertions(+), 9 deletions(-) create mode 100644 app/views/reports/templates/template_3/cover.html.erb create mode 100644 app/views/reports/templates/template_3/edit.html.erb create mode 100644 app/views/reports/templates/template_3/footer.html.erb create mode 100644 app/views/reports/templates/template_3/header.html.erb diff --git a/app/assets/javascripts/reports/new.js b/app/assets/javascripts/reports/new.js index b63d148c1..4da092c4a 100644 --- a/app/assets/javascripts/reports/new.js +++ b/app/assets/javascripts/reports/new.js @@ -980,9 +980,6 @@ function reportHandsonTableConverter() { // Project reportData.project_id = dropdownSelector.getValues('#projectSelector'); - // Template - reportData.template_id = dropdownSelector.getValues('#templateSelector'); - // Template values reportData.template_values = {}; $.each($('.report-template-values-container').find('.sci-input-field, select'), function(i, field) { @@ -1030,6 +1027,7 @@ function reportHandsonTableConverter() { }); // Settings + reportData.report.settings.template = dropdownSelector.getValues('#templateSelector'); reportData.report.settings.all_tasks = $('.project-contents-container .select-all-my-modules-checkbox') .prop('checked'); $.each($('.task-contents-container .content-element .protocol-setting'), function(i, e) { diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index a12fe6ea9..897e21727 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -186,7 +186,7 @@ class ReportsController < ApplicationController respond_to do |format| format.json do @report.update!(pdf_file_processing: true) - Reports::PdfJob.perform_later(@report, 'template_1', current_user) + Reports::PdfJob.perform_later(@report, @report.settings[:template], current_user) render json: { message: I18n.t('projects.reports.index.generation.accepted_message') } @@ -548,6 +548,6 @@ class ReportsController < ApplicationController end def generate_pdf_report - Reports::PdfJob.perform_later(@report, 'template_1', current_user) if @report.persisted? + Reports::PdfJob.perform_later(@report, @report.settings[:template], current_user) if @report.persisted? end end diff --git a/app/views/reports/templates/template_2/cover.html.erb b/app/views/reports/templates/template_2/cover.html.erb index fe859aeaf..6bd740f9b 100644 --- a/app/views/reports/templates/template_2/cover.html.erb +++ b/app/views/reports/templates/template_2/cover.html.erb @@ -23,6 +23,7 @@ ul { list-style-type: none; + padding: 0; } li { @@ -72,7 +73,7 @@
- + EXECUTIVE SUMMARY