php7 fixes
[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) {
413                  return;
414              }
415              
416              _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
417                  _this.grid.footer.onClick('first');
418              }); 
419          }
420        },
421        xns : Roo.grid,
422        '|xns' : 'Roo.grid',
423        footer : {
424         xtype : 'PagingToolbar',
425         displayInfo : true,
426         displayMsg : _this._strings['dc45dca245ff2f7b0a897d8a21b1873b'] /* Displaying Images{0} - {1} of {2} */,
427         emptyMsg : _this._strings['0c81971f67c0bd4b33799c5365ec2bf5'] /* No Images found */,
428         pageSize : 25,
429         xns : Roo,
430         '|xns' : 'Roo'
431        },
432        toolbar : {
433         xtype : 'Toolbar',
434         xns : Roo,
435         '|xns' : 'Roo',
436         items  : [
437          {
438           xtype : 'Button',
439           cls : 'x-btn-text-icon',
440           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
441           text : _this._strings['c1218806136c5a6445dcc48cec641fec'] /* Refresh Schema */,
442           listeners : {
443            click : function()
444             {
445                 Roo.MessageBox.alert("Updating", "Updating the cache");
446                 new Pman.Request({
447                     url : baseURL + '/Core/RefreshDatabaseCache',
448                     method : 'GET',
449                     success : function() {
450                         Roo.MessageBox.hide();
451                     }
452                 });
453             }
454           },
455           xns : Roo.Toolbar,
456           '|xns' : 'Roo.Toolbar'
457          }
458         ]
459        },
460        dataSource : {
461         xtype : 'Store',
462         remoteSort : true,
463         sortInfo : { field : 'filename', direction: 'ASC' },
464         xns : Roo.data,
465         '|xns' : 'Roo.data',
466         proxy : {
467          xtype : 'HttpProxy',
468          method : 'GET',
469          url : baseURL + '/Builder/ERM.php',
470          xns : Roo.data,
471          '|xns' : 'Roo.data'
472         },
473         reader : {
474          xtype : 'JsonReader',
475          fields : [
476              {
477                  'name': 'id',
478                  'type': 'int'
479              },
480              {
481                  'name': 'filename',
482                  'type': 'string'
483              },
484              {
485                  'name': 'ontable',
486                  'type': 'string'
487              },
488              {
489                  'name': 'onid',
490                  'type': 'int'
491              },
492              {
493                  'name': 'mimetype',
494                  'type': 'string'
495              },
496              {
497                  'name': 'width',
498                  'type': 'int'
499              },
500              {
501                  'name': 'height',
502                  'type': 'int'
503              },
504              {
505                  'name': 'filesize',
506                  'type': 'int'
507              },
508              {
509                  'name': 'displayorder',
510                  'type': 'int'
511              },
512              {
513                  'name': 'language',
514                  'type': 'string'
515              },
516              {
517                  'name': 'parent_image_id',
518                  'type': 'int'
519              },
520              {
521                  'name': 'created',
522                  'type': 'date',
523                  'dateFormat': 'Y-m-d'
524              },
525              {
526                  'name': 'imgtype',
527                  'type': 'string'
528              },
529              {
530                  'name': 'linkurl',
531                  'type': 'string'
532              },
533              {
534                  'name': 'descript',
535                  'type': 'string'
536              },
537              {
538                  'name': 'title',
539                  'type': 'string'
540              },
541              {
542                  'name': 'credit',
543                  'type': 'string'
544              },
545              {
546                  'name': 'source',
547                  'type': 'string'
548              },
549              {
550                  'name': 'parent_image_id_id',
551                  'type': 'int'
552              },
553              {
554                  'name': 'parent_image_id_filename',
555                  'type': 'string'
556              },
557              {
558                  'name': 'parent_image_id_ontable',
559                  'type': 'string'
560              },
561              {
562                  'name': 'parent_image_id_onid',
563                  'type': 'int'
564              },
565              {
566                  'name': 'parent_image_id_mimetype',
567                  'type': 'string'
568              },
569              {
570                  'name': 'parent_image_id_width',
571                  'type': 'int'
572              },
573              {
574                  'name': 'parent_image_id_height',
575                  'type': 'int'
576              },
577              {
578                  'name': 'parent_image_id_filesize',
579                  'type': 'int'
580              },
581              {
582                  'name': 'parent_image_id_displayorder',
583                  'type': 'int'
584              },
585              {
586                  'name': 'parent_image_id_language',
587                  'type': 'string'
588              },
589              {
590                  'name': 'parent_image_id_parent_image_id',
591                  'type': 'int'
592              },
593              {
594                  'name': 'parent_image_id_created',
595                  'type': 'date'
596              },
597              {
598                  'name': 'parent_image_id_imgtype',
599                  'type': 'string'
600              },
601              {
602                  'name': 'parent_image_id_linkurl',
603                  'type': 'string'
604              },
605              {
606                  'name': 'parent_image_id_descript',
607                  'type': 'string'
608              },
609              {
610                  'name': 'parent_image_id_title',
611                  'type': 'string'
612              },
613              {
614                  'name': 'parent_image_id_credit',
615                  'type': 'string'
616              },
617              {
618                  'name': 'parent_image_id_source',
619                  'type': 'string'
620              }
621          ],
622          id : 'id',
623          root : 'data',
624          totalProperty : 'total',
625          xns : Roo.data,
626          '|xns' : 'Roo.data'
627         }
628        },
629        colModel : [
630         {
631          xtype : 'ColumnModel',
632          dataIndex : 'table',
633          header : _this._strings['51c45b795d5d18a3e4e0c37e8b20a141'] /* Table */,
634          renderer : function(v) { return String.format('{0}', v); },
635          width : 200,
636          xns : Roo.grid,
637          '|xns' : 'Roo.grid'
638         }
639        ]
640       }
641      }
642     ]
643    }
644   };  }
645 });