it: формы добавления оборудования и выполненной работы в popup.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -20,22 +20,45 @@ function itToggleRow(key) {
|
||||
if (toggle) toggle.style.transform = opening ? 'rotate(90deg)' : '';
|
||||
}
|
||||
|
||||
function itIsModal(panel) {
|
||||
return panel && panel.getAttribute('role') === 'dialog';
|
||||
}
|
||||
|
||||
function itPanelOpen(id) {
|
||||
var panel = document.getElementById(id);
|
||||
if (!panel) return;
|
||||
if (itIsModal(panel)) {
|
||||
panel.style.display = 'flex';
|
||||
document.body.style.overflow = 'hidden';
|
||||
if (typeof initSearchableSelects === 'function') initSearchableSelects(panel);
|
||||
return;
|
||||
}
|
||||
var overlay = document.getElementById(id + '-overlay');
|
||||
if (overlay) overlay.style.display = 'block';
|
||||
if (panel) panel.style.transform = 'translateX(0)';
|
||||
panel.style.transform = 'translateX(0)';
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
|
||||
function itPanelClose(id) {
|
||||
var panel = document.getElementById(id);
|
||||
if (!panel) return;
|
||||
if (itIsModal(panel)) {
|
||||
panel.style.display = 'none';
|
||||
document.body.style.overflow = '';
|
||||
return;
|
||||
}
|
||||
var overlay = document.getElementById(id + '-overlay');
|
||||
if (overlay) overlay.style.display = 'none';
|
||||
if (panel) panel.style.transform = 'translateX(100%)';
|
||||
panel.style.transform = 'translateX(100%)';
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
function itModalsInit(root) {
|
||||
if (!root) return;
|
||||
if (root.getAttribute('data-it-equipment-open') === '1') itPanelOpen('it-equipment-panel');
|
||||
if (root.getAttribute('data-it-worklog-open') === '1') itPanelOpen('it-worklog-panel');
|
||||
}
|
||||
|
||||
function itContractServiceToggle(serviceTypeCode) {
|
||||
var block = document.getElementById('it-contract-ip-block');
|
||||
if (!block) return;
|
||||
@@ -413,19 +436,38 @@ function itReportPreviewClose() {
|
||||
|
||||
document.addEventListener('keydown', function (ev) {
|
||||
if (ev.key !== 'Escape') return;
|
||||
var modal = document.getElementById('it-report-preview-modal');
|
||||
if (modal && modal.style.display === 'flex') itReportPreviewClose();
|
||||
var preview = document.getElementById('it-report-preview-modal');
|
||||
if (preview && preview.style.display === 'flex') {
|
||||
itReportPreviewClose();
|
||||
return;
|
||||
}
|
||||
['it-equipment-panel', 'it-worklog-panel'].forEach(function (id) {
|
||||
var el = document.getElementById(id);
|
||||
if (el && el.style.display === 'flex') itPanelClose(id);
|
||||
});
|
||||
});
|
||||
|
||||
function itPageAfterLoad(scope) {
|
||||
var root = (scope || document).querySelector('[data-it-active-tab]');
|
||||
if (!root) return;
|
||||
if (typeof itTabSwitch === 'function') {
|
||||
itTabSwitch(root.getAttribute('data-it-active-tab') || 'equipment');
|
||||
}
|
||||
if (typeof initSearchableSelects === 'function') {
|
||||
initSearchableSelects(scope || document);
|
||||
}
|
||||
itModalsInit(root);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function () { itPageAfterLoad(document); });
|
||||
} else {
|
||||
itPageAfterLoad(document);
|
||||
}
|
||||
|
||||
document.addEventListener('htmx:afterSwap', function (ev) {
|
||||
var target = ev.detail && ev.detail.target;
|
||||
if (!target || target.id !== 'main-content') return;
|
||||
var root = target.querySelector('[data-it-active-tab]');
|
||||
if (root && typeof itTabSwitch === 'function') {
|
||||
itTabSwitch(root.getAttribute('data-it-active-tab') || 'equipment');
|
||||
}
|
||||
if (typeof initSearchableSelects === 'function') {
|
||||
initSearchableSelects(target);
|
||||
}
|
||||
itPageAfterLoad(target);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user