ae54d93442
Section-based portal access, matrix прав по группам, аккаунтинг-портал, управление группами пользователей, справочники, дашборд и общий каркас навигации/стилей. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
/**
|
|
* Сводная таблица доступа: вкл/выкл CUD при смене «Просмотр».
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
function bindMatrix() {
|
|
document.querySelectorAll('.access-matrix-row').forEach(function (row) {
|
|
if (row.getAttribute('data-bound') === '1') return;
|
|
var sel = row.querySelector('.access-view-select');
|
|
var cud = row.querySelector('.access-cud');
|
|
if (!sel || !cud) return;
|
|
row.setAttribute('data-bound', '1');
|
|
|
|
function sync(fromChange) {
|
|
var on = sel.value === '1';
|
|
cud.style.opacity = on ? '1' : '0.45';
|
|
cud.style.pointerEvents = on ? '' : 'none';
|
|
if (on && fromChange) {
|
|
cud.querySelectorAll('input[type=checkbox]').forEach(function (cb) {
|
|
if (!cb.dataset.touched) cb.checked = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
cud.querySelectorAll('input[type=checkbox]').forEach(function (cb) {
|
|
cb.addEventListener('change', function () { cb.dataset.touched = '1'; });
|
|
});
|
|
sel.addEventListener('change', function () { sync(true); });
|
|
sync(false);
|
|
});
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', bindMatrix);
|
|
document.addEventListener('htmx:afterSwap', bindMatrix);
|
|
document.addEventListener('htmx:afterSettle', bindMatrix);
|
|
})();
|