Sort hash of options.

This commit is contained in:
Martin Edenhofer 2013-10-01 22:48:15 +02:00
parent b6c367bf6a
commit 319a59f2e3

View file

@ -1066,7 +1066,6 @@ class App.ControllerForm extends App.Controller
return if !attribute.options return if !attribute.options
return if _.isArray( attribute.options ) return if _.isArray( attribute.options )
options_by_name = [] options_by_name = []
for i in attribute.options for i in attribute.options
options_by_name.push i['name'].toString().toLowerCase() 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 ) row.name = App.i18n.translateInline( row.name )
attribute.options.push row attribute.options.push row
else else
for key, value of selection order = _.sortBy(
name_new = value _.keys( selection, (item) ->
selection[item].toString().toLowerCase()
)
).reverse()
for key in order
name_new = selection[key]
if attribute.translate if attribute.translate
name_new = App.i18n.translateInline( name_new ) name_new = App.i18n.translateInline( name_new )
attribute.options.push { attribute.options.push {