Pman.js
authorAlan Knowles <alan@akbkhome.com>
Sat, 31 Mar 2012 07:54:39 +0000 (15:54 +0800)
committerAlan Knowles <alan@akbkhome.com>
Sat, 31 Mar 2012 07:54:39 +0000 (15:54 +0800)
Pman.js

diff --git a/Pman.js b/Pman.js
index 4af9993..3fa0886 100644 (file)
--- a/Pman.js
+++ b/Pman.js
@@ -19,6 +19,8 @@ if (typeof(_T) == 'undefined') { _T={};}
  
 
 
+Roo.XComponent.on('register', function(e) { return Pman.xregister(e); });
+
   
 
 Pman = new Roo.Document(
@@ -765,23 +767,11 @@ Pman = new Roo.Document(
     appModules : false,
     
     modules : false,
-    /**
-     * example:
-     * 
-     * Pman.register({
-          modKey : '00-admin-xxxx',
-          module : Pman.Tab.projectMgr, << really a components..
-          part : [ 'Admin', 'ProjectManager' ]
-          moduleOwner : 
-          region : 'center',
-          parent : Pman.layout
-        })
-     * 
-     */
-    register : function(obj)
+    
+    
+    xregister : function(obj)
     {
         
-        
         // work out owner..
         if (!this.appModules === false) {
             this.appModules = typeof(AppModules ) == 'undefined'? [] :
@@ -810,10 +800,12 @@ Pman = new Roo.Document(
             if (this.hasPermExists(permname) && !this.hasPerm(permname,'S')) {
                 // it's a turned off permission...
                 Roo.log(permname + " is Disabled for this user");
+                obj.disabled = true;
                 return;
             }
             if (appDisabled.indexOf(permname) > -1)  {
                 Roo.log(permname + " is Disabled for this site");
+                obj.disabled = true;
                 return;
             }
             
@@ -824,15 +816,43 @@ Pman = new Roo.Document(
         
         if (!obj.parent) {
             if (obj.parent === false) {
-                //console.log('skip module (no parent)' + obj.modkey);
+                obj.disabled = true;
+                console.log('skip module (no parent)');
+                console.log(obj);
                 return;
             }
             // this is an error condition - the parent does not exist..
             // technically it should not happen..
-            console.log("Parent is missing");
+            console.log("Parent is undefined");
             console.log(obj);
+            obj.disabled = true;
+            return;
+        }
+        
+       
+        
+    },
+    /**
+     * DEPRICATED : use Roo.XComponents now..
+     * 
+     * Pman.register({
+          modKey : '00-admin-xxxx',
+          module : Pman.Tab.projectMgr, << really a components..
+          part : [ 'Admin', 'ProjectManager' ]
+          moduleOwner : 
+          region : 'center',
+          parent : Pman.layout
+        })
+     * 
+     */
+    register : function(obj)
+    {
+        
+        this.xregister(obj);
+        if (obj.disabled) {
             return;
         }
+         
         if (!obj.parent.modules) {
             obj.parent.modules = new Roo.util.MixedCollection(false, function(o) { return o.modKey });
         }
@@ -841,6 +861,7 @@ Pman = new Roo.Document(
         
     },
     
+    
     buildModules : function(parent, onComplete) 
     {