Make groups a multiselect

With many groups, it overflows and very cluttered
This commit is contained in:
Girish Ramakrishnan
2018-07-24 21:36:50 -07:00
parent 46473c3756
commit dec1931f07
2 changed files with 11 additions and 19 deletions
+8 -14
View File
@@ -154,6 +154,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
aliases: {},
displayName: '',
superuser: false,
selectedGroups: [],
show: function (userInfo) {
$scope.useredit.error = {};
@@ -161,7 +162,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.useredit.displayName = userInfo.displayName;
$scope.useredit.fallbackEmail = userInfo.fallbackEmail;
$scope.useredit.userInfo = userInfo;
$scope.useredit.groupIds = angular.copy(userInfo.groupIds);
$scope.useredit.selectedGroups = userInfo.groupIds.map(function (gid) { return $scope.groupsById[gid]; });
$scope.useredit.superuser = userInfo.groupIds.indexOf('admin') !== -1;
$scope.useredit_form.$setPristine();
@@ -170,15 +171,6 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$('#userEditModal').modal('show');
},
toggleGroup: function (group) {
var pos = $scope.useredit.groupIds.indexOf(group.id);
if (pos === -1) {
$scope.useredit.groupIds.push(group.id);
} else {
$scope.useredit.groupIds.splice(pos, 1);
}
},
submit: function () {
$scope.useredit.error = {};
$scope.useredit.busy = true;
@@ -206,13 +198,15 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
return;
}
var groupIds = $scope.useredit.selectedGroups.map(function (g) { return g.id; });
if ($scope.useredit.superuser) {
if ($scope.useredit.groupIds.indexOf('admin') === -1) $scope.useredit.groupIds.push('admin');
if (groupIds.indexOf('admin') === -1) groupIds.push('admin');
} else {
$scope.useredit.groupIds = $scope.useredit.groupIds.filter(function (groupId) { return groupId !== 'admin'; });
groupIds = groupIds.filter(function (groupId) { return groupId !== 'admin'; });
}
Client.setGroups(data.id, $scope.useredit.groupIds, function (error) {
Client.setGroups(data.id, groupIds, function (error) {
if (error) return console.error('Unable to update groups for user:', error);
$scope.useredit.busy = false;
@@ -220,7 +214,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.useredit.email = '';
$scope.useredit.displayName = '';
$scope.useredit.superuser = false;
$scope.useredit.groupIds = [];
$scope.useredit.groups = [];
$scope.useredit_form.$setPristine();
$scope.useredit_form.$setUntouched();