From e751626ac83515ef363ffde19d803185ab4d95d0 Mon Sep 17 00:00:00 2001 From: Christoph Leistert <39339428+leischt@users.noreply.github.com> Date: Fri, 21 Jan 2022 16:49:22 +0100 Subject: [PATCH] Closes #9418: Admin UI: sort the realm localization texts alphabetically (#9419) --- .../base/admin/resources/js/controllers/realm.js | 15 ++++++++++++++- .../resources/partials/realm-localization.html | 10 +++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index 8df1028b28..7b6aa599b5 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -560,10 +560,23 @@ module.controller('RealmLocalizationCtrl', function($scope, Current, $location, $scope.updateRealmSpecificLocalizationTexts = function() { RealmSpecificLocalizationTexts.get({id: realm.realm, locale: $scope.selectedRealmSpecificLocales }, function (updated) { - $scope.localizationTexts = updated; + $scope.localizationTexts = getSortedArrayByKeyFromObject(updated); }) } + function getSortedArrayByKeyFromObject(object) { + const keys = Object.keys(object).sort(function (a, b) { + return a.localeCompare(b, locale); + }); + return keys.reduce(function (result, key) { + const value = object[key]; + if (typeof value !== 'string') { + return result; + } + return result.concat([[key, value]]); + }, []); + } + $scope.removeLocalizationText = function(key) { Dialog.confirmDelete(key, 'localization text', function() { RealmSpecificLocalizationText.remove({ diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/realm-localization.html b/themes/src/main/resources/theme/base/admin/resources/partials/realm-localization.html index b282fa2806..04f9bd6f9f 100644 --- a/themes/src/main/resources/theme/base/admin/resources/partials/realm-localization.html +++ b/themes/src/main/resources/theme/base/admin/resources/partials/realm-localization.html @@ -48,11 +48,11 @@ - - {{key}} - {{value}} - {{:: 'edit' | translate}} - {{:: 'delete' | translate}} + + {{pair[0]}} + {{pair[1]}} + {{:: 'edit' | translate}} + {{:: 'delete' | translate}}