Release v2.5.6

This commit is contained in:
2026-08-05 19:38:16 +01:00
parent a8ef35b287
commit 9f831f04bc
161 changed files with 8487 additions and 1295 deletions
+82 -12
View File
@@ -1,8 +1,16 @@
// RBAC permission matrix helpers for checkbox groups.
(function () {
function getGroupCheckboxes(group) {
return Array.prototype.slice.call(group.querySelectorAll('input[name="permission_keys[]"]'));
function getPermissionSections() {
return Array.prototype.slice.call(document.querySelectorAll('[data-permission-section]'));
}
function getPermissionRows(container) {
return Array.prototype.slice.call(container.querySelectorAll('[data-permission-row]'));
}
function getRowCheckboxes(row) {
return Array.prototype.slice.call(row.querySelectorAll('input[name="permission_keys[]"]'));
}
function getPermissionKey(checkbox) {
@@ -19,8 +27,12 @@
return String(parts[1] || '').trim().toLowerCase();
}
function syncPermissionGroup(group) {
var checkboxes = getGroupCheckboxes(group);
function syncPermissionRow(row) {
if (!row) {
return;
}
var checkboxes = getRowCheckboxes(row);
if (!checkboxes.length) {
return;
}
@@ -55,19 +67,57 @@
}
}
function handleGroupChange(event) {
function setRowCheckboxes(row, checked) {
if (!row) {
return;
}
var checkboxes = getRowCheckboxes(row);
if (!checkboxes.length) {
return;
}
checkboxes.forEach(function (checkbox) {
checkbox.checked = Boolean(checked);
});
syncPermissionRow(row);
}
function toggleRowCheckboxes(row) {
if (!row) {
return;
}
var checkboxes = getRowCheckboxes(row);
if (!checkboxes.length) {
return;
}
var allChecked = checkboxes.every(function (checkbox) {
return Boolean(checkbox.checked);
});
setRowCheckboxes(row, !allChecked);
}
function findPermissionRow(targetId) {
return document.querySelector('[data-permission-row-id="' + targetId + '"]');
}
function handleRowChange(event) {
var checkbox = event.target && event.target.matches ? event.target : null;
if (!checkbox || checkbox.tagName !== 'INPUT' || checkbox.type !== 'checkbox') {
return;
}
var actionKey = getActionKey(checkbox);
var group = checkbox.closest('.accordion-item');
if (!group) {
var row = checkbox.closest('[data-permission-row]');
if (!row) {
return;
}
var checkboxes = getGroupCheckboxes(group);
var checkboxes = getRowCheckboxes(row);
var readCheckbox = checkboxes.find(function (candidate) {
return getActionKey(candidate) === 'read';
}) || null;
@@ -91,8 +141,28 @@
}
function initPermissionGroups() {
document.querySelectorAll('.accordion-item').forEach(function (group) {
syncPermissionGroup(group);
getPermissionSections().forEach(function (section) {
getPermissionRows(section).forEach(function (row) {
syncPermissionRow(row);
});
});
document.addEventListener('click', function (event) {
var control = event.target && event.target.closest ? event.target.closest('[data-permission-row-toggle]') : null;
if (!control) {
return;
}
event.preventDefault();
var targetId = String(control.getAttribute('data-permission-row-target') || '').trim();
if (!targetId) {
return;
}
if (control.hasAttribute('data-permission-row-toggle')) {
toggleRowCheckboxes(findPermissionRow(targetId));
}
});
document.addEventListener('change', function (event) {
@@ -104,8 +174,8 @@
return;
}
handleGroupChange(event);
syncPermissionGroup(checkbox.closest('.accordion-item'));
handleRowChange(event);
syncPermissionRow(checkbox.closest('[data-permission-row]'));
});
}