Add third template to reports [SCI-5618]

This commit is contained in:
aignatov-bio 2021-04-29 15:21:58 +02:00
parent 6b023603f9
commit 86854b015d
9 changed files with 175 additions and 9 deletions

View file

@ -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) {

View file

@ -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

View file

@ -23,6 +23,7 @@
ul {
list-style-type: none;
padding: 0;
}
li {
@ -72,7 +73,7 @@
<td colspan=4><div class="divider"></div></td>
</tr>
<tr class="executive-summary">
<td colspan=4>
<td colspan=4 style="vertical-align: top;">
<b>EXECUTIVE SUMMARY</b>
<ul>
<li><b>Report file name:&nbsp;</b><%= render Reports::TextInputComponent.new(report: report, name: :report_file_name, label: 'Report file name', editing: false) %></li>
@ -97,7 +98,7 @@
<td colspan=2></td>
</tr>
<tr class="table-of-contents">
<td colspan=4>
<td colspan=4 style="vertical-align: top;">
<ul>
<li><b>Objective&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :objective, label: 'Objective', editing: false) %></li>
<li><b>Background&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :background, label: 'Background ', editing: false) %></li>

View file

@ -0,0 +1,90 @@
<div class="report-template-index">
<style type="text/css" scoped>
.report-template-index .template-table {
height: 297mm;
width: 100%;
font-size: 16px;
border-collapse: collapse;
border-spacing: 0;
table-layout: fixed;
}
.align-center {
text-align: center;
}
.executive-summary {
height: 170mm;
}
ul {
list-style-type: none;
padding: 0;
}
li {
padding: .5em 0;
}
.divider {
height: 4px;
background: black;
width: 100%;
}
</style>
<table class="template-table">
<tr>
<td colspan=2 class="logo"></td>
<td colspan=2></td>
</tr>
<tr>
<td colspan=4 class="align-center"><b>OTR-Short Form Report</b></td>
</tr>
<tr>
<td colspan=4><div class="divider"></div></td>
</tr>
<tr>
<td><b>Date:</b></td>
<td colspan=3><%= render Reports::DateInputComponent.new(report: report, name: :report_date, label: 'Date', editing: false) %></td>
</tr>
<tr>
<td><b>From:</b> </td>
<td colspan=3><%= render Reports::TextInputComponent.new(report: report, name: :report_from, label: 'From', editing: false) %></td>
</tr>
<tr>
<td><b>Through:</b></td>
<td colspan=3><%= render Reports::TextInputComponent.new(report: report, name: :report_through, label: 'Through', editing: false) %></td>
</tr>
<tr>
<td><b>To:</b></td>
<td colspan=3><%= render Reports::TextInputComponent.new(report: report, name: :report_to, label: 'To', editing: false) %></td>
</tr>
<tr>
<td><b>Subject:</b></td>
<td colspan=3><%= render Reports::TextInputComponent.new(report: report, name: :report_subject, label: 'Subject', editing: false) %></td>
</tr>
<tr>
<td colspan=4><div class="divider"></div></td>
</tr>
<tr class="executive-summary">
<td colspan=4 style="vertical-align: top;">
<ul>
<li><b>Report file name:&nbsp;</b><%= render Reports::TextInputComponent.new(report: report, name: :report_file_name, label: 'Report file name', editing: false) %></li>
<li><b>Associated Protocol:&nbsp;</b><%= render Reports::TextInputComponent.new(report: report, name: :associated_protocol, label: 'Associated Protocol', editing: false) %></li>
<li><b>Background:&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :report_background, label: 'Background', editing: false) %></li>
<li><b>Conclusions:&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :outcome_impact, label: 'Conclusions', editing: false) %></li>
<li><b>Results and Discussion&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :results, label: 'Results and Discussion', editing: false) %></li>
<li><b>References (if needed)&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :references, label: 'References (if needed)', editing: false) %></li>
<li><b>Records Management Project Name:&nbsp;</b><%= render Reports::LargeTextInputComponent.new(report: report, name: :management_project_name, label: 'Records Management Project Name', editing: false) %></li>
</ul>
</td>
</tr>
<tr style="height: 30px">
<td colspan=1><%= render Reports::TextInputComponent.new(report: report, name: :report_file_name, label: 'Report file name', editing: false) %></td>
<td colspan=2 class="align-center">Page 1 of</td>
<td colspan=1><%= render Reports::DateInputComponent.new(report: report, name: :report_date, label: 'Date', editing: false) %></td>
</tr>
</table>
</div>

View file

@ -0,0 +1,14 @@
<% content_for :cover do %>
<%= render Reports::DateInputComponent.new(report: report, name: :report_date, label: 'Date') %>
<%= render Reports::TextInputComponent.new(report: report, name: :report_from, label: 'From') %>
<%= render Reports::TextInputComponent.new(report: report, name: :report_through, label: 'Through') %>
<%= render Reports::TextInputComponent.new(report: report, name: :report_to, label: 'To') %>
<%= render Reports::TextInputComponent.new(report: report, name: :report_subject, label: 'Subject') %>
<%= render Reports::TextInputComponent.new(report: report, name: :report_file_name, label: 'Report file name') %>
<%= render Reports::TextInputComponent.new(report: report, name: :associated_protocol, label: 'Associated Protocol') %>
<%= render Reports::LargeTextInputComponent.new(report: report, name: :report_background, label: 'Background') %>
<%= render Reports::LargeTextInputComponent.new(report: report, name: :outcome_impact, label: 'Conclusions') %>
<%= render Reports::LargeTextInputComponent.new(report: report, name: :results, label: 'Results and Discussion') %>
<%= render Reports::LargeTextInputComponent.new(report: report, name: :references, label: 'References (if needed)') %>
<%= render Reports::TextInputComponent.new(report: report, name: :management_project_name, label: 'Records Management Project Name') %>
<% end %>

View file

@ -0,0 +1,36 @@
<style>
body {
height: 95px;
}
table {
border-collapse: collapse;
border-spacing: 0;
height: 80px;
table-layout: fixed;
width: 100%
}
table td {
font-size: 16px;
padding: .25em;
text-align: left;
vertical-align: middle;
}
table td.pagination {
font-size: 14px;
font-weight: bold;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
</style>
<table>
<tr>
<td colspan=1><%= render Reports::TextInputComponent.new(report: report, name: :report_file_name, label: 'Report file name', editing: false) %></td>
<td colspan=2 class="pagination">Page <span class="page"></span> of <span class="topage"></span></td>
<td colspan=1><%= render Reports::DateInputComponent.new(report: report, name: :report_date, label: 'Date', editing: false) %></td>
</tr>
</table>

View file

@ -0,0 +1,26 @@
<style>
body {
height: 95px;
}
table {
border-collapse: collapse;
border-spacing: 0;
height: 80px;
table-layout: fixed;
width: 100%
}
table td {
font-size: 16px;
padding: .25em;
text-align: left;
vertical-align: top;
}
</style>
<table>
<tr>
<td colspan=2 class="logo"></td>
<td colspan=2></td>
</tr>
</table>

View file

@ -12,7 +12,7 @@
<div class='template-selector'>
<%= label_tag :templateSelector, t('projects.reports.wizard.first_step.select_template') %>
<%= select_tag :templateSelector,
options_for_select(@templates),
options_for_select(@templates, report.settings[:template]),
data: {
placeholder: t('projects.reports.wizard.first_step.select_template'),
values_editor_path: reports_new_template_values_path(report_id: report.id)

View file

@ -422,6 +422,7 @@ class Extends
REPORT_TEMPLATES = {
template_1: 'template_1',
template_2: 'template_2'
template_2: 'template_2',
template_3: 'template_3'
}
end