Pman.Tab.BuilderTop.bjs
[Pman.Builder] / Pman.Tab.BuilderTop.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","Top"],
12         modKey : '001-Pman.Tab.BuilderTop',
13         module : Pman.Tab.BuilderTop,
14         region : 'center',
15         parent : Pman.Tab.BuilderTab,
16         name : "Pman.Tab.BuilderTop",
17         disabled : false, 
18         permname: '' 
19     });
20 });
21
22 Pman.Tab.BuilderTop = 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: 'ContentPanel',
36             xns: Roo,
37             background : true,
38             fitToFrame : true,
39             region : 'north',
40             toolbar : {
41                 xtype: 'Toolbar',
42                 xns: Roo,
43                 items : [
44                     {
45                         xtype: 'Button',
46                         xns: Roo.Toolbar,
47                         text : "Manage Modules",
48                         menu : {
49                             xtype: 'Menu',
50                             xns: Roo.menu,
51                             items : [
52                                 {
53                                     xtype: 'Item',
54                                     xns: Roo.menu,
55                                     listeners : {
56                                         click : function (_self, e)
57                                         {
58                                             Pman.Dialog.BuilderModule.show({
59                                                  id : 0
60                                             },function(data) {
61                                                 if (data) {
62                                                    _this.modsel.setFromData(data);
63                                                 }
64                                             });
65                                         
66                                         }
67                                     },
68                                     text : "Create",
69                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
70                                 },
71                                 {
72                                     xtype: 'Item',
73                                     xns: Roo.menu,
74                                     listeners : {
75                                         click : function (_self, e)
76                                         {
77                                          
78                                             if (!_this.modsel.getValue()) {
79                                                 Roo.MessageBox.alert("Error", "Select Module");
80                                                 return false;
81                                             }
82                                             Pman.Dialog.BuilderModule.show( { id : _this.modsel.getValue() } ,function(data) {
83                                                 if (data) {
84                                                     _this.modsel.setFromData(data);
85                                                 }
86                                             });
87                                         
88                                         }
89                                     },
90                                     text : "Edit"
91                                 },
92                                 {
93                                     xtype: 'Item',
94                                     xns: Roo.menu,
95                                     listeners : {
96                                         click : function (_self, e)
97                                         {
98                                            
99                                         
100                                         }
101                                     },
102                                     text : "Delete"
103                                 },
104                                 {
105                                     xtype: 'Separator',
106                                     xns: Roo.menu
107                                 },
108                                 {
109                                     xtype: 'Item',
110                                     xns: Roo.menu,
111                                     listeners : {
112                                         click : function (_self, e)
113                                         {
114                                             new Pman.Request({
115                                                 method : 'GET',
116                                                 url : baseURL + '/Roo/Builder_modules.php',
117                                                 params : {
118                                                     'query[_sync]' : 1
119                                                 },
120                                                 success : function() {
121                                                     Roo.MessageBox.alert("Done", "Re-syned modules");
122                                                 }
123                                             });
124                                         }
125                                     },
126                                     text : "Sync"
127                                 }
128                             ]
129                         }
130                     },
131                     {
132                         xtype: 'ComboBox',
133                         xns: Roo.form,
134                         listeners : {
135                             select : function (combo, record, index)
136                             {
137                                 _this.filesel.reset();
138                                 _this.filesel.fireEvent('select', false);
139                             
140                             },
141                             render : function (_self)
142                             {
143                                 _this.modsel = this;
144                             }
145                         },
146                         allowBlank : true,
147                         alwaysQuery : true,
148                         displayField : 'name',
149                         editable : false,
150                         forceSelection : true,
151                         listWidth : 300,
152                         loadingText : "Searching...",
153                         minChars : 2,
154                         pageSize : 40,
155                         queryParam : 'query[name]',
156                         selectOnFocus : true,
157                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b></div>',
158                         triggerAction : 'all',
159                         typeAhead : true,
160                         valueField : 'id',
161                         width : 100,
162                         store : {
163                             xtype: 'Store',
164                             xns: Roo.data,
165                             remoteSort : true,
166                             sortInfo : { field : 'name' , direction : 'ASC' },
167                             proxy : {
168                                 xtype: 'HttpProxy',
169                                 xns: Roo.data,
170                                 method : 'GET',
171                                 url : baseURL + '/Roo/Builder_modules.php'
172                             },
173                             reader : {
174                                 xtype: 'JsonReader',
175                                 xns: Roo.data,
176                                 id : 'id',
177                                 root : 'data',
178                                 totalProperty : 'total',
179                                 fields : [
180                                  
181                                     {
182                                         'name': 'name',
183                                         'type': 'string'
184                                     }
185                                     
186                                 ]
187                             }
188                         }
189                     },
190                     {
191                         xtype: 'Button',
192                         xns: Roo.Toolbar,
193                         text : "Manage Parts ",
194                         menu : {
195                             xtype: 'Menu',
196                             xns: Roo.menu,
197                             items : [
198                                 {
199                                     xtype: 'Item',
200                                     xns: Roo.menu,
201                                     listeners : {
202                                         click : function (_self, e)
203                                         {
204                                             if (!_this.modsel.getValue()) {
205                                                 Roo.MessageBox.alert("Error", "Select Module");
206                                                 return false;
207                                             }
208                                             
209                                             Pman.Dialog.BuilderPart.show( {
210                                                      id : 0, 
211                                                      module_id: _this.modsel.getValue() 
212                                                  } ,
213                                                  function(data) {
214                                                     _this.filesel.reset();
215                                                     if (!data.id) {
216                                                         return;
217                                                     }
218                                                     _this.filesel.setfromdata(data);
219                                                     Pman.Builder.Tree.clearAll();
220                                                     Pman.Builder.Tree.setCurrentNode(Pman.Tab.BuilderTree.tree.root,true);
221                                                      
222                                                     Pman.Tab.BuilderPanel.redraw.defer(100,Pman.Tab.BuilderPanel,[true]);
223                                             });
224                                         
225                                         }
226                                     },
227                                     text : "New Part",
228                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
229                                 },
230                                 {
231                                     xtype: 'Item',
232                                     xns: Roo.menu,
233                                     listeners : {
234                                         click : function (_self, e)
235                                         {
236                                             Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete it?", function(a) {
237                                                 if (a != 'yes') {
238                                                     return;
239                                                 }
240                                                     
241                                                
242                                                new Pman.Request({
243                                                     url : baseURL + '/Roo/Builder_part',
244                                                     method : 'POST',
245                                                     params : {
246                                                         _delete :  _this.filesel.getValue()
247                                                     },
248                                                     success : function() {
249                                                         _this.fileCombo.setValue('');
250                                                         // unload stuff..
251                                                         Pman.Tab.BuilderTab.layout.getRegion('west').el.mask("select part")
252                                                     
253                                                     }
254                                                
255                                                
256                                                });
257                                            });
258                                         }
259                                     },
260                                     text : "Delete"
261                                 }
262                             ]
263                         }
264                     },
265                     {
266                         xtype: 'ComboBox',
267                         xns: Roo.form,
268                         listeners : {
269                             select : function (combo, rec, index)
270                             {
271                                //cb.lastData = rec.data;
272                                 
273                                 
274                                 
275                                 
276                                 var bt = Pman.Tab.BuilderTree.tree;
277                                 var pt = Pman.Builder.Tree;
278                                 
279                                 if (!rec) {
280                                     pt.clearAll();
281                                     pt.setCurrentNode(bt.root,true);
282                                    // var bv = Pman.Tab.BuilderView;
283                                    Pman.Tab.BuilderView.panel.clearAll();
284                                    // bv.panel.el.mask("select Module / Part");
285                                     return;
286                                 }
287                                 //bv.panel.el.unmask();
288                                 
289                                 pt.loadBJS(_this.modsel.getValue(), rec.data.id)
290                             
291                             
292                             },
293                             render : function (_self)
294                             {
295                                 _this.filesel = this;
296                             }
297                         },
298                         allowBlank : true,
299                         alwaysQuery : true,
300                         displayField : 'name',
301                         editable : false,
302                         forceSelection : true,
303                         listWidth : 400,
304                         loadingText : "Searching...",
305                         minChars : 2,
306                         pageSize : 40,
307                         queryParam : 'query[name]',
308                         selectOnFocus : true,
309                         tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b></div>',
310                         triggerAction : 'all',
311                         typeAhead : true,
312                         valueField : 'id',
313                         width : 200,
314                         store : {
315                             xtype: 'Store',
316                             xns: Roo.data,
317                             listeners : {
318                                 beforeload : function (_self, o)
319                                 {
320                                      o.params = o.params || {}; 
321                                    // o.params.btype = 'FORM';
322                                     if (!_this.modsel.getValue()) {
323                                         Roo.MessageBox.alert("Error", "Select Module");
324                                         return false;
325                                     }
326                                     o.params.module_id = _this.modsel.getValue();
327                                     o.params._columns = 'id,name';
328                                 }
329                             },
330                             remoteSort : true,
331                             sortInfo : { field : 'name' , direction : 'ASC' },
332                             proxy : {
333                                 xtype: 'HttpProxy',
334                                 xns: Roo.data,
335                                 method : 'GET',
336                                 url : baseURL + '/Roo/Builder_part.php'
337                             },
338                             reader : {
339                                 xtype: 'JsonReader',
340                                 xns: Roo.data,
341                                 id : 'id',
342                                 root : 'data',
343                                 totalProperty : 'total',
344                                 fields : [
345                                    
346                                     {
347                                         'name': 'name',
348                                         'type': 'string'
349                                     } 
350                                 ]
351                             }
352                         }
353                     },
354                     {
355                         xtype: 'SplitButton',
356                         xns: Roo.Toolbar,
357                         listeners : {
358                             click : function (_self, e)
359                             {
360                                 Pman.Builder.save();
361                             },
362                             render : function (_self)
363                             {
364                                _this.saveBtn = this;
365                             }
366                         },
367                         cls : 'x-btn-text-icon',
368                         text : "Save",
369                         icon : rootURL + '/Pman/templates/images/save.gif',
370                         menu : {
371                             xtype: 'Menu',
372                             xns: Roo.menu,
373                             items : [
374                                 {
375                                     xtype: 'Item',
376                                     xns: Roo.menu,
377                                     listeners : {
378                                         click : function (_self, e)
379                                         {
380                                               Pman.Builder.save(false,0);
381                                         }
382                                     },
383                                     text : "Save a copy as",
384                                     icon : rootURL + '/Pman/templates/images/save.gif'
385                                 },
386                                 {
387                                     xtype: 'Item',
388                                     xns: Roo.menu,
389                                     listeners : {
390                                         click : function (_self, e)
391                                         {
392                                            Pman.Builder.save(
393                                              function(data) {
394                                              Roo.log("JSON GOT");
395                                                   Roo.log(data);
396                                                  Pman.Dialog.BuilderViewCode.show(data ); 
397                                                     
398                                         
399                                           } );
400                                         }
401                                     },
402                                     text : "Show JSON"
403                                 }
404                             ]
405                         }
406                     },
407                     {
408                         xtype: 'Separator',
409                         xns: Roo.Toolbar
410                     },
411                     {
412                         xtype: 'SplitButton',
413                         xns: Roo.Toolbar,
414                         listeners : {
415                             click : function (_self, e)
416                             {
417                                Pman.Tab.BuilderView.panel.redraw();
418                             }
419                         },
420                         text : "Redraw",
421                         menu : {
422                             xtype: 'Menu',
423                             xns: Roo.menu,
424                             items : [
425                                 {
426                                     xtype: 'Item',
427                                     xns: Roo.menu,
428                                     listeners : {
429                                         click : function (_self, e)
430                                         {
431                                          _this.redrawBtn.setText("Redraw (AUTO OFF)");
432                                             _this.redrawBtn.auto = 0;
433                                         
434                                         }
435                                     },
436                                     text : "Auto redraw - OFF"
437                                 },
438                                 {
439                                     xtype: 'Item',
440                                     xns: Roo.menu,
441                                     listeners : {
442                                         click : function (_self, e)
443                                         {
444                                          
445                                             _this.redrawBtn.setText("Redraw");
446                                              _this.redrawBtn.auto = 1;
447                                             var bp = Pman.Tab.BuilderPanel;
448                                             bp.redraw.defer(100,bp,[true]);
449                                             
450                                         
451                                         }
452                                     },
453                                     text : "Auto redraw - On"
454                                 }
455                             ]
456                         }
457                     }
458                 ]
459             }
460         });
461         this.layout = this.panel.layout;
462
463     }
464 });