From 3528b4eca3cf2519a6af5a43f6b321cbd8eea138 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Mon, 18 Apr 2011 10:59:50 -0500 Subject: Moved adder dialog box into entity. The adder dialog box definition has been moved from search facet into entity to make it accessible from other facets. --- install/ui/aci.js | 97 +++++++++++++++++++++++------------------ install/ui/automount.js | 6 ++- install/ui/dialog.js | 19 ++++++-- install/ui/dns.js | 10 ++++- install/ui/entity.js | 46 +++---------------- install/ui/group.js | 26 ++++++----- install/ui/hbac.js | 27 +++++++----- install/ui/host.js | 6 ++- install/ui/hostgroup.js | 6 ++- install/ui/netgroup.js | 6 ++- install/ui/policy.js | 6 ++- install/ui/search.js | 2 +- install/ui/service.js | 10 ++--- install/ui/sudo.js | 18 +++++--- install/ui/test/entity_tests.js | 6 +-- install/ui/user.js | 6 ++- 16 files changed, 158 insertions(+), 139 deletions(-) diff --git a/install/ui/aci.js b/install/ui/aci.js index 55d514cfc..336a965fc 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -28,20 +28,8 @@ IPA.entity_factories.permission = function() { return IPA.entity_builder(). entity('permission'). search_facet({ - columns:['cn'], - add_fields:[ - 'cn', - { - factory:IPA.rights_widget, - name: 'permissions', - join: true, undo: false - }, - { - factory: IPA.target_section, - name: 'target', - label: IPA.messages.objects.permission.target, - undo: false - }]}). + columns:['cn'] + }). details_facet({sections:[ { name:'identity', @@ -61,6 +49,21 @@ IPA.entity_factories.permission = function() { label: IPA.messages.objects.permission.target }]}). standard_association_facets(). + adder_dialog({ + fields:[ + 'cn', + { + factory:IPA.rights_widget, + name: 'permissions', + join: true, undo: false + }, + { + factory: IPA.target_section, + name: 'target', + label: IPA.messages.objects.permission.target, + undo: false + }] + }). build(); }; @@ -69,8 +72,7 @@ IPA.entity_factories.privilege = function() { return IPA.entity_builder(). entity('privilege'). search_facet({ - columns:['cn','description'], - add_fields:['cn', 'description']}). + columns:['cn','description']}). details_facet({ sections: [{ @@ -90,6 +92,9 @@ IPA.entity_factories.privilege = function() { remove_method: 'remove_permission' }). standard_association_facets(). + adder_dialog({ + fields:['cn', 'description'] + }). build(); }; @@ -99,8 +104,7 @@ IPA.entity_factories.role = function() { return IPA.entity_builder(). entity('role'). search_facet({ - columns:['cn','description'], - add_fields:['cn', 'description']}). + columns:['cn','description']}). details_facet({sections:[ { name:'identity', @@ -112,6 +116,9 @@ IPA.entity_factories.role = function() { remove_method: 'remove_privilege' }). standard_association_facets(). + adder_dialog({ + fields:['cn', 'description'] + }). build(); }; @@ -120,14 +127,7 @@ IPA.entity_factories.selfservice = function() { return IPA.entity_builder(). entity('selfservice'). search_facet({ - columns:['aciname'], - add_fields:[ - 'aciname', - {factory:IPA.attributes_widget, - object_type:'user', - name:'attrs', - undo: false - }]}). + columns:['aciname']}). details_facet({ sections:[{ name:'general', @@ -139,6 +139,15 @@ IPA.entity_factories.selfservice = function() { object_type:'user', name:'attrs' }]}]}). + adder_dialog({ + fields:[ + 'aciname', + {factory:IPA.attributes_widget, + object_type:'user', + name:'attrs', + undo: false + }] + }). build(); }; @@ -147,23 +156,7 @@ IPA.entity_factories.delegation = function() { return IPA.entity_builder(). entity('delegation'). search_facet({ - columns:['aciname'], - add_fields:[ - 'aciname', - { - factory:IPA.entity_select_widget, - name: 'group', entity: 'group', undo: false - }, - { - factory:IPA.entity_select_widget, - name: 'memberof', entity: 'group', - join: true, undo: false - }, - { - factory:IPA.attributes_widget, - name: 'attrs', object_type: 'user', - join: true, undo: false - }]}). + columns:['aciname']}). details_facet({sections:[ { name:'general', @@ -185,6 +178,24 @@ IPA.entity_factories.delegation = function() { join: true }]}]}). standard_association_facets(). + adder_dialog({ + fields:[ + 'aciname', + { + factory:IPA.entity_select_widget, + name: 'group', entity: 'group', undo: false + }, + { + factory:IPA.entity_select_widget, + name: 'memberof', entity: 'group', + join: true, undo: false + }, + { + factory:IPA.attributes_widget, + name: 'attrs', object_type: 'user', + join: true, undo: false + }] + }). build(); }; diff --git a/install/ui/automount.js b/install/ui/automount.js index 7cbe4fe0e..ca13b72dc 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -30,8 +30,7 @@ IPA.entity_factories.automountlocation = function() { return IPA.entity_builder(). entity('automountlocation'). search_facet({ - columns:['cn'], - add_fields:['cn'] + columns:['cn'] }). details_facet({sections:[{ name:'identity', @@ -39,6 +38,9 @@ IPA.entity_factories.automountlocation = function() { fields:['cn'] }]}). standard_association_facets(). + adder_dialog({ + fields:['cn'] + }). build(); }; diff --git a/install/ui/dialog.js b/install/ui/dialog.js index cba5b1abf..f60db5cab 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -276,12 +276,23 @@ IPA.dialog = function(spec) { if (field_spec instanceof Object) { var factory = field_spec.factory || IPA.text_widget; field = factory(field_spec); + + /* This is a bit of a hack, and is here to support ACI + permissions. The target section is a group of several + widgets together. It makes more sense to do them as a + section than as a widget. However, since they can be mixed + into the flow with the other widgets, the section needs to + be defined here with the fields to get the order correct.*/ + if (field.section) { + that.add_section(field); + } else { + that.add_field(field); + } + } else { - var field_name = field_spec; - field = IPA.text_widget({ name: field_name, undo: false }); + field = IPA.text_widget({ name: field_spec, undo: false }); + that.add_field(field); } - - that.add_field(field); } return that; diff --git a/install/ui/dns.js b/install/ui/dns.js index d89982803..4debd368e 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -29,8 +29,7 @@ IPA.entity_factories.dnszone = function() { return IPA.entity_builder(). entity('dnszone'). search_facet({ - columns:['idnsname'], - add_fields: ['idnsname','idnssoamname','idnssoarname', {factory:IPA.force_dnszone_add_checkbox_widget}] + columns:['idnsname'] }). details_facet({sections:[{ name:'identity', @@ -54,6 +53,13 @@ IPA.entity_factories.dnszone = function() { 'label': IPA.metadata.objects.dnsrecord.label }). standard_association_facets(). + adder_dialog({ + fields: [ + 'idnsname', + 'idnssoamname', + 'idnssoarname', + {factory:IPA.force_dnszone_add_checkbox_widget}] + }). build(); }; diff --git a/install/ui/entity.js b/install/ui/entity.js index 2cbed5b6b..39ce57350 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -601,6 +601,13 @@ IPA.entity_builder = function(){ return that; }; + that.adder_dialog = function(spec) { + spec.factory = spec.factory || IPA.add_dialog; + spec.name = spec.name || 'add'; + spec.title = spec.title || IPA.messages.objects.user.add; + return that.dialog(spec); + }; + that.details_facet = function (spec){ var sections = spec.sections; spec.sections = null; @@ -628,45 +635,6 @@ IPA.entity_builder = function(){ search_all: spec.search_all || false, columns: spec.columns }); - - var current_dialog = - IPA.add_dialog({ - 'name': 'add', - 'title': IPA.messages.objects.user.add, - entity_name: entity.name - }); - - facet.dialog(current_dialog); - - var add_fields = spec.add_fields; - if (add_fields) { - for (var i = 0; i < add_fields.length; i += 1){ - var field = add_fields[i]; - if (field instanceof Object){ - /* This is a bit of a hack ,and is here to support ACI - permissions. The target section is a group of secveral - widgets together. It makes more sense to do them as a - seciont than as a widgit. However, since they can be mixed - into the flow with the other widgets, the section needs to - be definied here with the fields to get the order correct.*/ - var factory; - if (field.section){ - factory = field.factory; - field.factory = null; - field.name = field.section; - field.section = null; - current_dialog.add_section(factory(field)); - }else{ - field.entity_name = entity.name; - factory = field.factory || IPA.text_widget; - current_dialog.field(factory(field)); - } - }else{ - current_dialog.text(add_fields[i]); - } - } - } - entity.facet(facet); return that; }; diff --git a/install/ui/group.js b/install/ui/group.js index fb07a8cb3..e4a037a50 100644 --- a/install/ui/group.js +++ b/install/ui/group.js @@ -29,18 +29,7 @@ IPA.entity_factories.group = function () { return IPA.entity_builder(). entity('group'). search_facet({ - columns:['cn','gidnumber','description'], - add_fields: [ - 'cn', - 'description', - { - factory:IPA.checkbox_widget, - name: 'posix', - label: IPA.messages.objects.group.posix, - undo: false, - checked: 'checked' - }, - 'gidnumber'] + columns:['cn','gidnumber','description'] }). details_facet({sections: [{ @@ -86,5 +75,18 @@ IPA.entity_factories.group = function () { associator: IPA.serial_associator }). standard_association_facets(). + adder_dialog({ + fields: [ + 'cn', + 'description', + { + factory:IPA.checkbox_widget, + name: 'posix', + label: IPA.messages.objects.group.posix, + undo: false, + checked: 'checked' + }, + 'gidnumber'] + }). build(); }; diff --git a/install/ui/hbac.js b/install/ui/hbac.js index a0a713405..f0a9e214f 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -27,8 +27,14 @@ IPA.entity_factories.hbacrule = function () { entity('hbacrule'). search_facet({ columns:['cn','usercategory','hostcategory','ipaenabledflag', - 'servicecategory','sourcehostcategory'], - add_fields:[ + 'servicecategory','sourcehostcategory'] + }). + facet({ + factory: IPA.hbacrule_details_facet, + 'name': 'details' + }). + adder_dialog({ + fields:[ 'cn', { factory: IPA.radio_widget, @@ -41,10 +47,7 @@ IPA.entity_factories.hbacrule = function () { 'label': IPA.messages.objects.hbacrule.deny }], 'undo': false - }]}). - facet({ - factory: IPA.hbacrule_details_facet, - 'name': 'details' + }] }). build(); }; @@ -53,12 +56,14 @@ IPA.entity_factories.hbacsvc = function () { return IPA.entity_builder(). entity('hbacsvc'). search_facet({ - columns:['cn','description'], - add_fields:['cn','description']}). + columns:['cn','description']}). details_facet({sections:[{ name: 'general', label: IPA.messages.details.general, fields:[ 'cn', 'description']}]}). + adder_dialog({ + fields:['cn','description'] + }). build(); }; @@ -67,8 +72,7 @@ IPA.entity_factories.hbacsvcgroup = function () { return IPA.entity_builder(). entity('hbacsvcgroup'). search_facet({ - columns:['cn', 'description'], - add_fields:['cn', 'description']}). + columns:['cn', 'description']}). details_facet({sections:[ { name: 'general', @@ -86,6 +90,9 @@ IPA.entity_factories.hbacsvcgroup = function () { save_values: false }] }]}). + adder_dialog({ + fields:['cn', 'description'] + }). build(); }; diff --git a/install/ui/host.js b/install/ui/host.js index 71e49fba8..44479de6b 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -33,8 +33,7 @@ IPA.entity_factories.host = function () { name: 'krblastpwdchange', label: IPA.messages.objects.host.enrolled, format: IPA.utc_date_column_format - }], - add_fields: ['fqdn', {factory:IPA.force_host_add_checkbox_widget}] + }] }). details_facet({sections:[ { @@ -87,6 +86,9 @@ IPA.entity_factories.host = function () { associator: IPA.serial_associator }). standard_association_facets(). + adder_dialog({ + fields: ['fqdn', {factory:IPA.force_host_add_checkbox_widget}] + }). build(); }; diff --git a/install/ui/hostgroup.js b/install/ui/hostgroup.js index a1b5ede2e..31f4c5250 100644 --- a/install/ui/hostgroup.js +++ b/install/ui/hostgroup.js @@ -27,8 +27,7 @@ IPA.entity_factories.hostgroup = function() { return IPA.entity_builder(). entity('hostgroup'). - search_facet({columns:['cn','description'], - add_fields:['cn','description']}). + search_facet({columns:['cn','description']}). details_facet({sections:[{ name:'identity', label: IPA.messages.objects.hostgroup.identity, @@ -39,6 +38,9 @@ IPA.entity_factories.hostgroup = function() { associator: IPA.serial_associator }). standard_association_facets(). + adder_dialog({ + fields:['cn','description'] + }). build(); }; diff --git a/install/ui/netgroup.js b/install/ui/netgroup.js index aa6141911..197925a8d 100644 --- a/install/ui/netgroup.js +++ b/install/ui/netgroup.js @@ -26,8 +26,7 @@ IPA.entity_factories.netgroup = function() { return IPA.entity_builder(). entity('netgroup'). search_facet({ - columns:['cn','description'], - add_fields:['cn', 'description']}). + columns:['cn','description']}). details_facet({sections:[{ name:'identity', fields:['cn','description','nisdomainname']}]}). @@ -36,5 +35,8 @@ IPA.entity_factories.netgroup = function() { associator: IPA.serial_associator }). standard_association_facets(). + adder_dialog({ + fields:['cn', 'description'] + }). build(); }; diff --git a/install/ui/policy.js b/install/ui/policy.js index ec2cb78a7..bb544177b 100644 --- a/install/ui/policy.js +++ b/install/ui/policy.js @@ -28,8 +28,7 @@ IPA.entity_factories.pwpolicy = function() { return IPA.entity_builder(). entity('pwpolicy'). search_facet({ - columns:['cn'], - add_fields:['cn', 'cospriority']}). + columns:['cn']}). details_facet({ sections:[ { @@ -38,6 +37,9 @@ IPA.entity_factories.pwpolicy = function() { 'krbpwdmindiffchars','krbpwdminlength'] }]}). standard_association_facets(). + adder_dialog({ + fields:['cn', 'cospriority'] + }). build(); }; diff --git a/install/ui/search.js b/install/ui/search.js index 7f00ebfa2..775ae549e 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -300,7 +300,7 @@ IPA.search_facet = function(spec) { }; that.add = function() { - var dialog = that.get_dialog('add'); + var dialog = that.entity.get_dialog('add'); dialog.open(that.container); }; diff --git a/install/ui/service.js b/install/ui/service.js index b8f78c79b..daf4e6212 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -30,12 +30,6 @@ IPA.entity_factories.service = function() { search_facet({ columns: [ 'krbprincipalname' ] }). - dialog({ - factory: IPA.service_add_dialog, - name: 'add', - title: IPA.messages.objects.service.add, - width: '450px' - }). details_facet({sections:[ { name: 'details', @@ -76,6 +70,10 @@ IPA.entity_factories.service = function() { remove_method: 'remove_host' }). standard_association_facets(). + adder_dialog({ + factory: IPA.service_add_dialog, + width: '450px' + }). build(); }; diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 43f364c89..e8489bcb2 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -28,13 +28,15 @@ IPA.entity_factories.sudorule = function () { return IPA.entity_builder(). entity('sudorule'). search_facet({ - columns:['cn','description','cmdcategory'], - add_fields:['cn'] + columns:['cn','description','cmdcategory'] }). facet({ factory: IPA.sudorule_details_facet, 'name': 'details' }). + adder_dialog({ + fields:['cn'] + }). build(); }; @@ -43,8 +45,7 @@ IPA.entity_factories.sudocmd = function () { return IPA.entity_builder(). entity( 'sudocmd'). search_facet({ - columns:['sudocmd','description'], - add_fields:['sudocmd','description']}). + columns:['sudocmd','description']}). details_facet({sections:[ { name: 'general', @@ -86,6 +87,9 @@ IPA.entity_factories.sudocmd = function () { ] }] }]}). + adder_dialog({ + fields:['sudocmd','description'] + }). build(); }; @@ -94,8 +98,7 @@ IPA.entity_factories.sudocmdgroup = function () { return IPA.entity_builder(). entity('sudocmdgroup'). search_facet({ - columns:['cn','description'], - add_fields:['cn','description'] + columns:['cn','description'] }). details_facet({sections:[ { @@ -138,6 +141,9 @@ IPA.entity_factories.sudocmdgroup = function () { ] }] }]}). + adder_dialog({ + fields:['cn','description'] + }). build(); }; diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index 0adc091fd..bf071f877 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -36,8 +36,7 @@ module('entity',{ entity_builder(). entity('user'). search_facet({ - columns:['uid'], - add_fields:[]}). + columns:['uid']}). build(); }; IPA.start_entities(); @@ -67,8 +66,7 @@ test('Testing IPA.entity_set_search_definition().', function() { entity_builder(). entity('user'). search_facet({ - columns:['uid'], - add_fields:[]}). + columns:['uid']}). build(); entity.init(); diff --git a/install/ui/user.js b/install/ui/user.js index 392ac5337..7c3482140 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -30,7 +30,6 @@ IPA.entity_factories.user = function() { entity('user'). search_facet({ columns:['uid','cn','uidnumber','mail','telephonenumber','title'], - add_fields: ['uid','givenname','sn'], search_all: true }). details_facet({sections:[ @@ -79,7 +78,10 @@ IPA.entity_factories.user = function() { name: 'memberof_role', associator: IPA.serial_associator }). - standard_association_facets(); + standard_association_facets(). + adder_dialog({ + fields: ['uid','givenname','sn'] + }); var entity = builder.build(); -- cgit