Skip to content

Commit

Permalink
Sort categories list by translation in the categories and groups pages (
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 authored Jan 31, 2025
1 parent 287d894 commit 8de1d0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
17 changes: 15 additions & 2 deletions web-ui/src/main/resources/catalog/js/admin/CategoriesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@
"$rootScope",
"$translate",
"$timeout",
function ($scope, $routeParams, $http, $rootScope, $translate, $timeout) {
"gnUtilityService",
function (
$scope,
$routeParams,
$http,
$rootScope,
$translate,
$timeout,
gnUtilityService
) {
$scope.categories = null;
$scope.categorySelected = { id: $routeParams.categoryId };

Expand Down Expand Up @@ -135,7 +144,11 @@

function loadCategories() {
$http.get("../api/tags").then(function (response) {
$scope.categories = response.data;
$scope.categories = gnUtilityService.sortByTranslation(
response.data,
$scope.lang,
"name"
);
});
}
loadCategories();
Expand Down
14 changes: 11 additions & 3 deletions web-ui/src/main/resources/catalog/js/admin/UserGroupController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down Expand Up @@ -48,6 +48,7 @@
"$timeout",
"gnConfig",
"gnConfigService",
"gnUtilityService",
function (
$scope,
$routeParams,
Expand All @@ -56,7 +57,8 @@
$translate,
$timeout,
gnConfig,
gnConfigService
gnConfigService,
gnUtilityService
) {
$scope.searchObj = {
params: {
Expand Down Expand Up @@ -146,7 +148,13 @@
$http.get("../api/tags").then(function (response) {
var nullTag = { id: null, name: "", label: {} };
nullTag.label[$scope.lang] = "";
$scope.categories = [nullTag].concat(response.data);
var categoriesSorted = gnUtilityService.sortByTranslation(
response.data,
$scope.lang,
"name"
);

$scope.categories = [nullTag].concat(categoriesSorted);
});

function loadGroups() {
Expand Down

0 comments on commit 8de1d0e

Please sign in to comment.