From 3f7f576b29a86403200609ba595e6afdb9cbf3a2 Mon Sep 17 00:00:00 2001
From: artoscinote <85488244+artoscinote@users.noreply.github.com>
Date: Fri, 3 Dec 2021 13:44:18 +0100
Subject: [PATCH] Print protocol fixes [SCI-6318] (#3717)
* Fix smart annotations [SCI-6318]
* Fix asset rendering [SCI-6316, SCI-6417]
* Copy fix [SCI-6315]
* Fix print protocol name handling [SCI-6318]
* CSS linter fixes
* Add support for handson tables [SCI-6318]
* Use partial for handsontable formulas [SCI-6318]
---
app/assets/stylesheets/print_protocol.scss | 44 ++++++++--
app/views/layouts/protocols/print.html.erb | 27 ++++++
.../protocols/_print_protocol_button.html.erb | 2 +-
app/views/protocols/print.html.erb | 84 +++++++++++--------
4 files changed, 116 insertions(+), 41 deletions(-)
diff --git a/app/assets/stylesheets/print_protocol.scss b/app/assets/stylesheets/print_protocol.scss
index 7e0330d49..e555fc68f 100644
--- a/app/assets/stylesheets/print_protocol.scss
+++ b/app/assets/stylesheets/print_protocol.scss
@@ -6,6 +6,11 @@
margin: 8mm;
}
+.page-break {
+ clear: both;
+ page-break-after: always;
+}
+
body {
font-family: Lato, "Open Sans", Arial, Helvetica, sans-serif;
font-size: 16px;
@@ -89,7 +94,7 @@ hr {
}
}
-.print-table {
+table {
border-collapse: collapse;
text-align: center;
width: 100%;
@@ -122,8 +127,20 @@ hr {
}
&.thumbnail {
- float: left;
- padding: 1em;
+ align-items: flex-end;
+ display: flex;
+ justify-content: center;
+ padding: 1em 1em 0;
+ text-align: center;
+ width: 15%;
+
+ img {
+ max-width: 100%;
+ }
+
+ .print-asset-image {
+ flex-basis: .25;
+ }
}
&.thumbnail,
@@ -146,8 +163,10 @@ hr {
}
.print-thumbnails {
- clear: both;
- overflow: hidden;
+ align-items: stretch;
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: left;
}
.print-asset-icon {
@@ -189,3 +208,18 @@ hr {
font-size: .8em;
text-align: right;
}
+
+.global-avatar-container.smart-annotation {
+ img {
+ margin-right: .2em;
+ vertical-align: middle;
+ width: 1.2em;
+ }
+}
+
+.ht_clone_top,
+.ht_clone_bottom,
+.ht_clone_left,
+.ht_clone_top_left_corner {
+ display: none;
+}
diff --git a/app/views/layouts/protocols/print.html.erb b/app/views/layouts/protocols/print.html.erb
index 1e6f38d0c..8abc34352 100644
--- a/app/views/layouts/protocols/print.html.erb
+++ b/app/views/layouts/protocols/print.html.erb
@@ -3,10 +3,37 @@
<%= t("protocols.print.title") %>
+ <%= javascript_include_tag 'application' %>
+ <%= javascript_include_tag "handsontable.full" %>
+ <%= render 'shared/formulas_libraries' %>
<%= stylesheet_link_tag 'print_protocol', media: 'print, screen' %>
<%= yield %>
diff --git a/app/views/my_modules/protocols/_print_protocol_button.html.erb b/app/views/my_modules/protocols/_print_protocol_button.html.erb
index 766342a87..72cc51b6d 100644
--- a/app/views/my_modules/protocols/_print_protocol_button.html.erb
+++ b/app/views/my_modules/protocols/_print_protocol_button.html.erb
@@ -26,7 +26,7 @@
diff --git a/app/views/protocols/print.html.erb b/app/views/protocols/print.html.erb
index 073700253..0338702ce 100644
--- a/app/views/protocols/print.html.erb
+++ b/app/views/protocols/print.html.erb
@@ -6,8 +6,17 @@
<%= t('.header.print_info', datetime: l(DateTime.current, format: :full), full_name: current_user.full_name) %>
-<%= @protocol.name || @protocol.my_module.name %>
-<%= @protocol.description.html_safe %>
+<%= @protocol.linked? ? protocol_name(@protocol.parent) : @protocol.name || @protocol.my_module.name %>
+
+ <% if @protocol.description.present? %>
+ <%= custom_auto_link(@protocol.tinymce_render(:description),
+ simple_format: false,
+ tags: %w(img),
+ team: current_team) %>
+ <% else %>
+ <%= t('my_modules.protocols.protocol_status_bar.no_description') %>
+ <% end %>
+
<% @protocol.steps.order(position: :asc).each do |step| %>
@@ -16,11 +25,22 @@
<%= step.position + 1 %>. <%= step.name %>
- <%= step.description.html_safe %>
+
+ <% if step.description.blank? %>
+
<%= t('protocols.steps.no_description') %>
+ <% else %>
+
+ <%= custom_auto_link(step.tinymce_render(:description),
+ simple_format: false,
+ tags: %w(img),
+ team: current_team) %>
+
+ <% end %>
+
<% step.checklists.each do |checklist| %>
-
<%= checklist.name %>
+
<%= smart_annotation_parser(checklist.name, current_team).html_safe %>
<% checklist.checklist_items.order(position: :asc).each do |checklist_item| %>
@@ -28,58 +48,51 @@
✓
<% end %>
- <%= checklist_item.text %>
+ <%= smart_annotation_parser(checklist_item.text, current_team).html_safe %>
<% end %>
<% end %>
<% step.tables.each do |table| %>
- <% table_data = JSON.parse(table.contents)["data"] %>
- <%= table.name %>
-
-
-
- |
- <% col = "A" %>
- <% table_data[0].length.times do %>
- <%= col %> |
- <% col.succ! %>
- <% end %>
-
-
-
- <% table_data.each_with_index do |tr, row| %>
-
- <%= row + 1 %> |
- <% tr.each do |td| %>
- <%= td %> |
- <% end %>
-
- <% end %>
-
-
+
+ <%= auto_link(simple_format(table.name),
+ link: :urls,
+ html: { target: '_blank' }) %>
+
+
+
+
+ <%= hidden_field(table, :contents, value: table.contents_utf_8, class: "hot-contents") %>
+
+
+
<% end %>
<% step.assets.where(view_mode: "inline").each do |asset| %>
- <%= image_tag asset.blob.url %>
-
<%= asset.blob.filename %>
+ <% if asset.previewable? %>
+ <%= image_tag asset.large_preview %>
+ <% end %>
+
<%= asset.render_file_name %>
+
<% end %>
<% step.assets.where(view_mode: "list").each do |asset| %>
<%= file_extension_icon_html(asset) %>
- <%= asset.blob.filename %>
+ <%= asset.render_file_name %>
<% end %>
<% step.assets.where(view_mode: "thumbnail").each do |asset| %>
- <%= image_tag asset.blob.representation(resize_to_limit: Constants::MEDIUM_PIC_FORMAT).processed %>
-
<%= asset.blob.filename %>
+ <% if asset.previewable? %>
+ <%= image_tag asset.blob.representation(resize_to_limit: Constants::MEDIUM_PIC_FORMAT).processed %>
+ <% end %>
+
<%= asset.render_file_name %>
<% end %>
@@ -99,7 +112,7 @@
+ <% end %>