diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2012-07-30 15:12:07 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-08-14 08:09:39 +0200 |
commit | 7c99e2d6617a397e4f8f1185032e17b779245181 (patch) | |
tree | 7ce92aed99fb479199a52a8420d3f0c4d3d10a9b /install/ui/widget.js | |
parent | d536b3824e6a2cee18164187f596089b97b3c00f (diff) | |
download | freeipa-7c99e2d6617a397e4f8f1185032e17b779245181.tar.gz freeipa-7c99e2d6617a397e4f8f1185032e17b779245181.tar.xz freeipa-7c99e2d6617a397e4f8f1185032e17b779245181.zip |
Display group type
Created new value_map_widget which serves for displaying values based on a map.
It is added to group for displaying its type. The decision is based on group's objectclass.
https://fedorahosted.org/freeipa/ticket/2895
Diffstat (limited to 'install/ui/widget.js')
-rw-r--r-- | install/ui/widget.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/install/ui/widget.js b/install/ui/widget.js index 9b15f2f1b..ea0702a22 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -3487,6 +3487,55 @@ IPA.action_panel = function(spec) { return that; }; +IPA.value_map_widget = function(spec) { + + spec = spec || {}; + spec.read_only = true; + + var that = IPA.input_widget(spec); + that.value_map = spec.value_map || {}; + that.default_label = spec.default_label || ''; + + that.create = function(container) { + that.widget_create(container); + container.addClass('status-widget'); + + that.display_control = $('<span/>', { + name: that.name + }).appendTo(container); + }; + + that.update = function(values) { + + var value, found, label; + + found = false; + + if ($.isArray(values)) { + for (value in that.value_map) { + + if (!that.value_map.hasOwnProperty(value)) continue; + + if (values.indexOf(value) > -1) { + label = that.value_map[value]; + found = true; + } + } + } + + if (!found) { + label = that.default_label; + } + + that.display_control.text(label); + }; + + that.clear = function() { + that.display_control.text(''); + }; + + return that; +}; IPA.widget_factories['attribute_table'] = IPA.attribute_table_widget; IPA.widget_factories['button'] = IPA.button_widget; @@ -3509,3 +3558,4 @@ IPA.widget_factories['select'] = IPA.select_widget; IPA.widget_factories['sshkeys'] = IPA.sshkeys_widget; IPA.widget_factories['textarea'] = IPA.textarea_widget; IPA.widget_factories['text'] = IPA.text_widget; +IPA.widget_factories['value_map'] = IPA.value_map_widget;
\ No newline at end of file |