Pman.Tab.BuilderDatabase.bjs
[Pman.Builder] / Pman.Tab.BuilderDatabase.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.BuilderDatabase = new Roo.XComponent({
8
9  _strings : {
10   'dc45dca245ff2f7b0a897d8a21b1873b' :"Displaying Images{0} - {1} of {2}",
11   '64e05c1766219647a3861e1419c75b6e' :"TOP LEVEL",
12   '651ae5789ab776f2fcaf80b5e62801dc' :"Tables",
13   '0c81971f67c0bd4b33799c5365ec2bf5' :"No Images found",
14   '6a844388ad911a9a292ca8936cd01208' :"Remove Group",
15   '4de4baf3480c0029c625937efcc38c37' :"Add Table/Container",
16   '51c45b795d5d18a3e4e0c37e8b20a141' :"Table",
17   '2f1fb3d9f25082e7fdb0befdad16da5f' :"Export Data",
18   '73eaab781d40c3cc779790197fbaae86' :"Manage Database",
19   'e1a0e2b1f38b57a8dc5aa6fecf0d5174' :"Sync Tables",
20   '81906cf98aa73f3353f46859f79e7ba1' :"Refresh/Manage Tables",
21   'b112803ab9deb7deba2a6b24ef3bb91a' :"Add Group",
22   'c1218806136c5a6445dcc48cec641fec' :"Refresh Schema"
23  },
24
25   part     :  ["Builder", "Database" ],
26   order    : '999-Pman.Tab.BuilderDatabase',
27   region   : 'center',
28   parent   : 'Pman.Tab.Builder',
29   name     : "Pman.Tab.BuilderDatabase",
30   disabled : false, 
31   permname : '', 
32   _tree : function()
33   {
34    var _this = this;
35    var MODULE = this;
36    return {
37    xtype : 'NestedLayoutPanel',
38    background : true,
39    region : 'center',
40    title : _this._strings['73eaab781d40c3cc779790197fbaae86'] /* Manage Database */,
41    listeners : {
42     activate : function (_self)
43      {
44       _this.treepanel.tree.root.reload();
45      }
46    },
47    xns : Roo,
48    '|xns' : 'Roo',
49    layout : {
50     xtype : 'BorderLayout',
51     xns : Roo,
52     '|xns' : 'Roo',
53     center : {
54      xtype : 'LayoutRegion',
55      xns : Roo,
56      '|xns' : 'Roo'
57     },
58     west : {
59      xtype : 'LayoutRegion',
60      split : true,
61      width : 150,
62      xns : Roo,
63      '|xns' : 'Roo'
64     },
65     items  : [
66      {
67       xtype : 'TreePanel',
68       region : 'west',
69       listeners : {
70        render : function (_self)
71         {
72            _this.treepanel = _self;
73         }
74       },
75       xns : Roo,
76       '|xns' : 'Roo',
77       menu : {
78        xtype : 'Menu',
79        xns : Roo.menu,
80        '|xns' : 'Roo.menu',
81        items  : [
82         {
83          xtype : 'Item',
84          text : _this._strings['b112803ab9deb7deba2a6b24ef3bb91a'] /* Add Group */,
85          listeners : {
86           click : function (_self, e)
87            {
88                _this.nIndex =     _this.nIndex || 0;
89                
90                var m = _this.cxnode.firstChild ? 'insertBefore' : 'appendChild';
91                var tree =  _this.treepanel.tree;
92                
93                var n = tree.loader.createNode({
94                    id : -1,
95                    descrip :'New Group ' + (++_this.nIndex), 
96                    name : ''
97                }); 
98                
99                var node = _this.cxnode[m]( n , _this.cxnode.firstChild);
100                setTimeout(function(){
101                        tree.editor.editNode = node;
102                        tree.editor.startEdit(node.ui.textNode);
103                    }, 10);
104            }
105          },
106          xns : Roo.menu,
107          '|xns' : 'Roo.menu'
108         },
109         {
110          xtype : 'Separator',
111          xns : Roo.menu,
112          '|xns' : 'Roo.menu'
113         },
114         {
115          xtype : 'Item',
116          text : _this._strings['6a844388ad911a9a292ca8936cd01208'] /* Remove Group */,
117          listeners : {
118           click : function (_self, e)
119            {
120                _this.nIndex =     _this.nIndex || 0;
121                
122                _this.cxnode;
123                // try and delete it..
124                new Pman.Request({
125                    url : baseURL + '/Roo/Builder_tables',
126                    params : {
127                        _delete : _this.cxnode.attributes.id
128                    },
129                    success : function() {
130                        _this.cxnode.parentNode.removeChild(_this.cxnode);
131                        _this.cxnode = false;
132                    
133                    }
134                });
135                
136            }
137          },
138          xns : Roo.menu,
139          '|xns' : 'Roo.menu'
140         }
141        ]
142       },
143       toolbar : {
144        xtype : 'Toolbar',
145        xns : Roo,
146        '|xns' : 'Roo',
147        items  : [
148         {
149          xtype : 'SplitButton',
150          text : _this._strings['81906cf98aa73f3353f46859f79e7ba1'] /* Refresh/Manage Tables */,
151          listeners : {
152           click : function (_self, e)
153            {
154             _this.treepanel.tree.root.reload();
155            }
156          },
157          xns : Roo.Toolbar,
158          '|xns' : 'Roo.Toolbar',
159          menu : {
160           xtype : 'Menu',
161           xns : Roo.menu,
162           '|xns' : 'Roo.menu',
163           items  : [
164            {
165             xtype : 'Item',
166             text : _this._strings['4de4baf3480c0029c625937efcc38c37'] /* Add Table/Container */,
167             xns : Roo.menu,
168             '|xns' : 'Roo.menu'
169            },
170            {
171             xtype : 'Separator',
172             xns : Roo.menu,
173             '|xns' : 'Roo.menu'
174            },
175            {
176             xtype : 'Item',
177             text : _this._strings['e1a0e2b1f38b57a8dc5aa6fecf0d5174'] /* Sync Tables */,
178             listeners : {
179              click : function (_self, e)
180               {
181                   new Pman.Request({
182                       method: 'GET',
183                       url: baseURL + '/Roo/Builder_tables.php',
184                       params : {
185                            _sync : 1
186                       }
187                   });
188                       
189               }
190             },
191             xns : Roo.menu,
192             '|xns' : 'Roo.menu'
193            },
194            {
195             xtype : 'Separator',
196             xns : Roo.menu,
197             '|xns' : 'Roo.menu'
198            },
199            {
200             xtype : 'Item',
201             text : _this._strings['2f1fb3d9f25082e7fdb0befdad16da5f'] /* Export Data */,
202             listeners : {
203              click : function (_self, e)
204               {
205               /*
206                   var node = _this.treepanel.tree.getSelectionModel().getSelectedNode();   
207                   
208                   if(!node){
209                       Roo.MessageBox.alert('Error', 'Please select a table');
210                       return;
211                   } 
212                   
213                   Roo.log(node.attributes.name);
214                   */
215                   new Pman.Download({
216                       url : baseURL + '/Roo/Builder_tables.php',
217                       timeout : 900000,
218                       params : {
219                           _dumpDatabase : 1
220                       },
221                       method : 'GET',
222                       success : function() {
223                       
224                       }
225                   });
226               }
227             },
228             xns : Roo.menu,
229             '|xns' : 'Roo.menu'
230            }
231           ]
232          }
233         }
234        ]
235       },
236       tree : {
237        xtype : 'TreePanel',
238        containerScroll : true,
239        ddGroup : 'dbtree',
240        enableDD : true,
241        rootVisible : false,
242        listeners : {
243         beforeload : function (node)
244          {
245              if (!_this.panel.active) {
246                  return false;
247              }
248          },
249         beforenodedrop : function (dropEvent)
250          {
251              Roo.log(dropEvent);
252              var node = dropEvent.dropNode;
253              var targ = dropEvent.target;
254              var parent = dropEvent.target;
255              switch(dropEvent.point) {
256                  case 'below': 
257                   case 'above':  
258                      parent = dropEvent.target.parentNode;
259                      break;
260                  default:
261                      break;
262              }
263              // technically you should not be able to drag tables into other modules..
264              if (parent.attributes.id < 1) {
265                  dropEvent.cancel = 1;
266              }
267              new Pman.Request({
268                  url : baseURL + '/Roo/Builder_tables',
269                  params : {
270                      id : node.attributes.id,
271                      parent_id : parent.attributes.id
272                  }
273              });
274              
275              
276          },
277         contextmenu : function (node, e)
278          {
279              if (!node.expanded || node.leaf) {
280                  return;
281              }
282          
283             _this.treepanel.menu = Roo.factory(_this.treepanel.menu);
284             _this.treepanel.menu.show(node.ui.anchor,'tr');
285             _this.cxnode = node;
286          }
287        },
288        xns : Roo.tree,
289        '|xns' : 'Roo.tree',
290        editor : {
291         xtype : 'TreeEditor',
292         listeners : {
293          beforenodeedit : function (_self,node)
294           {
295               Roo.log('before start edit');
296               Roo.log(this.editNode);
297               if (node.attributes.name.length) {
298                   return false;
299               }
300               return true;
301               
302           },
303          complete : function (_self, value, startValue)
304           {
305               Roo.log(this.editNode);
306           
307               var attr = this.editNode.attributes;
308               
309               var pa = this.editNode.parentNode.attributes;
310               Roo.log(pa);
311               var pr =  {
312            
313                   parent_id : pa.id,
314                   descrip : value,
315                   name : '',
316                   dbschema : ''
317               };
318                   
319               if (attr.id > 0) {
320                   pr.id = attr.id;
321               }
322               
323               new Pman.Request({
324                   url : baseURL + '/Roo/Builder_tables',
325                   method : 'POST',
326                   params : pr
327               });
328               
329               
330               
331           }
332         },
333         xns : Roo.tree,
334         '|xns' : 'Roo.tree'
335        },
336        root : {
337         xtype : 'AsyncTreeNode',
338         text : _this._strings['64e05c1766219647a3861e1419c75b6e'] /* TOP LEVEL */,
339         xns : Roo.tree,
340         '|xns' : 'Roo.tree'
341        },
342        loader : {
343         xtype : 'TreeLoader',
344         baseParams : { _tree: 1, 'sort': 'name', dir: 'ASC', limit : 9999 },
345         dataUrl : baseURL + '/Roo/Builder_tables.php',
346         queryParam : 'parent_id',
347         requestMethod : 'GET',
348         root : 'data',
349         listeners : {
350          create : function (_self, attr)
351           {
352               Roo.log("CREATE");
353               try {
354                   attr.text = attr.name.length ? attr.name : attr.descrip;
355                   
356                   attr.leaf = attr.name.length ? true : false;
357                   attr.html = String.format('<B>{0}</B><i>{1}</i>',
358                       attr.name,
359                       attr.descrip
360                   );
361               } catch(e) {
362                   Roo.log(e);
363               }
364               
365               Roo.log(attr);
366           
367           }
368         },
369         xns : Roo.tree,
370         '|xns' : 'Roo.tree'
371        },
372        sm : {
373         xtype : 'MultiSelectionModel',
374         xns : Roo.tree,
375         '|xns' : 'Roo.tree'
376        }
377       }
378      },
379      {
380       xtype : 'GridPanel',
381       background : true,
382       fitContainer : true,
383       fitToframe : true,
384       region : 'center',
385       tableName : 'Tables',
386       title : _this._strings['651ae5789ab776f2fcaf80b5e62801dc'] /* Tables */,
387       listeners : {
388        activate : function() {
389             _this.panel = this;
390             if (_this.grid) {
391                 _this.grid.footer.onClick('first');
392             }
393         }
394       },
395       xns : Roo,
396       '|xns' : 'Roo',
397       grid : {
398        xtype : 'Grid',
399        autoExpandColumn : 'table',
400        loadMask : true,
401        listeners : {
402         render : function() 
403          {
404              _this.grid = this; 
405              //_this.dialog = Pman.Dialog.FILL_IN
406              if (_this.panel.active) {
407                 this.footer.onClick('first');
408              }
409          },
410         rowdblclick : function (_self, rowIndex, e)
411          {
412              if (!_this.dialog) return;
413              _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
414                  _this.grid.footer.onClick('first');
415              }); 
416          }
417        },
418        xns : Roo.grid,
419        '|xns' : 'Roo.grid',
420        footer : {
421         xtype : 'PagingToolbar',
422         displayInfo : true,
423         displayMsg : _this._strings['dc45dca245ff2f7b0a897d8a21b1873b'] /* Displaying Images{0} - {1} of {2} */,
424         emptyMsg : _this._strings['0c81971f67c0bd4b33799c5365ec2bf5'] /* No Images found */,
425         pageSize : 25,
426         xns : Roo,
427         '|xns' : 'Roo'
428        },
429        toolbar : {
430         xtype : 'Toolbar',
431         xns : Roo,
432         '|xns' : 'Roo',
433         items  : [
434          {
435           xtype : 'Button',
436           cls : 'x-btn-text-icon',
437           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
438           text : _this._strings['c1218806136c5a6445dcc48cec641fec'] /* Refresh Schema */,
439           listeners : {
440            click : function()
441             {
442                 Roo.MessageBox.alert("Updating", "Updating the cache");
443                 new Pman.Request({
444                     url : baseURL + '/Core/RefreshDatabaseCache',
445                     method : 'GET',
446                     success : function() {
447                         Roo.MessageBox.hide();
448                     }
449                 });
450             }
451           },
452           xns : Roo.Toolbar,
453           '|xns' : 'Roo.Toolbar'
454          }
455         ]
456        },
457        dataSource : {
458         xtype : 'Store',
459         remoteSort : true,
460         sortInfo : { field : 'filename', direction: 'ASC' },
461         xns : Roo.data,
462         '|xns' : 'Roo.data',
463         proxy : {
464          xtype : 'HttpProxy',
465          method : 'GET',
466          url : baseURL + '/Builder/ERM.php',
467          xns : Roo.data,
468          '|xns' : 'Roo.data'
469         },
470         reader : {
471          xtype : 'JsonReader',
472          fields : [
473              {
474                  'name': 'id',
475                  'type': 'int'
476              },
477              {
478                  'name': 'filename',
479                  'type': 'string'
480              },
481              {
482                  'name': 'ontable',
483                  'type': 'string'
484              },
485              {
486                  'name': 'onid',
487                  'type': 'int'
488              },
489              {
490                  'name': 'mimetype',
491                  'type': 'string'
492              },
493              {
494                  'name': 'width',
495                  'type': 'int'
496              },
497              {
498                  'name': 'height',
499                  'type': 'int'
500              },
501              {
502                  'name': 'filesize',
503                  'type': 'int'
504              },
505              {
506                  'name': 'displayorder',
507                  'type': 'int'
508              },
509              {
510                  'name': 'language',
511                  'type': 'string'
512              },
513              {
514                  'name': 'parent_image_id',
515                  'type': 'int'
516              },
517              {
518                  'name': 'created',
519                  'type': 'date',
520                  'dateFormat': 'Y-m-d'
521              },
522              {
523                  'name': 'imgtype',
524                  'type': 'string'
525              },
526              {
527                  'name': 'linkurl',
528                  'type': 'string'
529              },
530              {
531                  'name': 'descript',
532                  'type': 'string'
533              },
534              {
535                  'name': 'title',
536                  'type': 'string'
537              },
538              {
539                  'name': 'credit',
540                  'type': 'string'
541              },
542              {
543                  'name': 'source',
544                  'type': 'string'
545              },
546              {
547                  'name': 'parent_image_id_id',
548                  'type': 'int'
549              },
550              {
551                  'name': 'parent_image_id_filename',
552                  'type': 'string'
553              },
554              {
555                  'name': 'parent_image_id_ontable',
556                  'type': 'string'
557              },
558              {
559                  'name': 'parent_image_id_onid',
560                  'type': 'int'
561              },
562              {
563                  'name': 'parent_image_id_mimetype',
564                  'type': 'string'
565              },
566              {
567                  'name': 'parent_image_id_width',
568                  'type': 'int'
569              },
570              {
571                  'name': 'parent_image_id_height',
572                  'type': 'int'
573              },
574              {
575                  'name': 'parent_image_id_filesize',
576                  'type': 'int'
577              },
578              {
579                  'name': 'parent_image_id_displayorder',
580                  'type': 'int'
581              },
582              {
583                  'name': 'parent_image_id_language',
584                  'type': 'string'
585              },
586              {
587                  'name': 'parent_image_id_parent_image_id',
588                  'type': 'int'
589              },
590              {
591                  'name': 'parent_image_id_created',
592                  'type': 'date'
593              },
594              {
595                  'name': 'parent_image_id_imgtype',
596                  'type': 'string'
597              },
598              {
599                  'name': 'parent_image_id_linkurl',
600                  'type': 'string'
601              },
602              {
603                  'name': 'parent_image_id_descript',
604                  'type': 'string'
605              },
606              {
607                  'name': 'parent_image_id_title',
608                  'type': 'string'
609              },
610              {
611                  'name': 'parent_image_id_credit',
612                  'type': 'string'
613              },
614              {
615                  'name': 'parent_image_id_source',
616                  'type': 'string'
617              }
618          ],
619          id : 'id',
620          root : 'data',
621          totalProperty : 'total',
622          xns : Roo.data,
623          '|xns' : 'Roo.data'
624         }
625        },
626        colModel : [
627         {
628          xtype : 'ColumnModel',
629          dataIndex : 'table',
630          header : _this._strings['51c45b795d5d18a3e4e0c37e8b20a141'] /* Table */,
631          renderer : function(v) { return String.format('{0}', v); },
632          width : 200,
633          xns : Roo.grid,
634          '|xns' : 'Roo.grid'
635         }
636        ]
637       }
638      }
639     ]
640    }
641   };  }
642 });