DataObjects/ProjectDirectory.php
[Pman.Core] / Pman.js
1 //<script type="text/javascript">
2
3 /**
4  * 
5  * >>> Pman.layout.getRegion('center').tabs.stripWrap
6  * ==> tab.???
7  * var tbh = Pman.layout.getRegion('center').tabs.stripWrap.child('div').createChild(
8  * 
9  * {tag: 'div', style: 'display:block;position:absolute;top:2;left:300;width:100%;height:25px'});
10  * 
11  * 
12  *  CHANGES
13  *  - gtranslate moved to Pman.GoogleTranslate
14  * 
15  * 
16  */
17  
18 if (typeof(_T) == 'undefined') { _T={};}
19  
20
21
22 Roo.XComponent.on('register', function(e) { return Pman.xregister(e); });
23 Roo.XComponent.on('buildComplete',  
24      function() {
25                     
26         Pman.layout.getRegion('center').showPanel(0);
27         Pman.layout.endUpdate(); 
28         Pman.addTopToolbar();  
29         Pman.finalize();
30         Pman.fireEvent('load',this);
31         
32         if (!Pman.layout.getRegion('south').panels.length) {
33             Pman.layout.getRegion('south').hide();
34         }
35     
36     
37 } );
38
39 //Roo.debug = 1;
40   
41
42 Pman = new Roo.Document(
43 {
44    /// appVersion: '1.7', // fixme = needs to be removed - use Global AppVersion
45     subMenuItems : [],
46     topMenuItems : [],
47     rightNames: { }, /// register right names here - so they can be translated and rendered.
48     /**
49      * @property {Roo.menu.Menu} pulldownMenu - the 'add menu pulldown, you can use it to add items..
50      *
51      */
52     pulldownMenu : false, 
53     
54     
55     buildCompleted : false, // flag to say if we are building interface..
56     events : {
57         'beforeload' : true, // fired after page ready, before module building.
58         'load' : true, // fired after module building
59         'authrefreshed' : true // fire on auth updated?? - should be on Login?!?!?
60     },
61     
62     listeners : {
63         'ready' : function()
64         {
65             // kludge to fix firebug debugger
66             if (typeof(console) == 'undefined') {
67                 console = { log : function() {  } };
68             }
69             
70             // remove loader..
71             if (Roo.get('loading')) {
72                 Roo.get('loading').remove();
73             }
74             
75             Roo.state.Manager.setProvider(new Roo.state.CookieProvider());
76             
77             // link errors...
78             
79             if (AppLinkError.length) {
80                 Roo.MessageBox.alert("Error", AppLinkError, function() {
81                     Pman.Login.onLoad();
82                 });
83                 return;
84             }
85             
86             
87             // reset password!!!!
88             if (showNewPass.length) {
89                 Pman.PasswordChange.show(  { passwordReset : showNewPass },
90                     function(data) {
91                         // fail and success we do  a load...
92                         Pman.Login.onLoad();
93                     }
94                 );
95                 return;
96             }
97              
98             Pman.Login.onLoad();
99             
100         },
101         'load' : function()
102         {
103             if (Roo.get('loading-logo-tile')) {
104                 Roo.get('loading-logo-tile').remove();
105             }
106             if (Roo.get('loading-logo-tile-top')) {
107                 Roo.get('loading-logo-tile-top').remove();
108             }
109             if (Roo.get('loading-logo-bottom')) {
110                 Roo.get('loading-logo-bottom').remove();
111             }
112             if (Roo.get('loading-logo-center')) {
113                 Roo.get('loading-logo-center').remove();
114             }
115         }   
116         
117     },
118    
119     fakeRoot :  {
120         modKey : '000',
121         module : 'Pman',
122         region : 'center',
123         parent : false,
124         isTop : true,
125         name : "Pman Base",
126         disabled : false, 
127         permname: '' 
128     },
129     
130     layout: false,
131     
132     onload: function() {
133         //this.fireEvent('beforeload',this);
134         
135         
136         
137         if (this.layout) {
138             return; // already loaded
139         } 
140         if (Roo.get('loading')) {
141             Roo.get('loading').remove();
142         }
143         if (Roo.get('loading-mask')) {
144             Roo.get('loading-mask').show();
145         }
146         
147      
148         var _this = this;
149         this.stime = new Date();
150         this.layout = new Roo.BorderLayout(document.body, {
151             north: {
152                 split:false,
153                 initialSize: 25,
154                 titlebar: false
155             },
156          
157              
158             center: {
159                 titlebar: false,
160                 autoScroll:false,
161                 closeOnTab: true,
162                 tabPosition: 'top',
163                 //resizeTabs: true,
164                 alwaysShowTabs: true,
165                 minTabWidth: 140
166             } ,
167             south: {
168                 collapsible : true,
169                 collapsed : true,
170                 split:false,
171                 height: 120,
172                 titlebar: false 
173             }
174             
175         });
176         
177         
178         Pman.register( Roo.apply(this.fakeRoot, {
179             layout : this.layout      
180                 
181                                  
182         } ) );
183         
184         // creates all the modules ready to load..
185         
186         this.fireEvent('beforeload',this);
187         
188         
189         
190         this.layout.beginUpdate();
191         this.layout.add('north', new Roo.ContentPanel('title', 'North'));
192         var au = Pman.Login.authUser;
193         if (au.id > 0 && au.company_id_background_color && au.company_id_background_color.length) {
194             Roo.get('title').dom.style.backgroundColor = '#' + au.company_id_background_color;
195             Roo.get('headerInformation').dom.style.color = this.invertColor('#' + au.company_id_background_color);
196         }
197         if (au.id > 0 && au.company_id_logo_id * 1 > 0) {
198             Roo.get('headerInformation-company-logo').dom.src =  baseURL + 
199                 '/Images/' + au.company_id_logo_id + '/' + au.company_id_logo_id_filename;
200         } else {
201             Roo.get('headerInformation-company-logo').dom.src = Roo.BLANK_IMAGE_URL;
202         }
203         
204         Roo.get('headerInformation').dom.innerHTML = String.format(
205                 "You are Logged in as <b>{0} ({1})</b>", // to {4} v{3}", // for <b>{2}</b>",
206                 au.name, au.email, au.company_id_name, 
207                 AppVersion , appNameShort
208         );
209         
210         
211         document.title = appName + ' v' + AppVersion + ' - ' + au.company_id_name;
212         Roo.QuickTips.init(); 
213         if (Roo.isGecko) {
214            Roo.useShims = true;
215         }
216        
217         //this.mainLayout.beginUpdate();
218         //var maskDom = Roo.get(document.body)._maskMsg.dom
219         this.layout.beginUpdate();
220         
221         Pman.building = true;
222         Roo.XComponent.build();
223          
224         
225         
226      
227     },
228     
229     addTopToolbar : function()
230     {
231           //console.log( "t6:" + ((new Date())-stime));
232         //this.mainLayout.endUpdate();
233         // make a new tab to hold administration stuff...
234         
235        
236         //console.log( "t7:" + ((new Date())-stime));
237         var se = Pman.layout.getRegion('center').tabs.stripEl;
238         var tbh = se.createChild( 
239                 { tag: 'td', style: 'width:100%;'  });
240         
241         var lotb = new Roo.Toolbar(tbh);
242         
243         if (Roo.isSafari) {
244             var tbl = se.child('table', true);
245             tbl.setAttribute('width', '100%');
246         }
247         lotb.add(
248             new Roo.Toolbar.Fill(), 
249      
250             {
251                 text: "Change Password",
252                 cls: 'x-btn-text-icon',
253                 icon: rootURL + '/Pman/templates/images/change-password.gif',
254                 handler : function(){
255                     Pman.PasswordChange.show({});
256                 }
257             }, '-'
258         );
259          
260         
261         if (this.topMenuItems.length) {
262             
263             Roo.each(this.topMenuItems, function (mi) {
264                 lotb.add(mi);
265             });
266             lotb.add('-');
267         }
268         
269         
270         
271         if (this.subMenuItems.length) {
272             
273             this.subMenuItems.sort(function (a,b) {
274                 return a.seqid > b.seqid ? 1 : -1;
275             });
276             // chop off last seperator.
277             // since we always add it.. just chop of last item
278             this.subMenuItems.pop(); 
279             
280             var btn = new Roo.Toolbar.Button( 
281                 {
282                     text: "Add New Item",
283                     cls: 'x-btn-text-icon',
284                     icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
285                     menu : {
286                         items : this.subMenuItems
287                     }     
288                 }
289             );
290             this.pulldownMenu = btn.menu;
291             lotb.add(btn, '-');
292             
293         }
294        
295         lotb.add(
296             {
297                 text: "Logout",
298                 cls: 'x-btn-text-icon',
299                 icon: rootURL + '/Pman/templates/images/logout.gif',
300                 handler: function() {
301                     Pman.Login.logout();
302                 }
303                  
304             }
305         );
306       
307        // this.layout.endUpdate();
308     },
309     
310     
311     finalize : function() {
312         
313       
314        
315         window.onbeforeunload = function(e) { 
316             e = e || window.event;
317             var r = "Closing this window will loose changes, are you sure you want to do that?";
318
319             // For IE and Firefox
320             if (e) {
321                 e.returnValue = r;
322             }
323
324             // For Safari
325             return r;
326             
327         };
328         
329         Roo.MessageBox.hide();
330         if (Roo.get('loading-mask')) {
331            Roo.get('loading-mask').remove();
332         }
333         
334         
335         this.buildCompleted = true; // now we can force refreshes on everything..
336         
337         
338         // does the URL indicate we want to see a system..
339         if (AppTrackOnLoad * 1 > 0) {
340             this.onLoadTrack(AppTrackOnLoad,false);
341         }
342         
343         // Open system..
344         
345         var forceAdmin = function(data)
346         {
347             if (!data || !data.id) {
348                 //Roo.log("Force Admin");
349                 Pman.Dialog.PersonStaff.show( 
350                     { 
351                         id : 0, 
352                         company_id : Pman.Login.authUser.company_id_id * 1, 
353                         company_id_name : Pman.Login.authUser.company_id_name
354                     }, function(data) {
355                         forceAdmin(data);
356                     }
357                 );
358                 return;
359             }
360             Roo.state.Manager.set('Pman.Login.username', data.email),
361             window.onbeforeunload = false;
362             document.location = baseURL + '?ts=' + Math.random();
363         }
364         
365         var forceCompany = function(data) {
366             if (Pman.Login.authUser.company_id * 1 > 0) {
367                 forceAdmin();
368                 return;
369             }
370             if (!data || !data.id) {
371                 Pman.Dialog.Companies.show( { id : 0, isOwner : 1, comptype: 'OWNER' }, function(data) {
372                     forceCompany(data);
373                 });
374                 return;
375             }
376             Pman.Login.authUser.company_id_id  = data.id;
377             Pman.Login.authUser.company_id  = data.id;
378             Pman.Login.authUser.company_id_name  = data.name;
379             forceAdmin();
380         }
381         
382         if (Pman.Login.authUser.id < 0) {
383             // admin company has been created - create the user..
384             if (Pman.Login.authUser.company_id_id* 1 > 0) {
385                 forceAdmin();
386                 return;
387             }
388             
389             forceCompany();
390             /// create account..
391             
392             
393         }
394         
395
396     },
397     
398     
399     // REMOVE THESE 
400     
401      
402     onLoadTrack : function(id,cb) {
403         this.onLoadTrackCall(id, cb, 'DocumentsCirc_');
404     },
405     onLoadTrackEdit : function(id,cb) {
406         this.onLoadTrackCall(id, cb, 'Documents_');
407     },
408     
409     
410     /// ----------- FIXME -----
411     
412     
413     onLoadTrackCall : function(id,cb, cls) {
414         Roo.get(document.body).mask("Loading Document details");
415
416         Pman.request({
417             url: baseURL + '/Roo/Documents.html',  
418             params: {
419                 _id: id
420             },  
421             method: 'GET',  
422             success : function(data) {
423                 Roo.get(document.body).unmask();
424              
425                 
426                 switch(data.in_out) {
427                     case 'IN' : cls+='In';break;
428                     case 'OUT' : cls+='Out';break;
429                     case 'WIP' : cls+='Wip';break;
430                     default: 
431                         Roo.MessageBox.alert("Error", "invalid in_out");
432                         return;
433                 }
434                 Pman.Dialog[cls].show(data, cb ? cb : Pman.refreshActivePanel);
435             }, 
436             
437             failure: function() {
438                 Roo.get(document.body).unmask();
439                 //if (cb) {
440                 //    cb.call(false);
441                 //}
442                  
443            }
444         });
445           
446     },
447     
448     refreshActivePanel : function() {
449         var actpan = this.layout.getRegion('center').getActivePanel();
450         if (actpan.controller && actpan.controller.paging) {
451             actpan.controller.paging.onClick('refresh');
452             return;
453         }
454         
455         var agid = Pman.layout.getRegion('center').getActivePanel().id;
456         if (!agid) {
457             return;
458         }
459         Pman.Tab[agid].paging.onClick('refresh');
460     },
461     toCidV : function(data) {
462         return 'C' + data.in_out.substring(0,1) + data.cid;
463     },
464     
465     
466     /**
467      * hasPerm:
468      * Does the authenticated user have permission to see this.
469      * 
470      * @param {String} name the [Module].[permission] to check for
471      * @param {Char} lvl  - which type of permission to use (eg. S=show...)
472      * @returns {Boolean} tue indicates permission allowed
473      */
474     hasPerm: function(name, lvl) {
475         if (
476             (typeof(Pman.Login.authUser) != 'object')
477             ||
478             (typeof(Pman.Login.authUser.perms) != 'object')
479             ||
480             (typeof(Pman.Login.authUser.perms[name]) != 'string')
481             ) {
482                 return false;
483         }
484         
485         return Pman.Login.authUser.perms[name].indexOf(lvl) > -1;
486         
487     },
488     /**
489      * hasPermExists:
490      * Is there a permission defined for this (used by module registration.)
491      * 
492      * @param {String} name the [Module].[permission] to check for
493      * @returns {Boolean} tue indicates permission exists.
494      */
495     hasPermExists: function(name) {
496         if (
497             (typeof(Pman.Login.authUser) != 'object')
498             ||
499             (typeof(Pman.Login.authUser.perms) != 'object')
500             ||
501             (typeof(Pman.Login.authUser.perms[name]) != 'string')
502             ) {
503                 return false;
504         }
505         return true;
506     },
507     
508     
509     
510     
511     
512     
513     Readers : {},
514     ColModels : {},
515     Forms : {},
516     Tab : {},
517     Dialog : {},
518     
519     processResponse : function (response)
520     {
521         var res = '';
522         try {
523             res = Roo.decode(response.responseText);
524             // oops...
525             if (typeof(res) != 'object') {
526                 res = { success : false, errorMsg : res, errors : true };
527             }
528             if (typeof(res.success) == 'undefined') {
529                 res.success = false;
530             }
531             
532         } catch(e) {
533             res = { success : false,  errorMsg : response.responseText, errors : true };
534         }
535         return res;
536     },
537     genericDelete : function(tab,tbl) {
538         
539         var r = [];
540         
541             
542         var s = tab.grid.getSelectionModel().getSelections();
543         if (!s.length)  {
544             Roo.MessageBox.alert("Error", "Select at least one Row to delete" );
545             return '';
546         }
547         
548         for(var i = 0; i < s.length; i++) {
549             r.push(s[i].data.id);
550         }
551     
552         Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?",
553             function(btn) {
554                 if (btn != 'yes') {
555                     return;
556                 }
557                 // what about the toolbar??
558                 tab.grid.getView().mainWrap.mask("Deleting");
559                 Pman.request({
560                     url: baseURL + '/Roo/'+tbl+'.php',
561                     method: 'GET',
562                     params: {
563                         _delete : r.join(',')
564                     },
565                     success: function(response) {
566                         tab.grid.getView().mainWrap.unmask();
567                         if ( tab.paging ) {
568                             tab.paging.onClick('refresh');   
569                         } else if (tab.refresh) {
570                             tab.refresh();
571                         } else if (tab.grid.footer && tab.grid.footer.onClick) {
572                             // new xtype built grids
573                             tab.grid.footer.onClick('refresh');   
574                         } else {
575                             tab.grid.getDataSource().load();
576                         }
577                         
578                         
579                         
580                     },
581                     failure: function(act) {
582                         tab.grid.getView().mainWrap.unmask();
583                         Roo.MessageBox.alert("Error", "Error Deleting");
584                     }
585                     
586                 });
587             }
588             
589         );
590         return '';
591     },
592     
593     
594     standardActionFailed :  function(f, act, cb) {
595     
596         if (act.failureType == 'client') {
597             Roo.MessageBox.alert("Error", "Please Correct all the errors in red", cb);
598             return;
599         }
600         if (act.failureType == 'connect') {
601             Roo.MessageBox.alert("Error", "Problem Connecting to Server - please try again.", cb);
602             return;
603         }
604         
605         if (act.type == 'submit') {
606             
607             Roo.MessageBox.alert("Error", typeof(act.result.errorMsg) == 'string' ?
608                 String.format('{0}', act.result.errorMsg) : 
609                 "Saving failed = fix errors and try again", cb);
610             return;
611         }
612         
613         // what about load failing..
614         Roo.MessageBox.alert("Error", "Error loading details",cb); 
615     },
616     /**
617      * Depreciated - USE new Pman.Request
618     * 
619      * 
620      */
621     request : function(c) {
622         var r= new Roo.data.Connection({
623             timeout : typeof(c.timeout) == 'undefined' ?  30000 : c.timeout
624         });
625         r.request({
626             url: c.url,
627             method : c.method,
628             params: c.params,
629             xmlData : c.xmlData,
630             success:  function(response, opts)  {  // check successfull...
631                
632                 var res = Pman.processResponse(response);
633                 
634                 if (!res.success) { // error!
635                     if (c.failure) {
636                         if (true === c.failure.call(this,response, opts)) {
637                             return;
638                         }
639                     }
640                     Roo.MessageBox.hide();
641                     Roo.MessageBox.alert("Error", res.errorMsg ? res.errorMsg : "Error Sending");
642                     return;
643                 }
644                 
645                 c.success.call(this, res.data);
646                 
647                 return; 
648             },
649             failure :  function(response, opts)  {  // check successfull...
650                 
651                 if (c.failure) {
652                     if (true === c.failure.call(this,response, opts)) {
653                         return;
654                     }
655                 }
656                 Roo.MessageBox.hide();
657                 Roo.MessageBox.alert("Error", "Connection timed out sending");
658                 Roo.log(response);
659                 
660             },
661             scope: this
662             
663         });
664     },
665     
666     
667     // depreciated - use Pman.Download()
668     
669     download : function(c) {
670         
671         return new Pman.Download(c);
672     },
673     
674     // fixme - move to document manager...
675     downloadRevision : function(doc, rev)
676     {
677         this.download({
678             url: baseURL + '/Documents/Doc/DownloadRev/'+ doc.id + '/' + rev + '/' +
679                 doc.project_id_code + '-' + doc.cidV + '-' + rev  + '-' +  doc.filename
680         }); 
681                     
682     },
683     
684     
685     exportCSV : function(c) {
686         
687         for(var i=0;i < c.csvFormat.length;i++) {
688             c.params['csvCols['+i+']'] = c.csvFormat[i][0];
689             c.params['csvTitles['+i+']'] = c.csvFormat[i][1];
690         }
691         c.url +=  '?' + Roo.urlEncode(c.params);
692         this.download(c);
693
694     },
695     
696     
697     prettyDate : function (value) 
698     {
699         if (typeof(value) == 'string') {
700             var ds = Date.parseDate(value, 'Y-m-d H:i:s');
701             if (ds) {
702                 return this.prettyDate(ds);
703             }
704             ds = Date.parseDate(value, 'Y-m-d');
705             if (ds) {
706                 return this.prettyDate(ds);
707             }
708             return '';
709         }
710 // last 7 days...
711         if (!value) {
712             return '';
713         }
714         var td = new Date();
715         var daysSince = Math.floor(td.getElapsed(value) / (1000 * 60*60*24));
716         if (daysSince < 7) {
717             return value.dateFormat('D H:i');
718         }
719         
720         // same month
721         if (td.dateFormat('m') == value.dateFormat('m')) {
722             return value.dateFormat('dS D');
723         }
724         // same year?
725         if (td.dateFormat('Y') == value.dateFormat('Y')) {
726             return value.dateFormat('dS M');
727         }
728         return value.dateFormat('d M Y');
729     },
730     loadException : function(a,b,c,d)
731     {
732         if (d && d.authFailure) {
733             Pman.Login.show();
734             return;
735         }
736         Roo.MessageBox.alert("Problem Loading Data", a.message || c.statusText);
737     },
738     
739     
740     /**
741      * 
742      * Routine to flash alerts in the title bar..
743      * 
744      * 
745      */
746     
747     notifyActive : false,
748     
749     notifyTitle: function(msg)
750     {
751         if (this.notifyActive ) {
752             return;
753         }
754         var stop = false;
755         
756         var stopper = function() {
757             stop = true;
758              document.title = oldtitle;
759         };
760         
761         Roo.get(document.body).on('mousemove', stopper, this);
762         var oldtitle = document.title;
763         var s = 1;
764         var _this = this;
765         var ivl = window.setInterval(function() {
766             
767             if (stop) {
768                 Roo.get(document.body).un('mousemove', stopper, this);
769                 _this.notifyActive = false;
770                 document.title = oldtitle;
771                 window.clearInterval(ivl);
772                 return true;
773             }
774             s = !s;
775             document.title = s ? msg : oldtitle;
776             return false;     
777         }, 1000); // every 120 secs = 2mins..
778          document.title =   msg;
779         
780         
781         
782     },
783     /**
784      * @property {Array} appModules  - array based on AppModules global
785      */
786     appModules : false,
787     
788     modules : false,
789     
790     
791     xregister : function(obj)
792     {
793         
794         // work out owner..
795         if (!this.appModules === false) {
796             this.appModules = typeof(AppModules ) == 'undefined'? [] :
797                 AppModules.split(',');
798         }
799         
800         
801         
802         // ignore registration of objects which are disabled.
803         // global supplied by master.html
804         appDisabled = typeof(appDisabled) == 'undefined' ? [] : appDisabled;
805         
806         
807         /// design flaw
808         // previously we did not a good naming policy for module and parts
809         // most things that are called module here, really are 'parts'
810         // new versions should have 'part' as [ module : part ]
811         
812         
813         if (typeof(obj.part) != 'undefined')  {
814             
815             var permname = obj.part.join('.');
816                 // we now have permission...
817                 // obj.moduleOwner '.' lname
818                 
819             if (this.hasPermExists(permname) && !this.hasPerm(permname,'S')) {
820                 // it's a turned off permission...
821                 Roo.log(permname + " is Disabled for this user");
822                 obj.disabled = true;
823                 return;
824             }
825             if (appDisabled.indexOf(permname) > -1)  {
826                 Roo.log(permname + " is Disabled for this site");
827                 obj.disabled = true;
828                 return;
829             }
830             
831             
832         }
833         
834         if ( obj.isTop) {
835             // false parent... use it..
836             return;
837         }
838         
839         
840         if (obj.parent === Pman) {
841             obj.parent = Pman.fakeRoot;
842         }
843         
844         if (typeof(obj.parent) == 'undefined') {
845             console.log("Parent is undefined");
846             console.log(obj);
847             obj.disabled = true;
848             return;
849         }
850             
851             
852         if (obj.parent === false) {
853             obj.disabled = true;
854             console.log('ignoring top level object (as parent===false found)');
855             console.log(obj);
856             return;
857         }
858         // this is an error condition - the parent does not exist..
859             // technically it should not happen..
860           
861         // hack for Pman parent == Pman..
862         if (obj.parent == obj.module) {
863             obj.parent = false;
864             
865         }
866        
867         
868     },
869     /**
870      * DEPRICATED : use Roo.XComponents now..
871      * 
872      * Pman.register({
873           modKey : '00-admin-xxxx',
874           module : Pman.Tab.projectMgr, << really a components..
875           part : [ 'Admin', 'ProjectManager' ]
876           moduleOwner : 
877           region : 'center',
878           parent : Pman.layout
879         })
880      * 
881      */
882     register : function(obj)
883     {
884         
885         //this.xregister(obj);
886         
887         
888         // old style calls go in here..
889         // we need to convert the object so that it looks a bit like an XCompoenent..
890          
891         obj.render = function()
892         {
893             if (!this.parent) {
894                 Roo.log("Skip module, as parent does not exist");
895                 Roo.log(this);
896                 return;
897             }
898             //if (typeof(mod) == 'function') {
899             //    mod();
900                 
901             if (typeof(this.region) == 'undefined') {
902                 Roo.log("Module does not have region defined, skipping");
903                 Roo.log(this);
904                 return;
905             }
906             if (this.module.disabled) {
907                 Roo.log("Module disabled, should not rendering")
908                 Roo.log(this);
909                 return;
910             }
911             
912             if (!this.parent.layout) {
913                 Roo.log("Module parent does not have property layout.")
914                 Roo.log(this);
915                 return;
916             }
917         
918            // honour DEPRICATED permname setings..
919            // new code should use PART name, and matching permissions.
920             if (this.permname && this.permname.length) {
921                 if (!Pman.hasPerm(this.permname, 'S')) {
922                     return;
923                 }
924                 
925             }
926             this.add(this.parent.layout, this.region);
927             this.el = this.layout;
928             
929             
930               
931         };
932         // map some of the standard properties..
933         obj.order = obj.modKey;
934         
935         // a bit risky...
936         
937         
938         
939         // the other issue we have is that
940          
941         
942         // Roo.log("CALLING XComponent register with : " + obj.name);
943         
944         // this will call xregister as it's the on.register handler..
945         Roo.XComponent.register(obj.isTop ? obj : Roo.apply(obj.module, obj));
946          
947     } ,
948     invertColor : function(c)
949     {
950         // read..
951         var ca = [];
952         for(var i = 0; i < 3; i++){
953             ca[i] = parseInt(c.charAt((i*2)+1) + c.charAt((i*2)+2), 16);
954         }
955             
956         // invert..
957         var col = '';
958         Roo.each(ca, function(hi) {
959             var h = parseInt(255-hi).toString(16);
960             if(h < 16){
961                 h = '0' + h;
962             }
963             col += h;
964         });
965         return '#' + col;
966         
967     }
968     
969     
970     
971     
972     
973     
974     
975 });
976