From d58181a101eee191c238f2f2499d0e1824e6bac3 Mon Sep 17 00:00:00 2001 From: Endi S. Dewata Date: Jan 11 2012 17:04:16 +0000 Subject: Refactored permission target section. The permission target section has been modified to use widgets to create the target selection and handle multiple fields. Ticket #2098 --- diff --git a/install/ui/aci.js b/install/ui/aci.js index 5d66bfb..cae0670 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -33,31 +33,32 @@ IPA.aci.permission_entity = function(spec) { params.builder.facet_groups([ 'privilege' , 'settings' ]). search_facet({ - columns:['cn'] + columns: [ 'cn' ] + }). + details_facet({ + sections: [ + { + name: 'identity', + fields: [ 'cn' ] + }, + { + name: 'rights', + label: IPA.messages.objects.permission.rights, + fields: [ + { + factory: IPA.rights_widget, + name: 'permissions', + join: true + } + ] + }, + { + factory: IPA.permission_target_section, + name: 'target', + label: IPA.messages.objects.permission.target + } + ] }). - details_facet({sections:[ - { - name: 'identity', - fields: [ - 'cn' - ] - }, - { - name: 'rights', - label: IPA.messages.objects.permission.rights, - fields: [ - { - factory: IPA.rights_widget, - name: 'permissions', - join: true - } - ] - }, - { - factory: IPA.target_section, - name: 'target', - label: IPA.messages.objects.permission.target - }]}). association_facet({ name: 'member_privilege', facet_group: 'privilege' @@ -77,9 +78,10 @@ IPA.aci.permission_entity = function(spec) { ] }, { - factory: IPA.target_section, + factory: IPA.permission_target_section, name: 'target', - label: IPA.messages.objects.permission.target + label: IPA.messages.objects.permission.target, + show_target: true } ] }); @@ -124,10 +126,10 @@ IPA.aci.privilege_entity = function(spec) { associator: IPA.serial_associator }). association_facet({ - name: 'memberof_permission', - facet_group: 'permission', - add_method: 'add_permission', - remove_method: 'remove_permission' + name: 'memberof_permission', + facet_group: 'permission', + add_method: 'add_permission', + remove_method: 'remove_permission' }). standard_association_facets(). adder_dialog({ @@ -173,10 +175,10 @@ IPA.aci.role_entity = function(spec) { ] }). association_facet({ - name: 'memberof_privilege', - facet_group: 'privilege', - add_method: 'add_privilege', - remove_method: 'remove_privilege' + name: 'memberof_privilege', + facet_group: 'privilege', + add_method: 'add_privilege', + remove_method: 'remove_privilege' }). standard_association_facets(). adder_dialog({ @@ -201,25 +203,33 @@ IPA.aci.selfservice_entity = function(spec) { params.builder.search_facet({ pagination: false, - columns:['aciname']}). + columns: [ 'aciname' ] + }). details_facet({ - sections:[{ - name:'general', - label: IPA.messages.details.general, - fields: [ - 'aciname', - { - factory:IPA.attributes_widget, - object_type:'user', - name:'attrs' - }]}]}). + sections: [ + { + name: 'general', + label: IPA.messages.details.general, + fields: [ + 'aciname', + { + factory: IPA.attributes_widget, + object_type: 'user', + name: 'attrs' + } + ] + } + ] + }). adder_dialog({ - fields:[ + fields: [ 'aciname', - {factory:IPA.attributes_widget, - object_type:'user', - name:'attrs' - }] + { + factory: IPA.attributes_widget, + object_type: 'user', + name: 'attrs' + } + ] }); }; @@ -234,34 +244,40 @@ IPA.aci.delegation_entity = function(spec) { params.builder.search_facet({ pagination: false, - columns:['aciname']}). - details_facet({sections:[ - { - name:'general', - label: IPA.messages.details.general, - fields:[ - 'aciname', - { - factory: IPA.entity_select_widget, - name: 'group', - other_entity: 'group', - other_field: 'cn' - }, - { - factory: IPA.entity_select_widget, - name: 'memberof', - other_entity: 'group', - other_field: 'cn', - join: true - }, - { - factory:IPA.attributes_widget, - name: 'attrs', object_type: 'user', - join: true - }]}]}). + columns: [ 'aciname' ] + }). + details_facet({ + sections: [ + { + name: 'general', + label: IPA.messages.details.general, + fields: [ + 'aciname', + { + factory: IPA.entity_select_widget, + name: 'group', + other_entity: 'group', + other_field: 'cn' + }, + { + factory: IPA.entity_select_widget, + name: 'memberof', + other_entity: 'group', + other_field: 'cn', + join: true + }, + { + factory: IPA.attributes_widget, + name: 'attrs', object_type: 'user', + join: true + } + ] + } + ] + }). standard_association_facets(). adder_dialog({ - fields:[ + fields: [ 'aciname', { factory: IPA.entity_select_widget, @@ -281,7 +297,8 @@ IPA.aci.delegation_entity = function(spec) { name: 'attrs', object_type: 'user', join: true - }] + } + ] }); }; @@ -450,313 +467,163 @@ IPA.rights_widget = function(spec) { return that; }; -IPA.target_section = function(spec) { +IPA.permission_target_section = function(spec) { spec = spec || {}; - var that = IPA.details_section(spec); + var that = IPA.details_table_section(spec); - var target_types = [ - { - name: 'filter', - label: IPA.messages.objects.permission.filter, - create: function(container) { - that.filter_text.create(container); - }, - load: function(record) { - that.filter_text.load(record); - }, - save: function(record) { - record.filter = that.filter_text.save(); - } - }, - { - name: 'subtree', - label: IPA.messages.objects.permission.subtree, - create: function(container) { - that.subtree_textarea.create(container); - }, - load: function(record) { - that.subtree_textarea.load(record); - }, - save: function(record) { - record.subtree = that.subtree_textarea.save(); - } - }, - { - name: 'targetgroup', - label: IPA.messages.objects.permission.targetgroup, - create: function(container) { - that.group_select.create(container); - }, - load: function(record) { - that.group_select.list.val(record.targetgroup); - }, - save: function(record) { - record.targetgroup = that.group_select.save(); - } - }, - { - name: 'type', - label: IPA.messages.objects.permission.type, - create: function(container) { - - var span = $('', { - name: 'type' - }).appendTo(container); - - that.type_select.create(span); - - span = $('', { - name: 'attrs' - }).appendTo(container); - - that.attribute_table.create(span); - - var select = that.type_select.select; + that.targets = [ 'filter', 'subtree', 'targetgroup', 'type' ]; + that.target = that.targets[0]; + that.show_target = spec.show_target; - select.change(function() { - that.attribute_table.object_type = - that.type_select.save()[0]; - that.attribute_table.reset(); - }); + var init = function() { - select.append($('