[KEYCLOAK-10018] Adding sorting of groups by name in UI
This commit is contained in:
parent
cc6c89325c
commit
ed4af9baba
1 changed files with 17 additions and 2 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
function sortGroups(prop, arr) {
|
||||||
|
// sort current elements
|
||||||
|
arr.sort(function (a, b) {
|
||||||
|
if (a[prop] < b[prop]) { return -1; }
|
||||||
|
if (a[prop] > b[prop]) { return 1; }
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
// check sub groups
|
||||||
|
arr.forEach(function (item, index) {
|
||||||
|
if (!!item.subGroups) {
|
||||||
|
sortGroups(prop, item.subGroups);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return arr;
|
||||||
|
};
|
||||||
|
|
||||||
module.controller('GroupListCtrl', function($scope, $route, $q, realm, Groups, GroupsCount, Group, GroupChildren, Notifications, $location, Dialog) {
|
module.controller('GroupListCtrl', function($scope, $route, $q, realm, Groups, GroupsCount, Group, GroupChildren, Notifications, $location, Dialog) {
|
||||||
$scope.realm = realm;
|
$scope.realm = realm;
|
||||||
$scope.groupList = [
|
$scope.groupList = [
|
||||||
|
@ -47,7 +63,7 @@ module.controller('GroupListCtrl', function($scope, $route, $q, realm, Groups, G
|
||||||
{
|
{
|
||||||
"id" : "realm",
|
"id" : "realm",
|
||||||
"name": "Groups",
|
"name": "Groups",
|
||||||
"subGroups" : groups
|
"subGroups": sortGroups('name', groups)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}, function (failed) {
|
}, function (failed) {
|
||||||
|
@ -600,4 +616,3 @@ module.controller('DefaultGroupsCtrl', function($scope, $q, realm, Groups, Group
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue