2023-08-07 16:45:52 +08:00
|
|
|
/* global tableColRowName notTurbolinksPreview */
|
2023-07-11 22:01:42 +08:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function initWelcomeModal() {
|
|
|
|
$('#shareable-link-welcome-modal').modal('show');
|
|
|
|
}
|
|
|
|
|
2023-07-26 21:19:32 +08:00
|
|
|
function initStepsExpandCollapse() {
|
2023-08-07 16:45:52 +08:00
|
|
|
$(document).on('click', '#steps-collapse-btn', function() {
|
|
|
|
$('.step-container .collapse').collapse('hide');
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click', '#steps-expand-btn', function() {
|
|
|
|
$('.step-container .collapse').collapse('show');
|
2023-07-26 21:19:32 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initStepComments() {
|
|
|
|
$(document).on('click', '.shareable-link-open-comments-sidebar', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('.comments-sidebar').removeClass('open');
|
|
|
|
|
|
|
|
$($(this).data('objectTarget')).addClass('open');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initStepAttachments() {
|
|
|
|
$(document).on('click', '.shareable-file-preview-link, .shareable-gallery-switcher', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('.modal-file-preview.in').modal('hide');
|
|
|
|
$($(`.modal-file-preview[data-object-id=${$(this).data('id')}]`)).modal('show');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initializeHandsonTable(el) {
|
|
|
|
var input = el.siblings('input.hot-table-contents');
|
|
|
|
var inputObj = JSON.parse(input.attr('value'));
|
|
|
|
var data = inputObj.data;
|
2024-01-11 00:28:14 +08:00
|
|
|
const metadata = JSON.parse(el.siblings('input.hot-table-metadata').val() || '{}');
|
2023-07-26 21:19:32 +08:00
|
|
|
|
|
|
|
el.handsontable({
|
|
|
|
disableVisualSelection: true,
|
|
|
|
rowHeaders: tableColRowName.tableRowHeaders(metadata.plateTemplate),
|
|
|
|
colHeaders: tableColRowName.tableColHeaders(metadata.plateTemplate),
|
|
|
|
editor: false,
|
|
|
|
copyPaste: false,
|
|
|
|
formulas: true,
|
|
|
|
data: data,
|
|
|
|
cell: metadata.cells || []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMyModuleProtocolShow() {
|
2023-08-22 18:21:05 +08:00
|
|
|
const myModule = $('#details-container').attr('data-shareable-link');
|
2023-08-18 19:58:39 +08:00
|
|
|
if (!sessionStorage.getItem(`my_module_shareable_link_${myModule}`)) {
|
|
|
|
sessionStorage.setItem(`my_module_shareable_link_${myModule}`, myModule);
|
|
|
|
initWelcomeModal();
|
|
|
|
}
|
2023-07-26 21:19:32 +08:00
|
|
|
initStepsExpandCollapse();
|
|
|
|
initStepComments();
|
|
|
|
initStepAttachments();
|
|
|
|
|
|
|
|
$('.hot-table-container').each(function() {
|
|
|
|
initializeHandsonTable($(this));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-07 16:45:52 +08:00
|
|
|
if (notTurbolinksPreview()) {
|
|
|
|
initMyModuleProtocolShow();
|
|
|
|
}
|
2023-07-11 22:01:42 +08:00
|
|
|
}());
|