2018-12-26 17:19:28 +00:00
|
|
|
$('.group-all').change(function () {
|
|
|
|
const v = $(this).is(':checked');
|
|
|
|
|
|
|
|
const items = $(this).parent().next('ul').children();
|
|
|
|
items.each(function () {
|
|
|
|
$(this).find('input[type=checkbox]').prop('checked', v);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('input[type=checkbox]:not(.group-all)').change(function () {
|
|
|
|
const groupAll = $(this).parent().parent().prev('h4').find('.group-all');
|
2018-12-30 17:45:38 +00:00
|
|
|
if (!$(this).is(':checked')) {
|
2018-12-26 17:19:28 +00:00
|
|
|
groupAll.prop('checked', false);
|
|
|
|
} else {
|
|
|
|
const siblings = $(this).parent().siblings().find('input[type=checkbox]:not(:checked)');
|
2018-12-30 17:45:38 +00:00
|
|
|
if (siblings.length === 0) {
|
2018-12-26 17:19:28 +00:00
|
|
|
groupAll.prop('checked', true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function checkSiblings() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
2018-12-30 17:45:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
2018-12-26 17:19:28 +00:00
|
|
|
});
|