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
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         part :  ["Builder","Database"],
12         modKey : '999-Pman.Tab.BuilderDatabase',
13         module : Pman.Tab.BuilderDatabase,
14         region : 'center',
15         parent : Pman.Tab.Builder,
16         name : "Pman.Tab.BuilderDatabase",
17         disabled : false, 
18         permname: '' 
19     });
20 });
21
22 Pman.Tab.BuilderDatabase = new Roo.util.Observable({
23
24     panel : false,
25     disabled : false,
26     parentLayout:  false,
27
28     add : function(parentLayout, region)
29     {
30
31         var _this = this;
32         this.parentLayout = parentLayout;
33
34         this.panel = parentLayout.addxtype({
35             xtype: 'NestedLayoutPanel',
36             xns: Roo,
37             listeners : {
38                 activate : function (_self)
39                 {
40                  _this.treepanel.tree.root.reload();
41                 }
42             },
43             background : true,
44             region : 'center',
45             title : "Manage Database",
46             layout : {
47                 xtype: 'BorderLayout',
48                 xns: Roo,
49                 items : [
50                     {
51                         xtype: 'TreePanel',
52                         xns: Roo,
53                         listeners : {
54                             render : function (_self)
55                             {
56                                _this.treepanel = _self;
57                             }
58                         },
59                         region : 'west',
60                         toolbar : {
61                             xtype: 'Toolbar',
62                             xns: Roo,
63                             items : [
64                                 {
65                                     xtype: 'SplitButton',
66                                     xns: Roo.Toolbar,
67                                     listeners : {
68                                         click : function (_self, e)
69                                         {
70                                          _this.treepanel.tree.root.reload();
71                                         }
72                                     },
73                                     text : "Refresh/Manage Tables",
74                                     menu : {
75                                         xtype: 'Menu',
76                                         xns: Roo.menu,
77                                         items : [
78                                             {
79                                                 xtype: 'Item',
80                                                 xns: Roo.menu,
81                                                 text : "Add Table/Container"
82                                             },
83                                             {
84                                                 xtype: 'Separator',
85                                                 xns: Roo.menu
86                                             },
87                                             {
88                                                 xtype: 'Item',
89                                                 xns: Roo.menu,
90                                                 listeners : {
91                                                     click : function (_self, e)
92                                                     {
93                                                         new Pman.Request({
94                                                             method: 'GET',
95                                                             url: baseURL + '/Roo/Builder_tables.php',
96                                                             params : {
97                                                                  _sync : 1
98                                                             }
99                                                         });
100                                                             
101                                                     }
102                                                 },
103                                                 text : "Sync Tables"
104                                             }
105                                         ]
106                                     }
107                                 }
108                             ]
109                         },
110                         tree : {
111                             xtype: 'TreePanel',
112                             xns: Roo.tree,
113                             listeners : {
114                                 beforeload : function (node)
115                                 {
116                                     if (!_this.panel.active) {
117                                         return false;
118                                     }
119                                 },
120                                 contextmenu : function (node, e)
121                                 {
122                                     if (!node.expanded || node.leaf) {
123                                         return;
124                                     }
125                                 
126                                    _this.treepanel.menu = Roo.factory(_this.treepanel.menu);
127                                    _this.treepanel.menu.show(node.ui.anchor,'tr');
128                                    _this.cxnode = node;
129                                 }
130                             },
131                             containerScroll : true,
132                             ddGroup : 'dbtree',
133                             enableDD : true,
134                             rootVisible : false,
135                             loader : {
136                                 xtype: 'TreeLoader',
137                                 xns: Roo.tree,
138                                 listeners : {
139                                     create : function (_self, attr)
140                                     {
141                                         Roo.log("CREATE");
142                                         try {
143                                             attr.text = attr.name.length ? attr.name : attr.descrip;
144                                             
145                                             attr.leaf = attr.name.length ? true : false;
146                                             attr.html = String.format('<B>{0}</B><i>{1}</i>',
147                                                 attr.name,
148                                                 attr.descrip
149                                             );
150                                         } catch(e) {
151                                             Roo.log(e);
152                                         }
153                                         Roo.log(attr);
154                                     
155                                     }
156                                 },
157                                 queryParam : 'parent_id',
158                                 requestMethod : 'GET',
159                                 root : 'data',
160                                 baseParams : { _tree: 1, 'sort': 'name', dir: 'ASC', limit : 9999 },
161                                 dataUrl : baseURL + '/Roo/Builder_tables.php'
162                             },
163                             root : {
164                                 xtype: 'AsyncTreeNode',
165                                 xns: Roo.tree,
166                                 text : "TOP LEVEL"
167                             },
168                             sm : {
169                                 xtype: 'DefaultSelectionModel',
170                                 xns: Roo.tree
171                             },
172                             editor : {
173                                 xtype: 'TreeEditor',
174                                 xns: Roo.tree,
175                                 listeners : {
176                                     beforenodeedit : function (_self,node)
177                                     {
178                                         Roo.log('before start edit');
179                                         Roo.log(this.editNode);
180                                         if (node.attributes.name.length) {
181                                             return false;
182                                         }
183                                         return true;
184                                         
185                                     }
186                                 }
187                             }
188                         },
189                         menu : {
190                             xtype: 'Menu',
191                             xns: Roo.menu,
192                             items : [
193                                 {
194                                     xtype: 'Item',
195                                     xns: Roo.menu,
196                                     listeners : {
197                                         click : function (_self, e)
198                                         {
199                                             _this.nIndex =     _this.nIndex || 0;
200                                             
201                                             var m = _this.cxnode.firstChild ? 'insertBefore' : 'appendChild';
202                                             
203                                             var n = _this.treepanel.laoder.createNode({
204                                                 id : 0,
205                                                 descrip :'New Group ' + (++_this.nIndex), 
206                                                 name : ''
207                                             }); 
208                                             
209                                             _this.cxnode[m]( n , _this.cxnode.firstChild);
210                                             
211                                         }
212                                     },
213                                     text : "Add Group"
214                                 }
215                             ]
216                         }
217                     },
218                     {
219                         xtype: 'GridPanel',
220                         xns: Roo,
221                         listeners : {
222                             activate : function() {
223                                 _this.panel = this;
224                                 if (_this.grid) {
225                                     _this.grid.footer.onClick('first');
226                                 }
227                             }
228                         },
229                         background : true,
230                         fitContainer : true,
231                         fitToframe : true,
232                         region : 'center',
233                         tableName : 'Tables',
234                         title : "Tables",
235                         grid : {
236                             xtype: 'Grid',
237                             xns: Roo.grid,
238                             listeners : {
239                                 render : function() 
240                                 {
241                                     _this.grid = this; 
242                                     //_this.dialog = Pman.Dialog.FILL_IN
243                                     if (_this.panel.active) {
244                                        this.footer.onClick('first');
245                                     }
246                                 },
247                                 rowdblclick : function (_self, rowIndex, e)
248                                 {
249                                     if (!_this.dialog) return;
250                                     _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
251                                         _this.grid.footer.onClick('first');
252                                     }); 
253                                 }
254                             },
255                             autoExpandColumn : 'table',
256                             loadMask : true,
257                             dataSource : {
258                                 xtype: 'Store',
259                                 xns: Roo.data,
260                                 remoteSort : true,
261                                 sortInfo : { field : 'filename', direction: 'ASC' },
262                                 proxy : {
263                                     xtype: 'HttpProxy',
264                                     xns: Roo.data,
265                                     method : 'GET',
266                                     url : baseURL + '/Builder/ERM.php'
267                                 },
268                                 reader : {
269                                     xtype: 'JsonReader',
270                                     xns: Roo.data,
271                                     totalProperty : 'total',
272                                     root : 'data',
273                                     id : 'id',
274                                     fields : [
275                                         {
276                                             'name': 'id',
277                                             'type': 'int'
278                                         },
279                                         {
280                                             'name': 'filename',
281                                             'type': 'string'
282                                         },
283                                         {
284                                             'name': 'ontable',
285                                             'type': 'string'
286                                         },
287                                         {
288                                             'name': 'onid',
289                                             'type': 'int'
290                                         },
291                                         {
292                                             'name': 'mimetype',
293                                             'type': 'string'
294                                         },
295                                         {
296                                             'name': 'width',
297                                             'type': 'int'
298                                         },
299                                         {
300                                             'name': 'height',
301                                             'type': 'int'
302                                         },
303                                         {
304                                             'name': 'filesize',
305                                             'type': 'int'
306                                         },
307                                         {
308                                             'name': 'displayorder',
309                                             'type': 'int'
310                                         },
311                                         {
312                                             'name': 'language',
313                                             'type': 'string'
314                                         },
315                                         {
316                                             'name': 'parent_image_id',
317                                             'type': 'int'
318                                         },
319                                         {
320                                             'name': 'created',
321                                             'type': 'date',
322                                             'dateFormat': 'Y-m-d'
323                                         },
324                                         {
325                                             'name': 'imgtype',
326                                             'type': 'string'
327                                         },
328                                         {
329                                             'name': 'linkurl',
330                                             'type': 'string'
331                                         },
332                                         {
333                                             'name': 'descript',
334                                             'type': 'string'
335                                         },
336                                         {
337                                             'name': 'title',
338                                             'type': 'string'
339                                         },
340                                         {
341                                             'name': 'credit',
342                                             'type': 'string'
343                                         },
344                                         {
345                                             'name': 'source',
346                                             'type': 'string'
347                                         },
348                                         {
349                                             'name': 'parent_image_id_id',
350                                             'type': 'int'
351                                         },
352                                         {
353                                             'name': 'parent_image_id_filename',
354                                             'type': 'string'
355                                         },
356                                         {
357                                             'name': 'parent_image_id_ontable',
358                                             'type': 'string'
359                                         },
360                                         {
361                                             'name': 'parent_image_id_onid',
362                                             'type': 'int'
363                                         },
364                                         {
365                                             'name': 'parent_image_id_mimetype',
366                                             'type': 'string'
367                                         },
368                                         {
369                                             'name': 'parent_image_id_width',
370                                             'type': 'int'
371                                         },
372                                         {
373                                             'name': 'parent_image_id_height',
374                                             'type': 'int'
375                                         },
376                                         {
377                                             'name': 'parent_image_id_filesize',
378                                             'type': 'int'
379                                         },
380                                         {
381                                             'name': 'parent_image_id_displayorder',
382                                             'type': 'int'
383                                         },
384                                         {
385                                             'name': 'parent_image_id_language',
386                                             'type': 'string'
387                                         },
388                                         {
389                                             'name': 'parent_image_id_parent_image_id',
390                                             'type': 'int'
391                                         },
392                                         {
393                                             'name': 'parent_image_id_created',
394                                             'type': 'date'
395                                         },
396                                         {
397                                             'name': 'parent_image_id_imgtype',
398                                             'type': 'string'
399                                         },
400                                         {
401                                             'name': 'parent_image_id_linkurl',
402                                             'type': 'string'
403                                         },
404                                         {
405                                             'name': 'parent_image_id_descript',
406                                             'type': 'string'
407                                         },
408                                         {
409                                             'name': 'parent_image_id_title',
410                                             'type': 'string'
411                                         },
412                                         {
413                                             'name': 'parent_image_id_credit',
414                                             'type': 'string'
415                                         },
416                                         {
417                                             'name': 'parent_image_id_source',
418                                             'type': 'string'
419                                         }
420                                     ]
421                                 }
422                             },
423                             footer : {
424                                 xtype: 'PagingToolbar',
425                                 xns: Roo,
426                                 pageSize : 25,
427                                 displayInfo : true,
428                                 displayMsg : "Displaying Images{0} - {1} of {2}",
429                                 emptyMsg : "No Images found"
430                             },
431                             toolbar : {
432                                 xtype: 'Toolbar',
433                                 xns: Roo,
434                                 items : [
435                                     {
436                                         xtype: 'Button',
437                                         xns: Roo.Toolbar,
438                                         listeners : {
439                                             click : function()
440                                             {
441                                                 Roo.MessageBox.alert("Updating", "Updating the cache");
442                                                 new Pman.Request({
443                                                     url : baseURL + '/Core/RefreshDatabaseCache',
444                                                     method : 'GET',
445                                                     success : function() {
446                                                         Roo.MessageBox.hide();
447                                                     }
448                                                 });
449                                             }
450                                         },
451                                         cls : 'x-btn-text-icon',
452                                         text : "Refresh Schema",
453                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
454                                     }
455                                 ]
456                             },
457                             colModel : [
458                                 {
459                                     xtype: 'ColumnModel',
460                                     xns: Roo.grid,
461                                     dataIndex : 'table',
462                                     header : 'Table',
463                                     width : 200,
464                                     renderer : function(v) { return String.format('{0}', v); }
465                                 }
466                             ]
467                         }
468                     }
469                 ],
470                 west : {
471                     xtype: 'LayoutRegion',
472                     xns: Roo,
473                     split : true,
474                     width : 150
475                 },
476                 center : {
477                     xtype: 'LayoutRegion',
478                     xns: Roo
479                 }
480             }
481         });
482         this.layout = this.panel.layout;
483
484     }
485 });