Another attempt on fixing the user edit with roles business

This commit is contained in:
Johannes Zellner
2020-03-07 14:05:58 -08:00
parent e240ac1fa5
commit 385d275f59
2 changed files with 14 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.config = Client.getConfig();
$scope.userInfo = Client.getUserInfo();
// Order matters for permissions used in canEdit
$scope.roles = [
{ id: 'user', name: 'User', disabled: false },
{ id: 'usermanager', name: 'User Manager', disabled: true },
@@ -48,6 +49,13 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
return group.userIds.filter(function (uid) { return !!$scope.allUsersById[uid]; }).map(function (uid) { return $scope.allUsersById[uid].username || $scope.allUsersById[uid].email; }).join(' ');
};
$scope.canEdit = function (user) {
let roleInt1 = $scope.roles.findIndex(function (role) { return role.id === $scope.userInfo.role; });
let roleInt2 = $scope.roles.findIndex(function (role) { return role.id === user.role; });
return (roleInt1 - roleInt2) >= 0;
};
$scope.userremove = {
busy: false,
error: null,