From 6f6d50f37f21db2a5591fa44c962eea04b82f596 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Mon, 7 Feb 2011 23:02:43 -0500 Subject: target section without radio buttons ACI target section refactored into an array of widget-like objects. The radio buttons have been replaced by a select box. THe select is not visible on the details page. --- install/ui/aci.js | 544 ++++++++++++++++++++++--------------------- install/ui/dialog.js | 3 + install/ui/test/aci_tests.js | 41 +++- install/ui/widget.js | 24 +- 4 files changed, 325 insertions(+), 287 deletions(-) (limited to 'install/ui') diff --git a/install/ui/aci.js b/install/ui/aci.js index e515902c5..494bd9a5b 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -34,7 +34,11 @@ IPA.attributes_widget = function(spec) { var id = spec.name; + that.setup = function (){ + }; + that.create = function(container) { + that.container = container; that.table = $('', { id:id, @@ -50,10 +54,8 @@ IPA.attributes_widget = function(spec) { html:$('',{ type: "checkbox", click: function(){ - $('.aci-attribute'). + $('.aci-attribute', that.table). attr('checked', $(this).attr('checked')); - }, - change: function() { that.show_undo(); } }) @@ -62,6 +64,10 @@ IPA.attributes_widget = function(spec) { if (that.undo) { that.create_undo(container); + that.get_undo().click(function(){ + that.reset(); + that.hide_undo(); + }); } if (that.object_type){ @@ -112,7 +118,7 @@ IPA.attributes_widget = function(spec) { name: that.name, value: value, 'class': 'aci-attribute', - change: function() { + click: function() { that.show_undo(); } })); @@ -129,7 +135,8 @@ IPA.attributes_widget = function(spec) { var unmatched = []; for (var i=0; i',{ - type:'hidden', - 'id':that.id, - value: value - }). - appendTo(container); - }; - - that.save = function(){ - return [value]; - }; - that.reset = function(){ - - }; - return that; -}; - IPA.rights_section = function() { var spec = { @@ -210,7 +194,8 @@ IPA.rights_section = function() { 'label': 'Rights' }; var that = IPA.details_section(spec); - that.add_field(IPA.rights_widget({name: 'permissions', label: 'Permissions', join: true})); + that.add_field(IPA.rights_widget( + {name: 'permissions', label: 'Permissions', join: true})); return that; }; @@ -221,265 +206,287 @@ IPA.target_section = function(spec) { spec = spec || {}; var that = IPA.details_section(spec); - that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; - var groupings = ['aci_by_type', 'aci_by_query', 'aci_by_group', - 'aci_by_filter' ]; - var inputs = ['input', 'select', 'textarea']; - - function disable_inputs() { - for (var g = 0; g < groupings.length; g += 1 ){ - for (var t = 0 ; t < inputs.length; t += 1){ - $('.' + groupings[g] + ' '+ inputs[t]). - attr('disabled', 'disabled'); - } - } - } - function enable_by(grouping) { - for (var t = 0 ; t < inputs.length; t += 1){ - $('.' + grouping + ' '+ inputs[t]). - attr('disabled', ''); - } - } - - function display_filter_target(dl) { - $('
'). - append($('', { - type: 'radio', - name: 'aci_type', - checked: 'true', - id: 'aci_by_filter' - })). - append($('
', { - 'class': 'aci_by_filter first' - }).appendTo(dl); - - var span = $('', { - name: 'filter' - }).appendTo(dd); + that.filter_text = IPA.text_widget({name: 'filter', undo: that.undo}); + that.subtree_textarea = IPA.textarea_widget({ + name: 'subtree', + cols: 30, rows: 1, + undo: that.undo + }); + that.group_select = IPA.entity_select_widget( + {name: 'targetgroup', entity:'group', undo: that.undo}); + that.type_select = IPA.select_widget({name: 'type', undo: that.undo}); + that.attribute_table = IPA.attributes_widget({ + name: 'attrs', undo: that.undo}); + + that.add_field(that.filter_text); + that.add_field(that.subtree_textarea); + that.add_field(that.group_select ); + that.add_field(that.type_select); + that.add_field(that.attribute_table); + + + that.filter_text.update = function(){ + var value = that.filter_text.values && that.filter_text.values.length ? + that.filter_text.values[0] : ''; + $('input[name="'+that.filter_text.name+'"]', that.filter_text.container).val(value); + + var label = $('label[name="'+that.filter_text.name+'"]', + that.filter_text.container); + var input = $('input[name="'+that.filter_text.name+'"]', + that.filter_text.container); + + label.css('display', 'none'); + input.css('display', 'inline'); - that.filter_text.create(span); - } - - - function display_type_target(dl) { - $('
'). - append($('', { - type: 'radio', - name: 'aci_type', - checked: 'true', - id: 'aci_by_type' - })). - append($('
', { - 'class': 'aci_by_type first' - }).appendTo(dl); - - var span = $('', { - name: 'type' - }).appendTo(dd); - - that.type_select.create(span); - - span = $('', { - name: 'attrs' - }).appendTo(dl); - - that.attribute_table.create(span); - } + }; - function display_query_target(dl) { - $('
'). - append($('', { - type: 'radio', - name: 'aci_type', - id: 'aci_by_query' - })). - append($('
', { - 'class': 'aci_by_query first' - }).appendTo(dl); + var target_types = [ + { + name:'filter', + create: function(dl){ + + $('
'). + append($('
', { + 'class': 'aci_by_filter first' + }).appendTo(dl); + + var span = $('', { + name: 'filter' + }).appendTo(dd); + + that.filter_text.create(span); + }, + load: function(record){ + that.filter_text.load(record); + }, + save: function(record){ + record.filter = that.filter_text.save()[0]; + } + }, + { + name:'subtree', + create:function(dl) { + $('
'). + append($('
', { + 'class': 'aci_by_query first' + }).appendTo(dl); + var span = $('', { + name: 'subtree' + }).appendTo(dd); + that.subtree_textarea.create(span); + }, + load: function(record){ + that.subtree_textarea.load(record); + }, + save: function(record){ + record.subtree = that.subtree_textarea.save()[0]; + } + }, + { + name:'targetgroup', + create: function (dl) { + $('
'). + append($('
', { + 'class': 'aci_by_group first' + }).appendTo(dl); + var span = $('', { + name: 'targetgroup' + }).appendTo(dd); + that.group_select.create(span); + }, + load: function(record){ + that.group_select.entity_select.val(record.targetgroup); + }, + save: function(record){ + record.targetgroup = that.group_select.save()[0]; + } + }, + { + name:'type', + create: function(dl) { + $('
'). + append($('
', { + 'class': 'aci_by_type first' + }).appendTo(dl); + var span = $('', { + name: 'type' + }).appendTo(dd); + that.type_select.create(span); + that.type_select.setup(span); + + span = $('
', { + name: 'attrs', + 'class':'other' + }).appendTo(dl); + + that.attribute_table.create(span); + + var select = that.type_select.select; + + select.change(function() { + that.attribute_table.object_type = + that.type_select.save()[0]; + that.attribute_table.reset(); + }); + select.append($('
'). - append($('', { - type: 'radio', - name: 'aci_type', - id: 'aci_by_group' - })). - append($('
', { - 'class': 'aci_by_group first' - }).appendTo(dl); - - var span = $('', { - name: 'targetgroup' - }).appendTo(dd); - - that.group_select.create(span); } - that.create = function(container) { + var dl = $('
', { 'class': 'aci-target' }).appendTo(container); + $('
Target:
').appendTo(dl); - display_filter_target(dl); - display_query_target(dl); - display_group_target(dl); - display_type_target(dl); - - $('#aci_by_filter', dl).click(function() { - disable_inputs(); - enable_by(groupings[3]); - }); - - $('#aci_by_type', dl).click(function() { - disable_inputs(); - enable_by(groupings[0]); - }); - - $('#aci_by_query', dl).click(function() { - disable_inputs(); - enable_by(groupings[1]); - }); - - $('#aci_by_group', dl).click(function() { - disable_inputs(); - enable_by(groupings[2]); - }); - - $('#aci_by_type', dl).click(); - }; - - that.setup = function(container) { - that.section_setup(container); - - var select = that.type_select.select; - - select.change(function() { - that.attribute_table.object_type = that.type_select.save()[0]; - that.attribute_table.reset(); - }); - - select.append($('