Added option to order (searchable_)select options 'DESC'.

This commit is contained in:
Thorsten Eckel 2015-06-29 16:24:46 +02:00
parent f1c8e3da96
commit ad1626b405

View file

@ -2094,7 +2094,14 @@ class App.ControllerForm extends App.Controller
_sortOptions: (attribute) ->
return if !attribute.options
return if _.isArray( attribute.options )
if _.isArray( attribute.options )
# reverse if we have to exit early, if configured
if attribute.order
if attribute.order == 'DESC'
attribute.options = attribute.options.reverse()
return
options_by_name = []
for i in attribute.options
options_by_name.push i['name'].toString().toLowerCase()
@ -2109,6 +2116,11 @@ class App.ControllerForm extends App.Controller
options_new.push ii
attribute.options = options_new
# do a final reverse, if configured
if attribute.order
if attribute.order == 'DESC'
attribute.options = attribute.options.reverse()
_addNullOption: (attribute) ->
return if !attribute.options
return if !attribute.nulloption