From 348d734c59432a740b52924ac18ff47b30dad54e Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 3 Feb 2011 21:42:50 -0600 Subject: Restructuring details page. Previously the IPA.details_list_section can only be used with widgets that generates
tag because it uses the following structure:
Telephone Number:
111-1111
222-2222
The
tag was previously used to handle multi-valued attributes. Since multi-valued attributes are now handled by the recently added IPA.multivalued_text_widget, the structure can be changed as follows:
Telephone Number:
111-1111
222-2222
This allows IPA.details_list_section to be used with any widgets without requiring the
tag. --- install/ui/widget.js | 155 ++++++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 76 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index db9d1744..beb09a9d 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -135,12 +135,14 @@ IPA.widget = function(spec) { that.writable = true; - if (that.param_info.primary_key) { - that.writable = false; - } + if (that.param_info) { + if (that.param_info.primary_key) { + that.writable = false; + } - if ('no_update' in that.param_info.flags) { - that.writable = false; + if (that.param_info.flags && 'no_update' in that.param_info.flags) { + that.writable = false; + } } if (that.record.attributelevelrights) { @@ -264,7 +266,9 @@ IPA.widget = function(spec) { that.widget_init = that.init; that.widget_create = that.create; that.widget_setup = that.setup; + that.widget_load = that.load; that.widget_reset = that.reset; + that.widget_save = that.save; return that; }; @@ -280,6 +284,11 @@ IPA.text_widget = function(spec) { that.create = function(container) { + $('
', { - 'class': 'first' - }).appendTo(container); - var div = $('
', { name: 'value' - }).appendTo(dd); + }).appendTo(container); $('', { type: 'text', @@ -440,16 +436,16 @@ IPA.multivalued_text_widget = function(spec) { href: 'jslink', title: 'Add', html: 'Add' - }).appendTo(dd); + }).appendTo(container); - dd.append(' '); + container.append(' '); $('', { name: 'undo_all', style: 'display: none;', 'class': 'ui-state-highlight ui-corner-all undo', html: 'undo all' - }).appendTo(dd); + }).appendTo(container); }; that.setup = function(container) { @@ -686,21 +682,37 @@ IPA.checkbox_widget = function (spec) { IPA.checkboxes_widget = function (spec) { spec = spec || {}; + var that = IPA.widget(spec); + that.direction = spec.direction || 'vertical'; that.options = spec.options || []; + that.add_option = function(option) { + that.options.push(option); + }; + that.create = function(container) { + var vertical = that.direction === 'vertical'; + for (var i=0; i', { type: 'checkbox', name: that.name, - text: option.label, value: option.value, title: that.tooltip }).appendTo(container); + + $('
').appendTo(container); + that.create = function(container) { that.entity_select = $('',{ + that.entity_filter = $('', { size:10, type: 'text', id: 'entity_filter', @@ -1415,20 +1418,20 @@ IPA.entity_select_widget = function(spec){ populate_select(); that.show_undo(); } - }).appendTo(dd); + }).appendTo(container); - $('',{ - href:"", + $('', { + href: '', text: 'add ' +entity + ' filter: ', - click:function(){ + click: function() { that.entity_filter.css('display','inline'); $(this).css('display','none'); return false; } - }).appendTo(dd); + }).appendTo(container); if (that.undo) { - that.create_undo(dd); + that.create_undo(container); } var undo = that.get_undo(); undo.click(function() { @@ -1437,18 +1440,18 @@ IPA.entity_select_widget = function(spec){ populate_select(); }; - that.reset = function(){ + + that.reset = function() { that.entity_filter.val(that.values[0]); that.hide_undo(); populate_select(that.values[0]); - }; - that.is_dirty = function(){ + that.is_dirty = function() { return (that.save()[0] !== that.values[0]); }; - that.load = function(record){ + that.load = function(record) { var value = record[that.name]; if (value instanceof Array) { that.values = value; @@ -1458,7 +1461,7 @@ IPA.entity_select_widget = function(spec){ that.reset(); }; - that.save = function(){ + that.save = function() { var value = $('option:selected', that.entity_select).val(); return [value]; }; -- cgit