--
Endi S. Dewata
From 945f937059587c2fe00a4874e6752baa3412c9f4 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Fri, 18 Feb 2011 18:15:21 -0600
Subject: [PATCH] Applied plugin framework on aci.

---
 install/ui/aci.js            |   87 +++++++++++++++++++++++------------------
 install/ui/test/aci_tests.js |    6 +-
 2 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index ea220f9af28fd908d218fb4c2583095fbb0e4ca8..9db572d4ff4a219822bda0fbfd7b3718d672bc90 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -24,7 +24,19 @@
 /* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
 
 
-IPA.attributes_widget = function(spec) {
+IPA.aci = IPA.plugin({
+    name: 'aci'
+});
+
+IPA.aci.init = function() {
+    IPA.aci.role();
+    IPA.aci.privilege();
+    IPA.aci.permission();
+    IPA.aci.selfservice();
+    IPA.aci.delegation();
+};
+
+IPA.aci.attributes_widget = function(spec) {
 
     spec = spec || {};
 
@@ -174,7 +186,7 @@ IPA.attributes_widget = function(spec) {
     return that;
 };
 
-IPA.rights_widget = function(spec) {
+IPA.aci.rights_widget = function(spec) {
 
     var that = IPA.checkboxes_widget(spec);
 
@@ -190,8 +202,7 @@ IPA.rights_widget = function(spec) {
     return that;
 };
 
-
-IPA.rights_section = function() {
+IPA.aci.rights_section = function() {
 
     var spec = {
         name: 'rights',
@@ -200,7 +211,7 @@ IPA.rights_section = function() {
 
     var that = IPA.details_section(spec);
 
-    that.add_field(IPA.rights_widget({
+    that.add_field(IPA.aci.rights_widget({
         name: 'permissions',
         join: true
     }));
@@ -208,8 +219,7 @@ IPA.rights_section = function() {
     return that;
 };
 
-
-IPA.target_section = function(spec) {
+IPA.aci.target_section = function(spec) {
 
     spec = spec || {};
 
@@ -225,7 +235,7 @@ IPA.target_section = function(spec) {
     that.group_select = IPA.entity_select_widget(
         {name: 'targetgroup', entity:'group', undo: that.undo});
     that.type_select = IPA.select_widget({name: 'type', undo: that.undo});
-    that.attribute_table = IPA.attributes_widget({
+    that.attribute_table = IPA.aci.attributes_widget({
         name: 'attrs', undo: that.undo});
 
     that.add_field(that.filter_text);
@@ -507,7 +517,7 @@ IPA.target_section = function(spec) {
     return that;
 };
 
-IPA.permission_details_facet = function(spec) {
+IPA.aci.permission_details_facet = function(spec) {
 
     spec = spec || {};
 
@@ -541,9 +551,9 @@ IPA.permission_details_facet = function(spec) {
     return that;
 };
 
-IPA.entity_factories.permission = function() {
+IPA.aci.permission = function() {
 
-    return IPA.entity({
+    IPA.entity({
         'name': 'permission'
     }).
         facet(
@@ -556,33 +566,34 @@ IPA.entity_factories.permission = function() {
                         width: '700px'
                     }).
                         field(IPA.text_widget({name: 'cn', undo: false})).
-                        field(IPA.rights_widget({
+                        field(IPA.aci.rights_widget({
                             name: 'permissions',
                             join: true, undo: false})).
-                        section(IPA.target_section({
+                        section(IPA.aci.target_section({
                             name: 'target',
                             label: IPA.messages.objects.permission.target,
                             undo: false
                         })))).
         facet(
-            IPA.permission_details_facet({ name: 'details' }).
+            IPA.aci.permission_details_facet({ name: 'details' }).
                 section(
                     IPA.stanza({
                         name:'identity',
                         label: IPA.messages.objects.permission.identity
                     }).
                         input({name: 'cn', read_only: true})).
-                section(IPA.rights_section()).
-                section(IPA.target_section({
+                section(IPA.aci.rights_section()).
+                section(IPA.aci.target_section({
                     name: 'target',
                     label: IPA.messages.objects.permission.target
                 }))).
-        standard_associations();
+        standard_associations().
+        init();
 };
 
+IPA.aci.privilege = function() {
 
-IPA.entity_factories.privilege = function() {
-    var that = IPA.entity({
+    IPA.entity({
         'name': 'privilege'
     }).
         facet(
@@ -620,14 +631,13 @@ IPA.entity_factories.privilege = function() {
                 remove_method: 'remove_permission'
             })).
 
-        standard_associations();
-
-    return that;
+        standard_associations().
+        init();
 };
 
+IPA.aci.role = function() {
 
-IPA.entity_factories.role = function() {
-    return  IPA.entity({
+    IPA.entity({
         'name': 'role'
     }).
         facet(
@@ -658,12 +668,13 @@ IPA.entity_factories.role = function() {
                 remove_method: 'remove_privilege'
             })).
 
-        standard_associations();
+        standard_associations().
+        init();
 };
 
+IPA.aci.selfservice = function() {
 
-IPA.entity_factories.selfservice = function() {
-    return IPA.entity({
+    IPA.entity({
         'name': 'selfservice'
     }).
         facet(
@@ -675,7 +686,7 @@ IPA.entity_factories.selfservice = function() {
                         title: IPA.messages.objects.selfservice.add
                     }).
                         field(IPA.text_widget({ name: 'aciname', undo: false})).
-                        field(IPA.attributes_widget({
+                        field(IPA.aci.attributes_widget({
                             object_type:'user',
                             name:'attrs', undo: false
                         })))).
@@ -687,15 +698,16 @@ IPA.entity_factories.selfservice = function() {
                         label: IPA.messages.details.general
                     }).
                         input({name:'aciname'}).
-                        custom_input(IPA.attributes_widget({
+                        custom_input(IPA.aci.attributes_widget({
                             object_type:'user',
                             name:'attrs'
-                        }))));
+                        })))).
+        init();
 };
 
+IPA.aci.delegation = function() {
 
-IPA.entity_factories.delegation = function() {
-    var that = IPA.entity({
+    IPA.entity({
         'name': 'delegation'
     }).
         facet(
@@ -717,7 +729,7 @@ IPA.entity_factories.delegation = function() {
                             name: 'memberof', entity: 'group',
                             join: true, undo: false
                         })).
-                        field(IPA.attributes_widget({
+                        field(IPA.aci.attributes_widget({
                             name: 'attrs', object_type: 'user',
                             join: true, undo: false
                         })))).
@@ -736,15 +748,14 @@ IPA.entity_factories.delegation = function() {
                             name:'memberof',
                             entity:'group', join: true
                         })).
-                        custom_input(IPA.rights_widget({
+                        custom_input(IPA.aci.rights_widget({
                             name: 'permissions',
                             direction: 'horizontal', join: true
                         })).
-                        custom_input(IPA.attributes_widget({
+                        custom_input(IPA.aci.attributes_widget({
                             name:'attrs', object_type:'user',
                             join: true
                         })))).
-        standard_associations();
-    return that;
-
+        standard_associations().
+        init();
 };
diff --git a/install/ui/test/aci_tests.js b/install/ui/test/aci_tests.js
index d51f1ea6d1aec5f5f204390b258155f96612e6ef..c439013fa92f66c28b186593413b60d52136762b 100644
--- a/install/ui/test/aci_tests.js
+++ b/install/ui/test/aci_tests.js
@@ -36,7 +36,7 @@ module('aci',{
            );
 
            target_container = $('<div id="target"/>').appendTo(document.body);
-           target_section = IPA.target_section({name: 'target', label: 'Target'});
+           target_section = IPA.aci.target_section({name: 'target', label: 'Target'});
            target_section.init();
            target_section.create(target_container);
        },
@@ -54,7 +54,7 @@ test("IPA.attributes_widget.", function() {
         name: 'attrs'
     });
 
-    var widget = IPA.attributes_widget({
+    var widget = IPA.aci.attributes_widget({
         name: 'attrs',
         object_type: 'user'
     });
@@ -111,7 +111,7 @@ test("IPA.rights_widget.", function() {
         name: 'permissions'
     });
 
-    var widget = IPA.rights_widget({
+    var widget = IPA.aci.rights_widget({
         name: 'permissions'
     });
 
-- 
1.6.6.1

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

Reply via email to