From 8fcf6d6b34400c1924f509701856b86e4f647624 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Wed, 9 Jul 2014 16:14:32 +0200 Subject: webui: option_widget_base: sort options https://fedorahosted.org/freeipa/ticket/4253 Reviewed-By: Endi Sukma Dewata --- install/ui/src/freeipa/widget.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'install/ui/src/freeipa/widget.js') diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 3204b353e..c12115592 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -1259,6 +1259,7 @@ IPA.option_widget_base = function(spec, that) { that.name = spec.name; that.label = spec.label; that.tooltip = spec.tooltip; + that.sort = spec.sort === undefined ? false : spec.sort; that.value_changed = that.value_changed || IPA.observer(); that.default_value = spec.default_value || null; that.default_on_empty = spec.default_on_empty === undefined ? true : spec.default_on_empty; @@ -1379,11 +1380,25 @@ IPA.option_widget_base = function(spec, that) { } }; + that.sort_options = function() { + var options = that.options.concat(); + options.sort(function(a,b) { + if (a.value > b.value) + return 1; + if (a.value < b.value) + return -1; + return 0; + }); + return options; + }; + that.create_options = function(container) { container = $(container)[0]; - for (var i=0, l=that.options.length; i