38471-vm/pages/users_role_permissions_script.php
2026-05-03 04:30:55 +00:00

36 lines
1.5 KiB
PHP

<script>
$(document).ready(function() {
// Select All by Action (View, Add, Edit, Delete)
$('.select-all-action').on('change', function() {
const action = $(this).data('action');
const checked = $(this).is(':checked');
const modal = $(this).closest('.modal');
modal.find('.perm-check[data-action="' + action + '"]').prop('checked', checked);
});
// Select All by Row
$('.select-all-row').on('change', function() {
const checked = $(this).is(':checked');
$(this).closest('.module-row').find('.perm-check').prop('checked', checked);
});
// Select All by Group
$('.select-all-group').on('change', function() {
const checked = $(this).is(':checked');
$(this).closest('.permission-group-container').find('.perm-check, .select-all-row').prop('checked', checked);
});
// Select All Button
$('.select-all-btn').on('click', function() {
const modal = $($(this).data('modal'));
modal.find('.perm-check, .select-all-action, .select-all-group, .select-all-row').prop('checked', true);
});
// Deselect All Button
$('.deselect-all-btn').on('click', function() {
const modal = $($(this).data('modal'));
modal.find('.perm-check, .select-all-action, .select-all-group, .select-all-row').prop('checked', false);
});
});
</script>