From 319a59f2e362a732948f762f7a25f6b4e5fdb1c0 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 1 Oct 2013 22:48:15 +0200 Subject: [PATCH] Sort hash of options. --- .../controllers/_application_controller_form.js.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 99ed2711d..c7c2de7fd 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -1066,7 +1066,6 @@ class App.ControllerForm extends App.Controller return if !attribute.options return if _.isArray( attribute.options ) - options_by_name = [] for i in attribute.options options_by_name.push i['name'].toString().toLowerCase() @@ -1099,8 +1098,13 @@ class App.ControllerForm extends App.Controller row.name = App.i18n.translateInline( row.name ) attribute.options.push row else - for key, value of selection - name_new = value + order = _.sortBy( + _.keys( selection, (item) -> + selection[item].toString().toLowerCase() + ) + ).reverse() + for key in order + name_new = selection[key] if attribute.translate name_new = App.i18n.translateInline( name_new ) attribute.options.push {