it: не дублировать списки аптек и сотрудников в каждом ряду оборудования.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-13 13:23:47 +03:00
parent 4e1d5f221e
commit 87bb98d097
5 changed files with 99 additions and 18 deletions
+37
View File
@@ -11,6 +11,39 @@ function itTabSwitch(tab) {
});
}
function itFillAssignOptions(root) {
if (!root || root.getAttribute('data-it-options-filled') === '1') return;
['pharmacy', 'office', 'employee'].forEach(function (kind) {
var src = document.getElementById('it-options-' + kind);
if (!src) return;
root.querySelectorAll('select[data-it-options="' + kind + '"]').forEach(function (sel) {
if (sel.getAttribute('data-it-options-ready') === '1') return;
var current = sel.value;
var currentLabel = '';
var curOpt = sel.options[sel.selectedIndex];
if (curOpt && curOpt.value) currentLabel = curOpt.textContent;
var empty = sel.querySelector('option[value=""]');
sel.innerHTML = '';
if (empty) sel.appendChild(empty);
Array.prototype.forEach.call(src.options, function (opt) {
sel.appendChild(opt.cloneNode(true));
});
if (current) {
sel.value = current;
if (sel.value !== current) {
var extra = document.createElement('option');
extra.value = current;
extra.textContent = currentLabel || current;
extra.selected = true;
sel.appendChild(extra);
}
}
sel.setAttribute('data-it-options-ready', '1');
});
});
root.setAttribute('data-it-options-filled', '1');
}
function itToggleRow(key) {
var row = document.getElementById('it-row-' + key);
var toggle = document.getElementById('it-toggle-' + key);
@@ -18,6 +51,10 @@ function itToggleRow(key) {
var opening = row.style.display === 'none';
row.style.display = opening ? 'table-row' : 'none';
if (toggle) toggle.style.transform = opening ? 'rotate(90deg)' : '';
if (opening) {
itFillAssignOptions(row);
if (typeof initSearchableSelects === 'function') initSearchableSelects(row);
}
}
function itIsModal(panel) {
+2
View File
@@ -196,6 +196,8 @@
window.initSearchableSelects = function (scope) {
(scope || document).querySelectorAll('.searchable-select:not([data-searchable-init])').forEach(function (widget) {
var hiddenRow = widget.closest('.it-detail-row');
if (hiddenRow && hiddenRow.style.display === 'none') return;
widget.setAttribute('data-searchable-init', '1');
build(widget);
});