From 65ab42a938eda82ba0d160aa59beb59acaa4b618 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 27 May 2022 13:26:40 +0200 Subject: [PATCH] Update PDF report with new step structure [SCI-6854] --- .../_my_module_protocol_element.html.erb | 5 +++++ .../elements/_my_module_step_element.html.erb | 19 +++++++++---------- .../elements/_step_text_element.html.erb | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 app/views/reports/elements/_step_text_element.html.erb diff --git a/app/views/reports/elements/_my_module_protocol_element.html.erb b/app/views/reports/elements/_my_module_protocol_element.html.erb index 85befb203..2d654b755 100644 --- a/app/views/reports/elements/_my_module_protocol_element.html.erb +++ b/app/views/reports/elements/_my_module_protocol_element.html.erb @@ -9,6 +9,11 @@
+
+

+ <%= protocol.name %> +

+
<% if protocol.description.present? %> <%= custom_auto_link(protocol.prepare_for_report(:description, export_all), diff --git a/app/views/reports/elements/_my_module_step_element.html.erb b/app/views/reports/elements/_my_module_step_element.html.erb index e0c2aa91f..444abb1f1 100644 --- a/app/views/reports/elements/_my_module_step_element.html.erb +++ b/app/views/reports/elements/_my_module_step_element.html.erb @@ -2,9 +2,7 @@ <% step_type_str = step.completed ? 'completed' : 'uncompleted' %> <% user = step.completed? && step.last_modified_by || step.user %> <% timestamp = step.completed ? step.completed_on : step.created_at %> -<% tables = step.tables %> <% assets = step.assets %> -<% checklists = step.checklists %> <% export_all = defined?(export_all) && export_all %>
@@ -39,9 +37,15 @@
- <% if @settings.dig('task', 'protocol', 'step_tables') %> - <% tables.each do |table| %> - <%= render partial: 'reports/elements/step_table_element.html.erb', locals: { table: table, export_all: export_all } %> + <% step.step_orderable_elements.order(:position).each do |e| %> + <% if e.orderable_type == 'StepTable' && @settings.dig('task', 'protocol', 'step_tables') %> + <%= render partial: 'reports/elements/step_table_element.html.erb', locals: { table: e.orderable.table, export_all: export_all } %> + <% end %> + <% if e.orderable_type == 'Checklist' && @settings.dig('task', 'protocol', 'step_checklists') %> + <%= render partial: 'reports/elements/step_checklist_element.html.erb', locals: { checklist: e.orderable, export_all: export_all } %> + <% end %> + <% if e.orderable_type == 'StepText' %> + <%= render partial: 'reports/elements/step_text_element.html.erb', locals: { step_text: e.orderable, export_all: export_all } %> <% end %> <% end %> <% if @settings.dig('task', 'protocol', 'step_files') %> @@ -49,11 +53,6 @@ <%= render partial: 'reports/elements/step_asset_element.html.erb', locals: { asset: asset, export_all: export_all } %> <% end %> <% end %> - <% if @settings.dig('task', 'protocol', 'step_checklists') %> - <% checklists.each do |checklist| %> - <%= render partial: 'reports/elements/step_checklist_element.html.erb', locals: { checklist: checklist, export_all: export_all } %> - <% end %> - <% end %> <% if @settings.dig('task', 'protocol', 'step_comments') %> <%= render partial: 'reports/elements/step_comments_element.html.erb', locals: { step: step, export_all: export_all } %> <% end %> diff --git a/app/views/reports/elements/_step_text_element.html.erb b/app/views/reports/elements/_step_text_element.html.erb new file mode 100644 index 000000000..ab212ba09 --- /dev/null +++ b/app/views/reports/elements/_step_text_element.html.erb @@ -0,0 +1,18 @@ +
+
+ <% if step_text.text.present? %> + <%= custom_auto_link(step_text.prepare_for_report(:text, export_all), + team: current_team, + simple_format: false, + tags: %w(img), + base64_encoded_imgs: export_all) %> + <% else %> + <%= t('projects.reports.elements.step.no_description') %> + <% end %> +
+ <% if defined?(children) %> +
+ <%= children %> +
+ <% end %> +