fix(acl(js)): toggle rights from the ACL editor

pull/285/head
Francis Lachapelle 2020-07-15 09:56:06 -04:00
parent 704e7885ce
commit 825fb85903
4 changed files with 15 additions and 12 deletions

View File

@ -69,7 +69,7 @@
</md-item-template>
</md-autocomplete>
</div>
<md-card ng-repeat="user in acl.users track by user.uid | orderBy:['userClass', 'displayName']"
<md-card ng-repeat="user in acl.users | orderBy:['userClass', 'cn']"
class="sg-collapsed"
ng-class="{ 'sg-expanded': user.uid == acl.selectedUid }">
<a class="md-flex md-button" ng-click="acl.selectUser(user, $event)">
@ -84,7 +84,7 @@
<div class="sg-md-body"><div>{{user.c_email}}</div></div>
</div>
<md-button class="md-icon-button md-secondary" type="button"
ng-click="acl.selectAllRights(user)"
ng-click="acl.toggleAllRights(user)"
ng-hide="!acl.showRights(user) || user.$isSpecial()">
<md-icon>select_all</md-icon>
</md-button>

View File

@ -66,7 +66,7 @@
<div class="sg-md-body"><div ng-bind="::user.c_email"><!-- email --></div></div>
</div>
<md-button class="md-icon-button md-secondary" type="button"
ng-click="acl.selectAllRights(user)"
ng-click="acl.toggleAllRights(user)"
ng-hide="!acl.showRights(user) || user.$isSpecial()">
<md-icon>select_all</md-icon>
</md-button>

View File

@ -136,12 +136,15 @@
* @memberof Acl.prototype
* @desc Select all rights of an user
*/
Acl.prototype.$selectAllRights = function(user) {
_.forEach(user.rights, function(value, right) {
if (angular.isNumber(user.rights[right]))
user.rights[right] = 1;
else
user.rights[right] = "Modifier";
Acl.prototype.$toggleAllRights = function(user) {
var unselected = !angular.isUndefined(_.find(_.values(user.rights), function (right) {
return (right !== 1) && (right !== "Modifier");
}));
_.forEach(user.rights, function(value, right) {
if (angular.isNumber(user.rights[right]))
user.rights[right] = unselected ? 1 : 0;
else
user.rights[right] = unselected ? "Modifier" : "None";
});
};

View File

@ -24,7 +24,7 @@
vm.confirmChange = confirmChange;
vm.removeUser = removeUser;
vm.addUser = addUser;
vm.selectAllRights = selectAllRights;
vm.toggleAllRights = toggleAllRights;
vm.selectUser = selectUser;
vm.hasNoRight = hasNoRight;
vm.showRights = showRights;
@ -87,8 +87,8 @@
}
}
function selectAllRights(user) {
folder.$acl.$selectAllRights(user);
function toggleAllRights(user) {
folder.$acl.$toggleAllRights(user);
}
function selectUser(user, $event) {