Skip to content

Commit 8de1d0e

Browse files
authored
Sort categories list by translation in the categories and groups pages (#8635)
1 parent 287d894 commit 8de1d0e

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
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

@@ -135,7 +144,11 @@
135144

136145
function loadCategories() {
137146
$http.get("../api/tags").then(function (response) {
138-
$scope.categories = response.data;
147+
$scope.categories = gnUtilityService.sortByTranslation(
148+
response.data,
149+
$scope.lang,
150+
"name"
151+
);
139152
});
140153
}
141154
loadCategories();

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
2+
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
33
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
44
* and United Nations Environment Programme (UNEP)
55
*
@@ -48,6 +48,7 @@
4848
"$timeout",
4949
"gnConfig",
5050
"gnConfigService",
51+
"gnUtilityService",
5152
function (
5253
$scope,
5354
$routeParams,
@@ -56,7 +57,8 @@
5657
$translate,
5758
$timeout,
5859
gnConfig,
59-
gnConfigService
60+
gnConfigService,
61+
gnUtilityService
6062
) {
6163
$scope.searchObj = {
6264
params: {
@@ -146,7 +148,13 @@
146148
$http.get("../api/tags").then(function (response) {
147149
var nullTag = { id: null, name: "", label: {} };
148150
nullTag.label[$scope.lang] = "";
149-
$scope.categories = [nullTag].concat(response.data);
151+
var categoriesSorted = gnUtilityService.sortByTranslation(
152+
response.data,
153+
$scope.lang,
154+
"name"
155+
);
156+
157+
$scope.categories = [nullTag].concat(categoriesSorted);
150158
});
151159

152160
function loadGroups() {

0 commit comments

Comments
 (0)