https://fedorahosted.org/freeipa/ticket/662
From daf23fb0873796b9e479102e01e97c417ac41a44 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Mon, 31 Jan 2011 17:24:42 -0500
Subject: [PATCH] aci association fixes

declarative priv definition
fixes role_add_privilege and privilege_add_permisison
---
 install/ui/aci.js       |   62 ++++++++++++++++++++++-------------------------
 install/ui/associate.js |    6 +++-
 install/ui/entity.js    |    9 ++++++-
 3 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index ffe264d83c0bd29b0eea2d793d5379b4a376c82d..5817e5096e63af4ccae3009898e07d7c18a41c81 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -791,42 +791,33 @@ IPA.entity_factories.permission = function () {
 IPA.entity_factories.privilege =  function() {
     var that = IPA.entity({
         'name': 'privilege'
-    });
-    that.init = function() {
+    }).
+        facet(
+            IPA.search_facet().
+                column({name:'cn'}).
+                column({name:'description'})).
+        facet(
+            IPA.details_facet({name:'details'}).
+                section(
+                    IPA.stanza({name:'identity', label:'Privilege Settings'}).
+                        input({name:'cn'}).
+                        input({name: 'description'}))).
+        add_dialog(
+            IPA.add_dialog({
+                name: 'add',
+                title: 'Add Privilege'}).
+                field(IPA.text_widget({ name: 'cn', undo: false})).
+                field(IPA.text_widget({ name: 'description', undo: false}))).
+    association({
+        name: 'permission',
+        other_entity: 'privilege',
+        add_method: 'add_permission',
+        remove_method: 'remove_permission'
+    }).
 
-        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);
+    standard_associations();
 
-        that.add_facet(function() {
-            var that = IPA.details_facet({name:'details'});
-            that.add_section(
-                IPA.stanza({name:'identity', label:'Privilege Settings'}).
-                    input({name:'cn'}).
-                    input({name: 'description'}));
-            return that;
-        }());
 
-
-        var dialog = IPA.add_dialog({
-            name: 'add',
-            title: 'Add Privilege',
-            entity_name: that.entity
-        });
-        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;
 };
 
@@ -851,6 +842,11 @@ IPA.entity_factories.role =  function() {
             }).
                 field(IPA.text_widget({ name: 'cn', undo: false})).
                 field(IPA.text_widget({ name: 'description', undo: false}))).
+        association({
+            name: 'privilege',
+            add_method: 'add_privilege',
+            remove_method: 'remove-privilege',
+        }).
         standard_associations();
 };
 
diff --git a/install/ui/associate.js b/install/ui/associate.js
index bdb10337a33b3d5e4e5bc3b43a36d79114996e68..15fe8fedc4df81de88b5a18f8a3b610f8ee59aa2 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -454,7 +454,8 @@ IPA.association_table_widget = function (spec) {
             'entity_name': that.entity_name,
             'pkey': pkey,
             'other_entity': that.other_entity,
-            'attribute_member': that.attribute_member
+            'attribute_member': that.attribute_member,
+            method:that.add_method
         });
     };
 
@@ -518,7 +519,8 @@ IPA.association_table_widget = function (spec) {
             'entity_name': that.entity_name,
             'pkey': pkey,
             'other_entity': that.other_entity,
-            'values': selected_values
+            'values': selected_values,
+            method:remove_method
         });
 
         dialog.remove = function() {
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 82af8234e1ac4a27068fa7a956b8e3be7153af24..4a8971d351ef0649be6d495328617116ec383d3c 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -204,7 +204,14 @@ IPA.entity = function (spec) {
         };
 
         if (config){
-            spec.associator = config.associator;
+            for (var key in config){
+                /*name is special, as iut has already been munged 
+                  into the association name */
+                if (key === "name"){
+                    continue;
+                }
+                spec[key] = config[key] ;
+            }
         }
 
         facet =  IPA.association_facet(spec);
-- 
1.7.3.5

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

Reply via email to