finally closed #2887 -- added implicit privilege markers to client-side privileges table

This commit is contained in:
Julian Lam
2015-04-20 16:58:44 -04:00
parent 5a0ea28633
commit 9e994f3baf
3 changed files with 34 additions and 3 deletions

View File

@@ -203,7 +203,9 @@ define('admin/manage/category', [
} else { } else {
app.alertError('[[error:invalid-data]]'); app.alertError('[[error:invalid-data]]');
} }
}) });
Category.exposeAssumedPrivileges();
}; };
Category.refreshPrivilegeTable = function() { Category.refreshPrivilegeTable = function() {
@@ -216,10 +218,33 @@ define('admin/manage/category', [
privileges: privileges privileges: privileges
}, function(html) { }, function(html) {
$('.privilege-table-container').html(html); $('.privilege-table-container').html(html);
Category.exposeAssumedPrivileges();
}); });
}); });
}; };
Category.exposeAssumedPrivileges = function() {
/*
If registered-users has a privilege enabled, then all users and groups of that privilege
should be assumed to have that privilege as well, even if not set in the db, so reflect
this arrangement in the table
*/
var privs = [];
$('.privilege-table tr[data-group-name="registered-users"] td input[type="checkbox"]').parent().each(function(idx, el) {
if ($(el).find('input').prop('checked')) {
privs.push(el.getAttribute('data-privilege'));
}
});
for(var x=0,numPrivs=privs.length;x<numPrivs;x++) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
inputs.each(function(idx, el) {
if (!el.checked) {
el.indeterminate = true;
}
});
}
};
Category.setPrivilege = function(member, privilege, state, checkboxEl) { Category.setPrivilege = function(member, privilege, state, checkboxEl) {
socket.emit('admin.categories.setPrivilege', { socket.emit('admin.categories.setPrivilege', {
cid: ajaxify.variables.get('cid'), cid: ajaxify.variables.get('cid'),

View File

@@ -1,7 +1,7 @@
<div class="row"> <div class="row">
<div class="col-lg-9"> <div class="col-lg-9">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div> <div class="panel-heading"><i class="fa fa-folder"></i> Active Categories</div>
<div class="panel-body"> <div class="panel-body">
<table class="table table-striped table-hover table-reordering"> <table class="table table-striped table-hover table-reordering">
<thead> <thead>
@@ -55,7 +55,7 @@
</div> </div>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div> <div class="panel-heading"><i class="fa fa-folder"></i> Disabled Categories</div>
<div class="panel-body"> <div class="panel-body">
<table class="table table-striped table-hover table-reordering"> <table class="table table-striped table-hover table-reordering">
<thead> <thead>

View File

@@ -42,4 +42,10 @@
</tr> </tr>
<!-- END privileges.groups --> <!-- END privileges.groups -->
</table> </table>
<div class="help-block">
If the <code>registered-users</code> group is granted a specific privilege, all other groups receive an
<strong>implicit privilege</strong>, even if they are not explicitly defined/checked. This implicit
privilege is shown to you because all users are part of the <code>registered-users</code> user group,
and so, privileges for additional groups need not be explicitly granted.
</div>
</div> </div>