Skip to content

Commit a44e7eb

Browse files
authored
Sort categories list by translation in the categories and groups pages (geonetwork#8632)
1 parent d1c1c4a commit a44e7eb

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

web-ui/src/main/resources/catalog/js/admin/CategoriesController.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@
3737
"$rootScope",
3838
"$translate",
3939
"$timeout",
40-
function ($scope, $routeParams, $http, $rootScope, $translate, $timeout) {
40+
"gnUtilityService",
41+
function (
42+
$scope,
43+
$routeParams,
44+
$http,
45+
$rootScope,
46+
$translate,
47+
$timeout,
48+
gnUtilityService
49+
) {
4150
$scope.categories = null;
4251
$scope.categorySelected = { id: $routeParams.categoryId };
4352

@@ -138,7 +147,11 @@
138147

139148
function loadCategories() {
140149
$http.get("../api/tags").then(function (response) {
141-
$scope.categories = response.data;
150+
$scope.categories = gnUtilityService.sortByTranslation(
151+
response.data,
152+
$scope.lang,
153+
"name"
154+
);
142155
});
143156
}
144157
loadCategories();

web-ui/src/main/resources/catalog/js/admin/UserGroupController.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"gnConfig",
5454
"gnConfigService",
5555
"gnAuditableService",
56+
"gnUtilityService",
5657
function (
5758
$scope,
5859
$routeParams,
@@ -63,7 +64,8 @@
6364
$log,
6465
gnConfig,
6566
gnConfigService,
66-
gnAuditableService
67+
gnAuditableService,
68+
gnUtilityService
6769
) {
6870
$scope.searchObj = {
6971
params: {
@@ -156,7 +158,13 @@
156158
$http.get("../api/tags").then(function (response) {
157159
var nullTag = { id: null, name: "", label: {} };
158160
nullTag.label[$scope.lang] = "";
159-
$scope.categories = [nullTag].concat(response.data);
161+
var categoriesSorted = gnUtilityService.sortByTranslation(
162+
response.data,
163+
$scope.lang,
164+
"name"
165+
);
166+
167+
$scope.categories = [nullTag].concat(categoriesSorted);
160168
});
161169

162170
function loadGroups() {

0 commit comments

Comments
 (0)