Closes #9418: Admin UI: sort the realm localization texts alphabetically (#9419)

This commit is contained in:
Christoph Leistert 2022-01-21 16:49:22 +01:00 committed by GitHub
parent 438fc2865f
commit e751626ac8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View file

@ -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({

View file

@ -48,11 +48,11 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="(key, value) in localizationTexts">
<td>{{key}}</td>
<td>{{value}}</td>
<td class="kc-action-cell" kc-open="/realms/{{realm.realm}}/localization/{{selectedRealmSpecificLocales}}/{{key}}">{{:: 'edit' | translate}}</td>
<td class="kc-action-cell" data-ng-click="removeLocalizationText(key)">{{:: 'delete' | translate}}</td>
<tr ng-repeat="pair in localizationTexts">
<td>{{pair[0]}}</td>
<td>{{pair[1]}}</td>
<td class="kc-action-cell" kc-open="/realms/{{realm.realm}}/localization/{{selectedRealmSpecificLocales}}/{{pair[0]}}">{{:: 'edit' | translate}}</td>
<td class="kc-action-cell" data-ng-click="removeLocalizationText(pair[0])">{{:: 'delete' | translate}}</td>
</tr>
</tbody>
</table>