Add handson table metadata to print protocol [SCI-7914] (#4957)

This commit is contained in:
ajugo 2023-02-14 11:15:42 +01:00 committed by GitHub
parent 03631d28aa
commit 7e48ce70c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 8 deletions

View file

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

View file

@ -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();

View file

@ -52,6 +52,7 @@
<div class="page-break"></div>
<div data-role="hot-table" class="hot-table">
<%= 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" ) %>
<div data-role="step-hot-table" class="step-result-hot-table"></div>
</div>
</div>