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                             },
121                             containerScroll : true,
122                             ddGroup : 'dbtree',
123                             enableDD : true,
124                             rootVisible : false,
125                             loader : {
126                                 xtype: 'TreeLoader',
127                                 xns: Roo.tree,
128                                 listeners : {
129                                     create : function (_self, attr)
130                                     {
131                                         Roo.log("CREATE");
132                                         try {
133                                             attr.text = attr.name.length ? attr.name : attr.descrip;
134                                             
135                                             attr.leaf = attr.name.length ? true : false;
136                                             attr.html = String.format('<B>{0}</B><i>{1}</i>',
137                                                 attr.name,
138                                                 attr.descrip
139                                             );
140                                         } catch(e) {
141                                             Roo.log(e);
142                                         }
143                                         Roo.log(attr);
144                                     
145                                     }
146                                 },
147                                 queryParam : 'parent_id',
148                                 requestMethod : 'GET',
149                                 root : 'data',
150                                 baseParams : { _tree: 1, 'sort': 'name', dir: 'ASC', limit : 9999 },
151                                 dataUrl : baseURL + '/Roo/Builder_tables.php'
152                             },
153                             root : {
154                                 xtype: 'AsyncTreeNode',
155                                 xns: Roo.tree,
156                                 text : "TOP LEVEL"
157                             },
158                             sm : {
159                                 xtype: 'DefaultSelectionModel',
160                                 xns: Roo.tree
161                             },
162                             editor : {
163                                 xtype: 'TreeEditor',
164                                 xns: Roo.tree,
165                                 listeners : {
166                                     beforenodeedit : function (_self,node)
167                                     {
168                                         Roo.log('before start edit');
169                                         Roo.log(this.editNode);
170                                         if (node.attributes.name.length) {
171                                             return false;
172                                         }
173                                         return true;
174                                         
175                                     }
176                                 }
177                             }
178                         },
179                         menu : {
180                             xtype: 'Menu',
181                             xns: Roo.menu,
182                             items : [
183                                 {
184                                     xtype: 'Item',
185                                     xns: Roo.menu,
186                                     text : "Add Group"
187                                 }
188                             ]
189                         }
190                     },
191                     {
192                         xtype: 'GridPanel',
193                         xns: Roo,
194                         listeners : {
195                             activate : function() {
196                                 _this.panel = this;
197                                 if (_this.grid) {
198                                     _this.grid.footer.onClick('first');
199                                 }
200                             }
201                         },
202                         background : true,
203                         fitContainer : true,
204                         fitToframe : true,
205                         region : 'center',
206                         tableName : 'Tables',
207                         title : "Tables",
208                         grid : {
209                             xtype: 'Grid',
210                             xns: Roo.grid,
211                             listeners : {
212                                 render : function() 
213                                 {
214                                     _this.grid = this; 
215                                     //_this.dialog = Pman.Dialog.FILL_IN
216                                     if (_this.panel.active) {
217                                        this.footer.onClick('first');
218                                     }
219                                 },
220                                 rowdblclick : function (_self, rowIndex, e)
221                                 {
222                                     if (!_this.dialog) return;
223                                     _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
224                                         _this.grid.footer.onClick('first');
225                                     }); 
226                                 }
227                             },
228                             autoExpandColumn : 'table',
229                             loadMask : true,
230                             dataSource : {
231                                 xtype: 'Store',
232                                 xns: Roo.data,
233                                 remoteSort : true,
234                                 sortInfo : { field : 'filename', direction: 'ASC' },
235                                 proxy : {
236                                     xtype: 'HttpProxy',
237                                     xns: Roo.data,
238                                     method : 'GET',
239                                     url : baseURL + '/Builder/ERM.php'
240                                 },
241                                 reader : {
242                                     xtype: 'JsonReader',
243                                     xns: Roo.data,
244                                     totalProperty : 'total',
245                                     root : 'data',
246                                     id : 'id',
247                                     fields : [
248                                         {
249                                             'name': 'id',
250                                             'type': 'int'
251                                         },
252                                         {
253                                             'name': 'filename',
254                                             'type': 'string'
255                                         },
256                                         {
257                                             'name': 'ontable',
258                                             'type': 'string'
259                                         },
260                                         {
261                                             'name': 'onid',
262                                             'type': 'int'
263                                         },
264                                         {
265                                             'name': 'mimetype',
266                                             'type': 'string'
267                                         },
268                                         {
269                                             'name': 'width',
270                                             'type': 'int'
271                                         },
272                                         {
273                                             'name': 'height',
274                                             'type': 'int'
275                                         },
276                                         {
277                                             'name': 'filesize',
278                                             'type': 'int'
279                                         },
280                                         {
281                                             'name': 'displayorder',
282                                             'type': 'int'
283                                         },
284                                         {
285                                             'name': 'language',
286                                             'type': 'string'
287                                         },
288                                         {
289                                             'name': 'parent_image_id',
290                                             'type': 'int'
291                                         },
292                                         {
293                                             'name': 'created',
294                                             'type': 'date',
295                                             'dateFormat': 'Y-m-d'
296                                         },
297                                         {
298                                             'name': 'imgtype',
299                                             'type': 'string'
300                                         },
301                                         {
302                                             'name': 'linkurl',
303                                             'type': 'string'
304                                         },
305                                         {
306                                             'name': 'descript',
307                                             'type': 'string'
308                                         },
309                                         {
310                                             'name': 'title',
311                                             'type': 'string'
312                                         },
313                                         {
314                                             'name': 'credit',
315                                             'type': 'string'
316                                         },
317                                         {
318                                             'name': 'source',
319                                             'type': 'string'
320                                         },
321                                         {
322                                             'name': 'parent_image_id_id',
323                                             'type': 'int'
324                                         },
325                                         {
326                                             'name': 'parent_image_id_filename',
327                                             'type': 'string'
328                                         },
329                                         {
330                                             'name': 'parent_image_id_ontable',
331                                             'type': 'string'
332                                         },
333                                         {
334                                             'name': 'parent_image_id_onid',
335                                             'type': 'int'
336                                         },
337                                         {
338                                             'name': 'parent_image_id_mimetype',
339                                             'type': 'string'
340                                         },
341                                         {
342                                             'name': 'parent_image_id_width',
343                                             'type': 'int'
344                                         },
345                                         {
346                                             'name': 'parent_image_id_height',
347                                             'type': 'int'
348                                         },
349                                         {
350                                             'name': 'parent_image_id_filesize',
351                                             'type': 'int'
352                                         },
353                                         {
354                                             'name': 'parent_image_id_displayorder',
355                                             'type': 'int'
356                                         },
357                                         {
358                                             'name': 'parent_image_id_language',
359                                             'type': 'string'
360                                         },
361                                         {
362                                             'name': 'parent_image_id_parent_image_id',
363                                             'type': 'int'
364                                         },
365                                         {
366                                             'name': 'parent_image_id_created',
367                                             'type': 'date'
368                                         },
369                                         {
370                                             'name': 'parent_image_id_imgtype',
371                                             'type': 'string'
372                                         },
373                                         {
374                                             'name': 'parent_image_id_linkurl',
375                                             'type': 'string'
376                                         },
377                                         {
378                                             'name': 'parent_image_id_descript',
379                                             'type': 'string'
380                                         },
381                                         {
382                                             'name': 'parent_image_id_title',
383                                             'type': 'string'
384                                         },
385                                         {
386                                             'name': 'parent_image_id_credit',
387                                             'type': 'string'
388                                         },
389                                         {
390                                             'name': 'parent_image_id_source',
391                                             'type': 'string'
392                                         }
393                                     ]
394                                 }
395                             },
396                             footer : {
397                                 xtype: 'PagingToolbar',
398                                 xns: Roo,
399                                 pageSize : 25,
400                                 displayInfo : true,
401                                 displayMsg : "Displaying Images{0} - {1} of {2}",
402                                 emptyMsg : "No Images found"
403                             },
404                             toolbar : {
405                                 xtype: 'Toolbar',
406                                 xns: Roo,
407                                 items : [
408                                     {
409                                         xtype: 'Button',
410                                         xns: Roo.Toolbar,
411                                         listeners : {
412                                             click : function()
413                                             {
414                                                 Roo.MessageBox.alert("Updating", "Updating the cache");
415                                                 new Pman.Request({
416                                                     url : baseURL + '/Core/RefreshDatabaseCache',
417                                                     method : 'GET',
418                                                     success : function() {
419                                                         Roo.MessageBox.hide();
420                                                     }
421                                                 });
422                                             }
423                                         },
424                                         cls : 'x-btn-text-icon',
425                                         text : "Refresh Schema",
426                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
427                                     }
428                                 ]
429                             },
430                             colModel : [
431                                 {
432                                     xtype: 'ColumnModel',
433                                     xns: Roo.grid,
434                                     dataIndex : 'table',
435                                     header : 'Table',
436                                     width : 200,
437                                     renderer : function(v) { return String.format('{0}', v); }
438                                 }
439                             ]
440                         }
441                     }
442                 ],
443                 west : {
444                     xtype: 'LayoutRegion',
445                     xns: Roo,
446                     split : true,
447                     width : 150
448                 },
449                 center : {
450                     xtype: 'LayoutRegion',
451                     xns: Roo
452                 }
453             }
454         });
455         this.layout = this.panel.layout;
456
457     }
458 });