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