scinote-web/app/assets/javascripts/protocols/handson.js
Soufiane 1b34de37ef
CSP and inline js refactor [SCI-8118][SCI-8119] (#5206)
CSP and inline js refactor [SCI-8118][SCI-8119]
2023-05-03 11:31:17 +02:00

32 lines
961 B
JavaScript

(function() {
const handsontableInitDataElem = $('#handson');
const HANDSONTABLE_INIT_ROWS_CNT = handsontableInitDataElem.data('init-rows-cnt');
const HANDSONTABLE_INIT_COLS_CNT = handsontableInitDataElem.data('init-cols-cnt');
$("[data-role='hot-table']").each(function() {
var hot;
var $container = $(this).find("[data-role='step-hot-table']");
var contents = $(this).find('.hot-contents');
var metadata = $(this).find('.hot-metadata');
$container.handsontable({
startRows: HANDSONTABLE_INIT_ROWS_CNT,
startCols: HANDSONTABLE_INIT_COLS_CNT,
rowHeaders: true,
colHeaders: true,
fillHandle: false,
formulas: true,
data: JSON.parse(contents.attr('value')).data,
cell: JSON.parse(metadata.val() || '{}').cells || [],
readOnly: true
});
hot = $container.handsontable('getInstance');
setTimeout(() => {
hot.render();
}, 500);
});
window.print();
}());