The adder dialog box definition has been moved from search facet
into entity to make it available to other facets.

--
Endi S. Dewata
From 5e5bbe7b4607d8f3900e76363fe5cac15e0b0d97 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Mon, 18 Apr 2011 10:59:50 -0500
Subject: [PATCH] Moved adder dialog box into entity.

The adder dialog box definition has been moved from search facet
into entity to make it available to other facets.
---
 install/ui/aci.js               |   97 +++++++++++++++++++++-----------------
 install/ui/automount.js         |    6 ++-
 install/ui/dialog.js            |   19 ++++++--
 install/ui/dns.js               |    6 ++-
 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, 154 insertions(+), 139 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index e7e0c563de2b4be9dc3d0769c5e52aa8f4aefafb..77ea47a9a9ee050cb219b81fa70fda6384a7a4c7 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 7cbe4fe0e0922e8436457cc6d3ec58a256ea2da7..ca13b72dc8ad5913dbc09cdbf944472e6ce34de7 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 cba5b1abfacb24cc3fd41da74232fa4dc86ab750..eefeee17e9639489b288789cda2c90a4519dd7b4 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 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.*/
+            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 08aac113c7e3a59df10cbbda28ef1f6090ddb786..d92963c3b5c5ede8ec1ca94dc43b5d9bfb8097ef 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']
+            columns:['idnsname']
         }).
         details_facet({sections:[{
             name:'identity',
@@ -54,6 +53,9 @@ IPA.entity_factories.dnszone = function() {
             'label': IPA.metadata.objects.dnsrecord.label
         }).
         standard_association_facets().
+        adder_dialog({
+            fields: ['idnsname','idnssoamname','idnssoarname']
+        }).
         build();
 };
 
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 2cbed5b6b6bd828b441fcef5fffb3620be2d534b..39ce57350c896724414629d765aee497851ad4f9 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 fb07a8cb3303e240267e80e5ddcbdf15e5933510..e4a037a50961a3c8c856805bc50802288f7cb374 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 a0a713405723be5a6903b39d480447f62ae41460..f0a9e214f765a28197bc91485983b42c55bcceb2 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 71e49fba83a233d4213ac9b8e6f6e368cf84239d..44479de6b843020421aaa57f4bd871c86212b94f 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 a1b5ede2e4811919f4d6b2324a3c1a8e86933dfc..31f4c52504bd2877c092917c9afb8e3ff4bdb1d6 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 aa61419118ae646d7e1912354853275be6427ace..197925a8d4443745597e7d6fd4fa5ea39b21b0c2 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 ec2cb78a762f2f53e79a7db2111b7987ae2b7133..bb544177b93178c337d053e4ae238d804ba6691f 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 7f00ebfa294645b546a89f66ac5dfc99428057dd..775ae549e6931c07009c96530a890956cfdd79f9 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 b8f78c79b2db65ec9263219263c22805029538bc..daf4e6212943a4d158230b0dd96245a8af0b19f4 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 43f364c89d038d215bbfc0a4a3b0dee8c77642ba..e8489bcb2ed628ed97e3cd58f77aefd96b56db67 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 0adc091fdae25995da04a83ffeeb16a4307cbd0c..bf071f877a4c7737c36a8892a344ec414fb98caa 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 392ac5337440b3e1ec19d4ed6407c28e3de16990..7c3482140cd76f90624d698b756a194504730a07 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();
-- 
1.7.4

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to