ACK

----- Original Message -----
> Fixes https://fedorahosted.org/freeipa/ticket/772
> 
> Depends on freeipa-admiyo-0154-1-declarative-defintions.patch
> 
> _______________________________________________
> Freeipa-devel mailing list
> Freeipa-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/freeipa-devel
From a2bc445f1390aabb971230c04e0b48c39cb19725 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Wed, 26 Jan 2011 13:46:49 -0500
Subject: [PATCH] declarative for aci

A couple of the ACI definitions were incorrect, and the end result was that fields were not getting initialized.  USing the declarative approach cleaned up the cause.

Also fixed a few broken unit tests
---
 install/ui/aci.js                   |  340 ++++++++++-------------------------
 install/ui/serverconfig.js          |   34 ++--
 install/ui/test/details_tests.js    |    6 +-
 install/ui/test/entity_tests.js     |   11 +-
 install/ui/test/navigation_tests.js |   10 +-
 5 files changed, 121 insertions(+), 280 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index 4e975d85528563f1e3888155235d42205aef7d09..91be59acc210aa7e305bdbd693934ff6e1602f37 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -458,9 +458,6 @@ IPA.target_section = function () {
             appendTo(dl);
     }
 
-
-
-
     that.create = function(container) {
         var dl =  $('<dl class="entryattrs"/>').appendTo(container);
 
@@ -565,111 +562,35 @@ IPA.target_section = function () {
 
 IPA.entity_factories.permission = function () {
 
-    var that = IPA.entity({
+    return IPA.entity({
         'name': 'permission'
-    });
-
-    that.init = function() {
-
-        var dialog = IPA.permission_add_dialog({
+    }).add_dialog(
+        IPA.add_dialog({
             name: 'add',
-            title: 'Add New Permission',
-            entity_name: 'permission'
-        });
-        that.add_dialog(dialog);
-        dialog.init();
-
-        var facet = IPA.permission_search_facet({
-            name: 'search',
-            label: 'Search'
-        });
-        that.add_facet(facet);
-
-        facet = IPA.permission_details_facet();
-        that.add_facet(facet);
-
-        that.entity_init();
-    };
-
-    return that;
-};
-
-
-
-IPA.permission_add_dialog =  function (spec) {
-
-    spec = spec || {};
-
-    var that = IPA.add_dialog(spec);
-
-    that.init = function() {
-
-        that.add_field(IPA.text_widget({
-            name: 'cn',
-            undo: false
-        }));
-
-        that.add_field(IPA.text_widget({
-            name: 'description',
-            undo: false
-        }));
-
-        that.add_field(IPA.rights_widget({name:'permissions'}));
-        that.add_field(IPA.hidden_widget({name:'filter','value':'objectClass=changethisvalue'}));
-        that.add_dialog_init();
-    };
-
-
-    return that;
-};
-
-
-IPA.permission_search_facet =  function (spec) {
-
-    spec = spec || {};
-    var that = IPA.search_facet(spec);
-    that.init = function() {
-        that.create_column({name:'cn'});
-        that.create_column({name:'description'});
-        that.search_facet_init();
-    };
-    return that;
-};
-
-
-IPA.permission_details_facet = function () {
-
-    var spec = {
-            name: 'details'
-    };
-    var that = IPA.details_facet(spec);
-
-    that.init = function() {
-
-        var section = that.add_section(IPA.details_list_section({
-            name:'identity',label:'Identity'  }));
-        section.create_field({ name: 'cn', 'read_only': true });
-        section.create_field({ name: 'description'});
-
-        that.rights_section = IPA.rights_section();
-        that.add_section(that.rights_section);
-
-        that.target_section = IPA.target_section();
-
-        that.add_section(that.target_section);
-        that.details_facet_init();
-    };
-
-    that.superior_load = that.load;
-
-    that.load = function(result) {
-        that.superior_load(result);
-    };
-
-    that.superior_update = that.update;
-    that.update = function(on_win, on_fail){
-        that.superior_update(on_win, on_fail);
-    };
+            title: 'Add New Permission'
+        }).
+            field(IPA.text_widget({
+                name: 'cn',
+                undo: false
+            })).
+            field(IPA.text_widget({
+                name: 'description',
+                undo: false
+            })).
+            field(IPA.rights_widget({name:'permissions'})).
+            field(IPA.hidden_widget(
+                {name:'filter','value':'objectClass=changethisvalue'}))).
+        facet(IPA.search_facet().
+              column({name:'cn'}).
+              column({name:'description'})).
+        facet(IPA.details_facet({ name: 'details' }).
+              section(
+                  IPA.stanza({
+                name:'identity',label:'Identity'  }).
+                      input({ name: 'cn', 'read_only': true }).
+                      input({ name: 'description'})).
+              section(IPA.rights_section()).
+              section(IPA.target_section()));
     return that;
 };
 
@@ -718,155 +639,88 @@ IPA.entity_factories.privilege =  function() {
 
 
 IPA.entity_factories.role =  function() {
-    var that = IPA.entity({
+    return  IPA.entity({
         'name': 'role'
-    });
-    that.init = function() {
-        var search_facet = IPA.search_facet({
-            name: 'search',
-            label: 'Search',
-            entity_name: that.name
-        });
-        search_facet.create_column({name:'cn'});
-        search_facet.create_column({name:'description'});
-        that.add_facet(search_facet);
-
-        that.add_facet(function() {
-            var that = IPA.details_facet({name:'details'});
-            that.add_section(
-                IPA.stanza({name:'identity', label:'Role Settings'}).
-                    input({name:'cn'}).
-                    input({name: 'description'}));
-            return that;
-        }());
-
-        var dialog = IPA.add_dialog({
-            name: 'add',
-            title: 'Add Role'
-        });
-        that.add_dialog(dialog);
-
-        dialog.add_field(IPA.text_widget({ name: 'cn', undo: false}));
-        dialog.add_field(IPA.text_widget({ name: 'description', undo: false}));
-        dialog.init();
-
-        that.create_association_facets();
-
-        that.entity_init();
-    };
-    return that;
+    }).
+        facet(IPA.search_facet().
+              column({name:'cn'}).
+              column({name:'description'})).
+        facet(
+            IPA.details_facet({name:'details'}).
+                section(
+                    IPA.stanza({name:'identity', label:'Role Settings'}).
+                        input({name:'cn'}).
+                        input({name: 'description'}))).
+        add_dialog(
+            IPA.add_dialog({
+                name: 'add',
+                title: 'Add Role'
+            }).
+                field(IPA.text_widget({ name: 'cn', undo: false})).
+                field(IPA.text_widget({ name: 'description', undo: false}))).
+        standard_associations();
 };
 
 
 IPA.entity_factories.selfservice =  function() {
-    var that = IPA.entity({
+    return IPA.entity({
         'name': 'selfservice'
-    });
-
-    that.add_facet(function () {
-        var spec = {
-            name: 'search',
-            label: 'Search'
-        };
-        var that = IPA.search_facet(spec);
-        that.init = function() {
-            that.create_column({name:'aciname'});
-            that.search_facet_init();
-        };
-        return that;
-    }());
-
-
-    that.add_facet(function(){
-        var that = IPA.details_facet({'name':'details'});
-
-        that.init = function() {
-            that.add_section(
-                IPA.stanza({name:'general', label:'General',
-                            entity_name:'selfservice'}).
-                    input({name:'aciname'}).
-                    custom_input(IPA.attribute_table_widget({
-                        object_type:'user',
-                        name:'attrs'
-                    })));
-        };
-        return that;
-    }());
-
-    that.parent_init = that.init;
-    that.init = function(){
-        that.parent_init();
-        var dialog = IPA.add_dialog({
-            name: 'add',
-            title: 'Add Self Service Definition'
-        });
-        that.add_dialog(dialog);
-        dialog.add_field(IPA.text_widget({ name: 'aciname', undo: false}));
-        dialog.add_field(IPA.attribute_table_widget({
-            object_type:'user',
-            name:'attrs'
-        }));
-        dialog.init();
-    };
-    return that;
+    }).
+        facet(IPA.search_facet().
+              column({name:'aciname'})).
+        facet(
+            IPA.details_facet({'name':'details'}).
+                section(
+                    IPA.stanza({name:'general', label:'General'}).
+                        input({name:'aciname'}).
+                        custom_input(IPA.attribute_table_widget({
+                            object_type:'user',
+                            name:'attrs'
+                        })))).
+        add_dialog(
+            IPA.add_dialog({
+                name: 'add',
+                title: 'Add Self Service Definition'
+            }).
+                field(IPA.text_widget({ name: 'aciname', undo: false})).
+                field(IPA.attribute_table_widget({
+                    object_type:'user',
+                    name:'attrs'
+                })));
 };
 
 
 IPA.entity_factories.delegation =  function() {
     var that = IPA.entity({
         'name': 'delegation'
-    });
-
-    that.add_facet(function () {
-            var spec = {
-                name: 'search',
-                label: 'Search'
-            };
-            var that = IPA.search_facet(spec);
-            that.init = function() {
-                that.create_column({name:'aciname'});
-                that.search_facet_init();
-            };
-            return that;
-        }());
-    that.add_facet(function(){
-        var that = IPA.details_facet({'name':'details'});
-        var section =
-            IPA.stanza({name:'general', label:'General'}).
-            input({name:'aciname'}).
-            custom_input(IPA.entity_select_widget(
-                {name:'group', entity:'group'})).
-            custom_input(IPA.entity_select_widget(
-                {name:'memberof', entity:'group'})).
-            custom_input(
-                IPA.rights_widget({
-                    id:'delegation_rights'})).
-            custom_input(
-                IPA.attribute_table_widget({
-                    name:'attrs'}));
-            that.add_section(section);
-        return that;
-    }());
-
-    that.super_init = that.init;
-    that.init = function(){
-        that.super_init();
-        var dialog = IPA.add_dialog({
+    }).facet(
+        IPA.search_facet().
+            column({name:'aciname'})).
+        facet(
+            IPA.details_facet().
+                section(
+                    IPA.stanza({name:'general', label:'General'}).
+                        input({name:'aciname'}).
+                        custom_input(IPA.entity_select_widget(
+                            {name:'group', entity:'group'})).
+                        custom_input(IPA.entity_select_widget(
+                            {name:'memberof', entity:'group'})).
+                        custom_input(
+                            IPA.rights_widget({
+                                id:'delegation_rights'})).
+                        custom_input(
+                            IPA.attribute_table_widget({
+                                name:'attrs'})))).
+        add_dialog(IPA.add_dialog({
             name: 'add',
-            title: 'Add Delegation',
-            entity_name: that.entity
-        });
-        that.add_dialog(dialog);
-        dialog.add_field(IPA.text_widget({ name: 'aciname', undo: false}));
-        dialog.add_field(IPA.entity_select_widget({name:'group',
-                                                   entity:'group'}));
-        dialog.add_field(IPA.entity_select_widget({name:'memberof',
-                                                   entity:'group'}));
-        dialog.add_field(IPA.attribute_table_widget({ name: 'attrs'}));
-
-        dialog.init();
-        that.create_association_facets();
-    };
-
+            title: 'Add Delegation'
+        }).
+                   field(IPA.text_widget({ name: 'aciname', undo: false})).
+                   field(IPA.entity_select_widget({name:'group',
+                                                   entity:'group'})).
+                   field(IPA.entity_select_widget({name:'memberof',
+                                                   entity:'group'})).
+                   field(IPA.attribute_table_widget({ name: 'attrs'}))).
+        standard_associations();
     return that;
 };
\ No newline at end of file
diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js
index dbf46df43cff88e99c7e832d2c1ba97990532832..46e2e48564ded34bde0539fab6d62e9aa73414db 100644
--- a/install/ui/serverconfig.js
+++ b/install/ui/serverconfig.js
@@ -31,24 +31,20 @@ IPA.entity_factories.config = function(){
 
     var that = IPA.entity({
         name: 'config'
-    });
-
-    var details = IPA.details_facet();
-
-    details.add_section(
-        IPA.stanza({name:'ipaserver', label:'Configuration'}).
-            input({name:'cn', label:'Name'}).
-            input({name:'ipacertificatesubjectbase'}).
-            input({name:'ipadefaultloginshell'}).
-            input({name:'ipadefaultprimarygroup'}).
-            input({name:'ipagroupsearchfields'}).
-            input({name:'ipahomesrootdir'}).
-            input({name:'ipamaxusernamelength'}).
-            input({name:'ipamigrationenabled'}).
-            input({name:'ipasearchrecordslimit'}).
-            input({name:'ipasearchtimelimit'}).
-            input({name:'ipausersearchfields'}));
- 
-    that.add_facet(details);
+    }).facet(
+        IPA.details_facet().
+            section(
+                IPA.stanza({name:'ipaserver', label:'Configuration'}).
+                    input({name:'cn', label:'Name'}).
+                    input({name:'ipacertificatesubjectbase'}).
+                    input({name:'ipadefaultloginshell'}).
+                    input({name:'ipadefaultprimarygroup'}).
+                    input({name:'ipagroupsearchfields'}).
+                    input({name:'ipahomesrootdir'}).
+                    input({name:'ipamaxusernamelength'}).
+                    input({name:'ipamigrationenabled'}).
+                    input({name:'ipasearchrecordslimit'}).
+                    input({name:'ipasearchtimelimit'}).
+                    input({name:'ipausersearchfields'})));
     return that;
 };
\ No newline at end of file
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index 38609072fc0ecd5fcdee460635412041aafa7ae6..fb33808c7faf60bbeda9090ebd20fa5a64b94113 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -22,11 +22,11 @@
 module('details', {
     setup: function() {
         var obj_name = 'user';
-        IPA.register_entity( 
+        IPA.entity_factories.user=  
             function(){
                 return IPA.entity({name:obj_name});
-            });
-        IPA.start_entities();
+            };
+    IPA.start_entities();
     },
     teardown: function() {
     }
diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js
index a5878a6ce00c770fc98aa0a3e01c60d6758e3688..1178b99faf36ede0abfc8c8f5f5ea4904d79a913 100644
--- a/install/ui/test/entity_tests.js
+++ b/install/ui/test/entity_tests.js
@@ -20,7 +20,8 @@
 
 module('entity',{
     setup: function() {
-        IPA.register_entity(function(){return IPA.entity({name:'user'})});
+        IPA.entity_factories.user = function(){
+            return IPA.entity({name:'user'})};
         IPA.start_entities();
     },
     teardown: function() {
@@ -87,14 +88,6 @@ test('Testing ipa_facet_setup_views().', function() {
     );
 
 
-    IPA.register_entity(function(){
-        var entity = IPA.entity({
-            'name': 'user'
-        });
-
-        return entity;
-    });
-
     IPA.start_entities();
 
     var entity = IPA.get_entity('user');
diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js
index 916259b4115a1bb631aa284c3f7a617c373c3d99..9db0bb1cc3b0aa71d5dc705b873adf06188fb34f 100644
--- a/install/ui/test/navigation_tests.js
+++ b/install/ui/test/navigation_tests.js
@@ -31,7 +31,7 @@ test("Testing nav_create().", function() {
 
     var entity;
 
-    IPA.register_entity( function() {
+    IPA.entity_factories.user =  function() {
         var that = IPA.entity({name: 'user'});
         that.setup = function(container){
             user_mock_called = true;
@@ -39,10 +39,8 @@ test("Testing nav_create().", function() {
             same(container[0].nodeName,'DIV','user div');
         }
         return that;
-    });
-
-    IPA.register_entity( function(){
-
+    };
+    IPA.entity_factories.group = function(){
         var that  = IPA.entity({name: 'group'});
         that.setup = function(container){
             group_mock_called = true;
@@ -50,7 +48,7 @@ test("Testing nav_create().", function() {
             same(container[0].nodeName,'DIV','group Div');
         };
         return that;
-    });
+    };
 
     IPA.start_entities();
 
-- 
1.7.3.5

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

Reply via email to