From 26ded75be94e60a34a19d06ce4a5fb3185875cd5 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 10 Aug 2011 20:03:02 -0500 Subject: Fixed layout problem in permission adder dialog. In order to maintain consistent layout between details page and dialog boxes the IPA.details_list_section has been replaced with IPA.details_table_section which is based on table. The IPA.target_section and other subclasses of IPA.details_list_section have been converted to use IPA.details_table_section as well. The unit tests have been updated accordingly. Ticket #1648 --- install/ui/aci.js | 377 ++++++++++++++++++++++++++---------------------------- 1 file changed, 183 insertions(+), 194 deletions(-) (limited to 'install/ui/aci.js') diff --git a/install/ui/aci.js b/install/ui/aci.js index a0399f50..e447391c 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -33,20 +33,29 @@ IPA.entity_factories.permission = function() { }). details_facet({sections:[ { - name:'identity', - fields: [{ - factory: IPA.text_widget, - name: 'cn', - read_only: true - }] + name: 'identity', + fields: [ + { + factory: IPA.text_widget, + name: 'cn', + read_only: true + } + ] }, { - name:'rights', - factory:IPA.rights_section + name: 'rights', + label: IPA.messages.objects.permission.rights, + fields: [ + { + factory: IPA.rights_widget, + name: 'permissions', + join: true + } + ] }, { - name:'target', - factory:IPA.target_section, + factory: IPA.target_section, + name: 'target', label: IPA.messages.objects.permission.target }]}). association_facet({ @@ -56,10 +65,10 @@ IPA.entity_factories.permission = function() { adder_dialog({ width: 500, height: 400, - fields:[ + fields: [ 'cn', { - factory:IPA.rights_widget, + factory: IPA.rights_widget, name: 'permissions', join: true, undo: false }, @@ -68,7 +77,8 @@ IPA.entity_factories.permission = function() { name: 'target', label: IPA.messages.objects.permission.target, undo: false - }] + } + ] }). build(); }; @@ -380,26 +390,6 @@ IPA.rights_widget = function(spec) { return that; }; - -IPA.rights_section = function(spec) { - - spec = spec || {}; - - spec.name = 'rights'; - spec.label = IPA.messages.objects.permission.rights; - - var that = IPA.details_section(spec); - - that.add_field(IPA.rights_widget({ - entity: that.entity, - name: 'permissions', - join: true - })); - - return that; -}; - - IPA.target_section = function(spec) { spec = spec || {}; @@ -408,158 +398,60 @@ IPA.target_section = function(spec) { that.section = true; that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; - that.filter_text = IPA.text_widget({ - name: 'filter', - undo: that.undo, - entity: spec.entity - }); - that.subtree_textarea = IPA.textarea_widget({ - entity: spec.entity, - name: 'subtree', - cols: 30, rows: 1, - undo: that.undo - }); - that.group_select = IPA.entity_select_widget({ - name: 'targetgroup', - other_entity: 'group', - other_field: 'cn', - undo: that.undo - }); - that.type_select = IPA.select_widget({ - name: 'type', - undo: that.undo - }); - that.attribute_table = IPA.attributes_widget({ - entity: spec.entity, - 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); - - - /*TODO these next two functions are work arounds for missing attribute - permissions for the filter text. Remove them once that has been fixed */ - 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.save = function(){ - var input = $('input[name="'+that.filter_text.name+'"]', - that.filter_text.container); - var value = input.val(); - return value === '' ? [] : [value]; - }; - 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); + name: 'filter', + label: IPA.messages.objects.permission.filter, + create: function(container) { + that.filter_text.create(container); }, - load: function(record){ + load: function(record) { that.filter_text.load(record); }, - save: function(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); + name: 'subtree', + label: IPA.messages.objects.permission.subtree, + create: function(container) { + that.subtree_textarea.create(container); }, - load: function(record){ + load: function(record) { that.subtree_textarea.load(record); }, - save: function(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); + name: 'targetgroup', + label: IPA.messages.objects.permission.targetgroup, + create: function(container) { + that.group_select.create(container); }, - load: function(record){ + load: function(record) { that.group_select.list.val(record.targetgroup); }, - save: function(record){ + save: function(record) { record.targetgroup = that.group_select.save()[0]; } }, { - name:'type', - create: function(dl) { - $('
'). - append($('
', { - 'class': 'aci_by_type first' - }).appendTo(dl); + name: 'type', + label: IPA.messages.objects.permission.type, + create: function(container) { + var span = $('', { name: 'type' - }).appendTo(dd); - that.type_select.create(span); + }).appendTo(container); + that.type_select.create(span); - span = $('
', { - name: 'attrs', - 'class':'other' - }).appendTo(dl); + span = $('', { + name: 'attrs' + }).appendTo(container); that.attribute_table.create(span); @@ -570,17 +462,21 @@ IPA.target_section = function(spec) { that.type_select.save()[0]; that.attribute_table.reset(); }); + select.append($('
Target:
').appendTo(dl); + var table = $('', { + 'class': 'section-table' + }).appendTo(that.container); - if (that.undo){ - dl.css('display','none'); + var tr = $('').appendTo(table); + + var td = $('', { + style: 'display: none' + }).appendTo(table); + + td = $('
', { + 'class': 'section-cell-label' + }).appendTo(tr); + + $('', { + 'class': 'section-cell-field' + }).appendTo(tr); + + var field_container = $('
', { + name: 'target', + 'class': 'field' + }).appendTo(td); + + that.target_type_select = $('
', { + 'class': 'section-cell-label' + }).appendTo(tr); + + $('', { + 'class': 'section-cell-field' + }).appendTo(tr); + + field_container = $('
', { + name: target_type.name, + title: target_type.label, + 'class': 'field' + }).appendTo(td); + + target_type.create(field_container); + target_type.container = tr; } }; @@ -667,14 +662,14 @@ IPA.target_section = function(spec) { reset_target_widgets(); var target_type_name ; - for (var i = 0 ; i < target_types.length; i += 1){ + for (var i=0; i