Separate superuser checkbox from the other groups in user edit

This commit is contained in:
Johannes Zellner
2016-02-25 23:20:55 +01:00
parent 4fb89de34f
commit d430e902bf
2 changed files with 16 additions and 7 deletions

View File

@@ -117,15 +117,18 @@
</div>
<input type="email" class="form-control" ng-model="useredit.email" name="email" required>
</div>
<div class="form-group">
<label class="control-label">Superuser</label>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="useredit.superuser"> Allow this user to manage apps, groups and other users
</label>
</div>
</div>
<div class="form-group">
<label class="control-label">Groups</label>
<div>
<span>
<button class="btn btn-admin" type="button" ng-show="useredit.userInfo.id === userInfo.id" ng-click="showBubble($event)" data-toggle="tooltip" data-trigger="manual" title="Removing yourself from admin group is not allowed">Admin</button>
<button class="btn btn-default" type="button" ng-hide="useredit.userInfo.id === userInfo.id" ng-click="userEditToggleGroup({ id: 'admin', name: 'admin' })" ng-class="{ 'btn-admin': (useredit.groupIds.indexOf('admin') !== -1) }">Admin</button>
</span>
<span ng-repeat="group in groups" ng-show="group.id !== 'admin'">
<span ng-repeat="group in groups | ignoreAdminGroup" ng-show="group.id !== 'admin'">
<button class="btn btn-default" type="button" ng-click="userEditToggleGroup(group);" ng-class="{ 'btn-primary': (useredit.groupIds.indexOf(group.id) !== -1) }">{{ group.name }}</button>
</span>
</div>

View File

@@ -31,7 +31,8 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
error: {},
userInfo: {},
email: '',
displayName: ''
displayName: '',
superuser: false
};
$scope.showBubble = function ($event) {
@@ -236,6 +237,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.useredit.email = userInfo.email;
$scope.useredit.userInfo = userInfo;
$scope.useredit.groupIds = angular.copy(userInfo.groupIds);
$scope.useredit.superuser = userInfo.groupIds.indexOf('admin') !== -1;
$scope.useredit_form.$setPristine();
$scope.useredit_form.$setUntouched();
@@ -269,6 +271,9 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
return console.error('Unable to update user:', error);
}
if ($scope.useredit.superuser) $scope.useredit.groupIds.push('admin');
else $scope.useredit.groupIds = $scope.useredit.groupIds.filter(function (groupId) { return groupId !== 'admin'; });
Client.setGroups(data.id, $scope.useredit.groupIds, function (error) {
$scope.useredit.busy = false;
@@ -277,6 +282,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.useredit.userInfo = {};
$scope.useredit.email = '';
$scope.useredit.displayName = '';
$scope.useredit.superuser = false;
$scope.useredit.groupIds = [];
$scope.useredit_form.$setPristine();