This commit is contained in:
parent
438fc2865f
commit
e751626ac8
2 changed files with 19 additions and 6 deletions
|
@ -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({
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue