Fix user select in group add/edit dialogs

We have to depend on all users not just the paginated ones
The selection does not need all information from the user so we are good
This commit is contained in:
Johannes Zellner
2020-01-09 16:21:20 +01:00
parent 42066e20ed
commit 36b8b0e6a1

View File

@@ -19,7 +19,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.ready = false;
$scope.users = [];
$scope.usersById = [];
$scope.allUsersById = [];
$scope.groups = [];
$scope.groupsById = { };
$scope.config = Client.getConfig();
@@ -38,7 +38,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.userRefreshBusy = true;
$scope.groupMembers = function (group) {
return group.userIds.filter(function (uid) { return !!$scope.usersById[uid]; }).map(function (uid) { return $scope.usersById[uid].username || $scope.usersById[uid].email; }).join(' ');
return group.userIds.filter(function (uid) { return !!$scope.allUsersById[uid]; }).map(function (uid) { return $scope.allUsersById[uid].username || $scope.allUsersById[uid].email; }).join(' ');
};
$scope.userremove = {
@@ -314,7 +314,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.groupEdit.error = {};
$scope.groupEdit.groupInfo = groupInfo;
$scope.groupEdit.name = groupInfo.name;
$scope.groupEdit.selectedUsers = groupInfo.userIds.map(function (uid) { return $scope.usersById[uid]; });
$scope.groupEdit.selectedUsers = groupInfo.userIds.map(function (uid) { return $scope.allUsersById[uid]; });
$scope.groupEdit_form.$setPristine();
$scope.groupEdit_form.$setUntouched();
@@ -614,10 +614,6 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
if (error) return console.error('Unable to get user listing.', error);
angular.copy(result, $scope.users);
$scope.usersById = { };
for (var i = 0; i < result.length; i++) {
$scope.usersById[result[i].id] = result[i];
}
$scope.ready = true;
$scope.userRefreshBusy = false;
@@ -672,6 +668,11 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
if (error) return console.error(error);
$scope.allUsers = results;
$scope.allUsersById = {};
for (var i = 0; i < results.length; i++) {
$scope.allUsersById[results[i].id] = results[i];
}
});
});