summaryrefslogtreecommitdiffstats
path: root/install/ui/widget.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-09-16 12:02:12 -0500
committerEndi S. Dewata <edewata@redhat.com>2011-09-29 16:57:05 +0000
commitecb58275e30f215143c57bdf96094103c8fda7ba (patch)
treefbac5e378d3aaefd2426e76745efbd72a2d5dcc2 /install/ui/widget.js
parent5eba2ffddd981d200168d7751a92ac7c83ff1422 (diff)
downloadfreeipa-ecb58275e30f215143c57bdf96094103c8fda7ba.tar.gz
freeipa-ecb58275e30f215143c57bdf96094103c8fda7ba.tar.xz
freeipa-ecb58275e30f215143c57bdf96094103c8fda7ba.zip
Use editable combobox for service type.
The service type field in the service adder dialog has been modified to use an editable combobox. Ticket #1633.
Diffstat (limited to 'install/ui/widget.js')
-rw-r--r--install/ui/widget.js34
1 files changed, 29 insertions, 5 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js
index f32dfbb18..8d425412d 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1598,8 +1598,9 @@ IPA.combobox_widget = function(spec) {
that.editable = spec.editable;
that.searchable = spec.searchable;
- that.list_size = spec.list_size || 5;
+ that.size = spec.size || 5;
that.empty_option = spec.empty_option === undefined ? true : spec.empty_option;
+ that.options = spec.options || [];
that.create = function(container) {
that.widget_create(container);
@@ -1688,7 +1689,7 @@ IPA.combobox_widget = function(spec) {
that.list = $('<select/>', {
name: 'list',
- size: that.list_size,
+ size: that.size,
style: 'width: 100%',
change: function() {
var value = $('option:selected', that.list).val();
@@ -1720,7 +1721,30 @@ IPA.combobox_widget = function(spec) {
return that.list_container.css('visibility') == 'visible';
};
- that.search = function(filter) {
+ that.search = function(filter, on_success, on_error) {
+
+ that.remove_options();
+
+ if (that.empty_option) {
+ that.create_option();
+ }
+
+ for (var i=0; i<that.options.length; i++) {
+ var option = that.options[i];
+
+ var label, value;
+ if (option instanceof Object) {
+ label = option.label;
+ value = option.value;
+ } else {
+ label = option;
+ value = option;
+ }
+
+ that.create_option(label, value);
+ }
+
+ if (on_success) on_success.call(this);
};
that.update = function() {
@@ -1792,9 +1816,9 @@ IPA.combobox_widget = function(spec) {
return value === '' ? [] : [value];
};
- that.create_option = function(text, value) {
+ that.create_option = function(label, value) {
return $('<option/>', {
- text: text,
+ text: label,
value: value
}).appendTo(that.list);
};