diff --git a/web-ui/src/main/resources/catalog/components/utility/UtilityService.js b/web-ui/src/main/resources/catalog/components/utility/UtilityService.js index bdd80c1f22b..d2c9d1ff59e 100644 --- a/web-ui/src/main/resources/catalog/components/utility/UtilityService.js +++ b/web-ui/src/main/resources/catalog/components/utility/UtilityService.js @@ -436,6 +436,22 @@ return defer.promise; }; + /** + * Sort an array of elements with translations labels, using the provided language. + * + */ + var sortByTranslation = function (values, sortByLanguage, defaultProperty) { + return Object.values( + // Don't mutate the original array + values.concat().sort(function (a, b) { + var aValue = a.label[sortByLanguage] || a[defaultProperty]; + var bValue = b.label[sortByLanguage] || b[defaultProperty]; + + return aValue.localeCompare(bValue); + }) + ); + }; + return { scrollTo: scrollTo, isInView: isInView, @@ -452,7 +468,8 @@ randomUuid: randomUuid, displayPermalink: displayPermalink, openModal: openModal, - goBack: goBack + goBack: goBack, + sortByTranslation: sortByTranslation }; } ]); diff --git a/web-ui/src/main/resources/catalog/js/LoginController.js b/web-ui/src/main/resources/catalog/js/LoginController.js index 42097136212..15a0a862c6e 100644 --- a/web-ui/src/main/resources/catalog/js/LoginController.js +++ b/web-ui/src/main/resources/catalog/js/LoginController.js @@ -155,7 +155,11 @@ $scope.retrieveGroups = function () { $http.get("../api/groups").then( function (response) { - $scope.groups = response.data; + $scope.groups = gnUtilityService.sortByTranslation( + response.data, + $scope.lang, + "name" + ); }, function (response) {} ); diff --git a/web-ui/src/main/resources/catalog/js/admin/ReportController.js b/web-ui/src/main/resources/catalog/js/admin/ReportController.js index 0178ae06155..13a88062239 100644 --- a/web-ui/src/main/resources/catalog/js/admin/ReportController.js +++ b/web-ui/src/main/resources/catalog/js/admin/ReportController.js @@ -36,7 +36,8 @@ "$http", "$rootScope", "$translate", - function ($scope, $routeParams, $http, $rootScope, $translate) { + "gnUtilityService", + function ($scope, $routeParams, $http, $rootScope, $translate, gnUtilityService) { $scope.pageMenu = { folder: "report/", defaultTab: "report-updated-metadata", @@ -150,7 +151,11 @@ if ($scope.user.profile === "Administrator") { $http.get("../api/groups").then( function (response) { - $scope.groups = response.data; + $scope.groups = gnUtilityService.sortByTranslation( + response.data, + $scope.lang, + "name" + ); }, function (response) { // TODO @@ -166,6 +171,12 @@ $scope.groups = _.uniqBy(groups, function (e) { return e.id; }); + + $scope.groups = gnUtilityService.sortByTranslation( + $scope.groups, + $scope.lang, + "name" + ); }, function (response) { // TODO