Add automatic selection of permissions based on user rank
This commit is contained in:
parent
ce9d215098
commit
1f3e0243cf
|
@ -9,11 +9,11 @@ $('.group-all').change(function () {
|
||||||
|
|
||||||
$('input[type=checkbox]:not(.group-all)').change(function () {
|
$('input[type=checkbox]:not(.group-all)').change(function () {
|
||||||
const groupAll = $(this).parent().parent().prev('h4').find('.group-all');
|
const groupAll = $(this).parent().parent().prev('h4').find('.group-all');
|
||||||
if(!$(this).is(':checked')) {
|
if (!$(this).is(':checked')) {
|
||||||
groupAll.prop('checked', false);
|
groupAll.prop('checked', false);
|
||||||
} else {
|
} else {
|
||||||
const siblings = $(this).parent().siblings().find('input[type=checkbox]:not(:checked)');
|
const siblings = $(this).parent().siblings().find('input[type=checkbox]:not(:checked)');
|
||||||
if(siblings.length === 0) {
|
if (siblings.length === 0) {
|
||||||
groupAll.prop('checked', true);
|
groupAll.prop('checked', true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,33 @@ function checkSiblings() {
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const ranks = [1, 2, 3, 6, 7, 8, 9, 10];
|
||||||
|
const rankPresets = {
|
||||||
|
1: [],
|
||||||
|
2: ['user.disableAds'],
|
||||||
|
3: [],
|
||||||
|
6: ['blog.view', 'blog.create', 'blog.editOwn', 'dashboard.view'],
|
||||||
|
7: ['blog.edit', 'blog.deleteOwn', 'blog.delete', 'blog.createCategory', 'blog.publish', 'blog.publishNow', 'blog.publishSelf'],
|
||||||
|
8: ['blog.edit', 'blog.deleteOwn', 'blog.delete', 'blog.createCategory', 'blog.publish', 'blog.publishNow', 'blog.publishSelf', 'user.view', 'user.deletePost', 'user.warn', 'reports.receive', 'feedback.receive', 'feedback.reply', 'contact.view', 'contact.answer'],
|
||||||
|
9: ['blog.edit', 'blog.deleteOwn', 'blog.delete', 'blog.createCategory', 'blog.publish', 'blog.publishNow', 'blog.publishSelf', 'blog.deleteOwnFinally', 'blog.deleteFinally', 'projects.view', 'user.changeRank', 'user.editPermissions'],
|
||||||
|
10: ['projects.create', 'projects.editOwn', 'projects.edit', 'projects.deleteOwn', 'projects.delete', 'projects.deleteCategory', 'file.view', 'file.upload', 'file.uploadManually', 'file.delete', 'redirect.view', 'redirect.create', 'redirect.edit', 'redirect.delete', 'user.ban', 'user.viewDetails', 'dashboard.detailView'],
|
||||||
|
};
|
||||||
|
|
||||||
|
$('input[name=rank]').change(function () {
|
||||||
|
const activeRank = parseInt($(this).val());
|
||||||
|
|
||||||
|
$('.perm-box').prop('checked', false);
|
||||||
|
|
||||||
|
for (let rank of ranks) {
|
||||||
|
if (rank > activeRank)
|
||||||
|
break;
|
||||||
|
|
||||||
|
rankPresets[rank].forEach(perm => {
|
||||||
|
const el = $('#' + perm.replace('.', ''));
|
||||||
|
const value = !el.is(':checked');
|
||||||
|
el.prop('checked', value);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
Reference in New Issue
Block a user