From 7c5fe63d0b394aca3195bba8728a346513d319bc Mon Sep 17 00:00:00 2001 From: Simone Chiaretta Date: Fri, 25 May 2018 10:01:12 +0200 Subject: [PATCH] Sort language by name The issue was that the web API was returning a dictionary that was interpreted as data object by AngularJS, with each key becoming a property of an enormous object, so when binding this object to the select element, it was sorted by property name, thus the key of the array, which was the And being an object it was impossible to sort it again by value. Only option was to convert it to an array. And since the original list of culture is already sorted correctly, no need to sort it again. --- .../src/views/languages/edit.controller.js | 9 ++++++++- src/Umbraco.Web.UI.Client/src/views/languages/edit.html | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js b/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js index 3dc0845afc..6ee5a5bd7a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/languages/edit.controller.js @@ -41,7 +41,14 @@ if($routeParams.create) { vm.page.name = vm.labels.addLanguage; - languageResource.getCultures().then(function(cultures) { + languageResource.getCultures().then(function (culturesDictionary) { + var cultures = []; + angular.forEach(culturesDictionary, function (value, key) { + cultures.push({ + name: key, + displayName: value + }); + }); vm.availableCultures = cultures; }); } diff --git a/src/Umbraco.Web.UI.Client/src/views/languages/edit.html b/src/Umbraco.Web.UI.Client/src/views/languages/edit.html index 4e0f3aba60..d2b5ef6433 100644 --- a/src/Umbraco.Web.UI.Client/src/views/languages/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/languages/edit.html @@ -25,7 +25,7 @@ Required