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

This commit is contained in:
Francis Lachapelle
2020-07-15 09:56:06 -04:00
parent 704e7885ce
commit 825fb85903
4 changed files with 15 additions and 12 deletions
@@ -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";
});
};
@@ -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) {