mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 01:03:18 +08:00
Add handson table metadata to print protocol [SCI-7914] (#4957)
This commit is contained in:
parent
03631d28aa
commit
7e48ce70c9
3 changed files with 38 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue