diff --git a/app/assets/stylesheets/layouts/print_protocol.scss b/app/assets/stylesheets/layouts/print_protocol.scss index c6b8095d4..e6b0cce5b 100644 --- a/app/assets/stylesheets/layouts/print_protocol.scss +++ b/app/assets/stylesheets/layouts/print_protocol.scss @@ -1,3 +1,6 @@ +// scss-lint:disable SelectorDepth +// scss-lint:disable NestingDepth + @import "../shared_styles/constants/*"; @import "../constants"; @@ -108,7 +111,6 @@ hr { .print-table { table { border-collapse: collapse; - text-align: center; width: 100%; &, @@ -128,6 +130,34 @@ hr { td { padding: .15em .3em; + + &.htLeft { + text-align: left; + } + + &.htCenter { + text-align: center; + } + + &.htRight { + text-align: right; + } + + &.htJustify { + text-align: justify; + } + + &.htTop { + vertical-align: top; + } + + &.htMiddle { + vertical-align: middle; + } + + &.htBottom { + vertical-align: bottom; + } } } } diff --git a/app/views/layouts/protocols/print.html.erb b/app/views/layouts/protocols/print.html.erb index 36cd118a8..e591d7dfa 100644 --- a/app/views/layouts/protocols/print.html.erb +++ b/app/views/layouts/protocols/print.html.erb @@ -14,6 +14,7 @@ $("[data-role='hot-table']").each(function() { var $container = $(this).find("[data-role='step-hot-table']"); var contents = $(this).find('.hot-contents'); + var metadata = $(this).find('.hot-metadata'); $container.handsontable({ startRows: <%= Constants::HANDSONTABLE_INIT_ROWS_CNT %>, @@ -22,17 +23,15 @@ colHeaders: true, fillHandle: false, formulas: true, + data: JSON.parse(contents.attr('value')).data, + cell: JSON.parse(metadata.val() || '{}').cells || [], readOnly: true }); var hot = $container.handsontable('getInstance'); - if (contents.attr("value")) { - var data = JSON.parse(contents.attr("value")); - if (Array.isArray(data.data)) hot.loadData(data.data); - setTimeout(() => { - hot.render() - }, 0) - } + setTimeout(() => { + hot.render() + }, 500) }); window.print(); diff --git a/app/views/protocols/print.html.erb b/app/views/protocols/print.html.erb index 5845bb01c..b8b7c561b 100644 --- a/app/views/protocols/print.html.erb +++ b/app/views/protocols/print.html.erb @@ -52,6 +52,7 @@
<%= hidden_field(table, :contents, value: table.contents_utf_8, class: "hot-contents") %> + <%= hidden_field(table, :metadata, value: table.metadata ? table.metadata.to_json : nil, class: "hot-metadata" ) %>