Pman.Tab.BAdminCoreEnum.bjs
[Pman.BAdmin] / Pman.Tab.BAdminCoreEnum.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
8
9  _strings : {
10   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
11   '2df80d5febcde0c10a66818488622b7c' :"Pulldown Options",
12   '7dce122004969d56ae2e0245cb754d35' :"Edit",
13   '01abfc750a0c942167651c40d088531d' :"#",
14   'dae8ace18bdcbcc6ae5aece263e14fe8' :"Options",
15   'b48968e1c912da07df5e8d6d246291ec' :"Display Name",
16   'f2d346b1bb7c1c85ab6f7f21e3666b9f' :"Types",
17   '49ee3087348e8d44e1feda1917443987' :"Name",
18   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
19   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active"
20  },
21
22   part     :  ["BAdmin", "CoreEnum" ],
23   order    : '005-Pman.Tab.BAdminCoreEnum',
24   region   : 'center',
25   parent   : 'Pman.Tab.BAdmin',
26   name     : "unnamed module",
27   disabled : false, 
28   permname : '', 
29   _tree : function(_data)
30   {
31    var _this = this;
32    var MODULE = this;
33    return {
34    xtype : 'Nest',
35    background : true,
36    title : _this._strings['2df80d5febcde0c10a66818488622b7c'] /* Pulldown Options */,
37    xns : Roo.bootstrap.panel,
38    '|xns' : 'Roo.bootstrap.panel',
39    layout : {
40     xtype : 'Border',
41     xns : Roo.bootstrap.layout,
42     '|xns' : 'Roo.bootstrap.layout',
43     center : {
44      xtype : 'Region',
45      hideTabs : true,
46      tabPosition : 'top',
47      xns : Roo.bootstrap.layout,
48      '|xns' : 'Roo.bootstrap.layout'
49     },
50     west : {
51      xtype : 'Region',
52      hideTabs : true,
53      split : true,
54      tabPosition : 'top',
55      width : 350,
56      xns : Roo.bootstrap.layout,
57      '|xns' : 'Roo.bootstrap.layout'
58     },
59     items  : [
60      {
61       xtype : 'Grid',
62       background : false,
63       closable : false,
64       fitContainer : true,
65       fitToFrame : true,
66       region : 'west',
67       title : _this._strings['f2d346b1bb7c1c85ab6f7f21e3666b9f'] /* Types */,
68       listeners : {
69        activate : function (_self)
70         {
71             if(_this.type_grid) {
72                 _this.type_grid.footer.onClick('first');
73             }
74         },
75        render : function (_self)
76         {
77             _this.type_panel = _self; 
78         }
79       },
80       xns : Roo.bootstrap.panel,
81       '|xns' : 'Roo.bootstrap.panel',
82       toolbar : {
83        xtype : 'NavSimplebar',
84        xns : Roo.bootstrap,
85        '|xns' : 'Roo.bootstrap',
86        items  : [
87         {
88          xtype : 'NavGroup',
89          xns : Roo.bootstrap,
90          '|xns' : 'Roo.bootstrap',
91          items  : [
92           {
93            xtype : 'NavItem',
94            xns : Roo.bootstrap,
95            '|xns' : 'Roo.bootstrap',
96            items  : [
97             {
98              xtype : 'Button',
99              glyphicon : 'plus',
100              html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
101              style : 'margin: 10px;',
102              weight : 'default',
103              listeners : {
104               click : function (_self, e)
105                {
106                    Pman.Dialog.BAdminCoreEnum.show({ 
107                        id : 0
108                    }, function(res) {
109                        _this.type_grid.footer.onClick('first');
110                    });
111                
112                }
113              },
114              xns : Roo.bootstrap,
115              '|xns' : 'Roo.bootstrap'
116             }
117            ]
118           }
119          ]
120         }
121        ]
122       },
123       grid : {
124        xtype : 'Table',
125        cellSelection : true,
126        cls : 'table-fixed',
127        hover : true,
128        loadMask : true,
129        responsive : true,
130        rowSelection : true,
131        striped : false,
132        listeners : {
133         render : function (_self)
134          {
135              _this.type_grid = _self; 
136             
137          },
138         rowdblclick : function (_self, el, rowIndex, e)
139          {
140              var r = _this.type_grid.store.getAt(rowIndex);
141              
142              if(!r || r.data.id * 1 < 1){
143                  return;
144              }
145              
146              Pman.Dialog.BAdminCoreEnum.show({ 
147                  id : r.data.id
148              }, function(res) {
149                  _this.type_grid.footer.onClick('first');
150              });
151          }
152        },
153        xns : Roo.bootstrap,
154        '|xns' : 'Roo.bootstrap',
155        footer : {
156         xtype : 'PagingToolbar',
157         displayInfo : false,
158         name : 'footer',
159         pageSize : 100,
160         xns : Roo.bootstrap,
161         '|xns' : 'Roo.bootstrap'
162        },
163        store : {
164         xtype : 'Store',
165         remoteSort : true,
166         sortInfo : { field : 'display_name', direction: 'ASC' },
167         listeners : {
168          beforeload : function (_self, o)
169           {
170               o.params = o.params || {};
171               
172               o.params['query[empty_etype]'] = 1;
173               
174           }
175         },
176         xns : Roo.data,
177         '|xns' : 'Roo.data',
178         proxy : {
179          xtype : 'HttpProxy',
180          method : 'GET',
181          url : baseURL + '/Roo/core_enum.php',
182          xns : Roo.data,
183          '|xns' : 'Roo.data'
184         },
185         reader : {
186          xtype : 'JsonReader',
187          fields : [
188              {
189                  'name': 'id',
190                  'type': 'int'
191              },
192              {
193                  'name': 'etype',
194                  'type': 'string'
195              },
196              {
197                  'name': 'name',
198                  'type': 'string'
199              },
200              {
201                  'name': 'display_name',
202                  'type': 'string'
203              },
204              {
205                  'name': 'active',
206                  'type': 'int'
207              },
208              {
209                  'name': 'seqid',
210                  'type': 'int'
211              }
212          ],
213          id : 'id',
214          root : 'data',
215          totalProperty : 'total',
216          xns : Roo.data,
217          '|xns' : 'Roo.data'
218         }
219        },
220        sm : {
221         xtype : 'RowSelectionModel',
222         singleSelect : true,
223         listeners : {
224          selectionchange : function (_self)
225           {
226               _this.option_grid.store.load({});
227           }
228         },
229         xns : Roo.bootstrap.Table,
230         '|xns' : 'Roo.bootstrap.Table'
231        },
232        cm : [
233         {
234          xtype : 'ColumnModel',
235          dataIndex : 'display_name',
236          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
237          renderer : function(v,x,r) {
238              Roo.log(v);
239              return String.format('<span tooltip="{1}">Coba: {0}</span>', v, r.data.name); 
240          },
241          sortable : true,
242          xs : 12,
243          xns : Roo.grid,
244          '|xns' : 'Roo.grid'
245         }
246        ]
247       }
248      },
249      {
250       xtype : 'Grid',
251       background : false,
252       fitContainer : true,
253       fitToFrame : true,
254       region : 'center',
255       title : _this._strings['dae8ace18bdcbcc6ae5aece263e14fe8'] /* Options */,
256       listeners : {
257        activate : function (_self)
258         {
259             if (_this.option_grid) {
260                 _this.option_grid.store.load({});
261         //        _this.option_grid.footer.onClick('first');
262             }
263         },
264        render : function (_self)
265         {
266             _this.option_panel = _self;
267         }
268       },
269       xns : Roo.bootstrap.panel,
270       '|xns' : 'Roo.bootstrap.panel',
271       toolbar : {
272        xtype : 'NavSimplebar',
273        xns : Roo.bootstrap,
274        '|xns' : 'Roo.bootstrap',
275        items  : [
276         {
277          xtype : 'NavGroup',
278          xns : Roo.bootstrap,
279          '|xns' : 'Roo.bootstrap',
280          items  : [
281           {
282            xtype : 'NavItem',
283            xns : Roo.bootstrap,
284            '|xns' : 'Roo.bootstrap',
285            items  : [
286             {
287              xtype : 'Button',
288              glyphicon : 'plus',
289              html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
290              style : 'margin: 10px;',
291              weight : 'default',
292              listeners : {
293               click : function (_self, e)
294                {
295                    var sel = _this.type_grid.getSelectionModel().getSelected();
296                    
297                    if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length ){
298                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a type');
299                        return;
300                    }
301                
302                    Pman.Dialog.BAdminCoreEnum.show({ 
303                        id : 0,
304                        etype : sel.data.name
305                    }, function(res) {
306                        _this.option_grid.store.load({});
307                    });
308                
309                }
310              },
311              xns : Roo.bootstrap,
312              '|xns' : 'Roo.bootstrap'
313             },
314             {
315              xtype : 'Button',
316              glyphicon : 'pencil',
317              html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
318              style : 'margin: 10px;',
319              weight : 'default',
320              listeners : {
321               click : function (_self, e)
322                {
323                    var sel = _this.option_grid.getSelectionModel().getSelected();
324                    
325                    if(!sel || sel.data.id * 1 < 1){
326                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
327                        return;
328                    }
329                
330                    Pman.Dialog.BAdminCoreEnum.show({ 
331                        id : sel.data.id
332                    }, function(res) {
333                        _this.option_grid.store.load({});
334                    });
335                
336                }
337              },
338              xns : Roo.bootstrap,
339              '|xns' : 'Roo.bootstrap'
340             },
341             {
342              xtype : 'Button',
343              glyphicon : 'trash',
344              html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
345              style : 'margin: 10px;',
346              weight : 'primary',
347              listeners : {
348               click : function (_self, e)
349                {
350                    var sel = _this.option_grid.getSelectionModel().getSelected();
351                    
352                    if(!sel || sel.data.id * 1 < 1){
353                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
354                        return;
355                    }
356                
357                    new Pman.Request({
358                        url: baseURL + '/Roo/Core_enum.php',
359                        method : 'POST',
360                        params : {
361                            _delete : sel.data.id
362                        }, 
363                        success : function(res) {
364                            _this.option_grid.store.load({});
365                        }
366                    });
367                
368                }
369              },
370              xns : Roo.bootstrap,
371              '|xns' : 'Roo.bootstrap'
372             }
373            ]
374           }
375          ]
376         }
377        ]
378       },
379       grid : {
380        xtype : 'Table',
381        cellSelection : true,
382        cls : 'table-fixed',
383        footerShow : false,
384        hover : true,
385        loadMask : true,
386        responsive : true,
387        rowSelection : true,
388        striped : true,
389        listeners : {
390         cellclick : function (_self, el, rowIndex, columnIndex, e)
391          {
392              var di = _this.option_grid.colModel.getDataIndex(columnIndex);
393              
394              if (di != 'active') {
395                  return;
396              }
397               
398              var rec = _this.option_grid.store.getAt(rowIndex);
399              
400              rec.set('active', rec.data.active ? 0 : 1);
401              
402              rec.commit();
403          },
404         render : function (_self)
405          {
406              _this.option_grid = _self; 
407          
408          },
409         rowdblclick : function (_self, el, rowIndex, e)
410          {
411              var sel = _this.option_grid.store.getAt(rowIndex);
412              
413              if(!sel || sel.data.id * 1 < 1){
414                  return;
415              }
416              
417              Pman.Dialog.BAdminCoreEnum.show({ 
418                  id : sel.data.id
419              }, function(res) {
420                  _this.option_grid.store.load({});
421              });
422              
423          }
424        },
425        xns : Roo.bootstrap,
426        '|xns' : 'Roo.bootstrap',
427        store : {
428         xtype : 'Store',
429         remoteSort : true,
430         sortinfo : { field : 'display_name', direction: 'ASC' },
431         listeners : {
432          beforeload : function (_self, o)
433           {
434               o.params = o.params || {};
435               
436               var sel = _this.type_grid.getSelectionModel().getSelected();
437               
438               if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length){
439                   this.removeAll();
440                   return false;
441               }
442               
443               o.params.etype = sel.data.name;
444               
445           },
446          update : function (_self, record, operation)
447           {
448               if (operation != 'commit') {
449                   return;
450               }
451           
452               new Pman.Request({
453                   url : baseURL + '/Roo/Core_enum',
454                   method :'POST',
455                   params : {
456                       id : record.data.id,
457                       active: record.data.active
458                   },
459                   success : function() {
460           
461                   },
462                   failure : function() 
463                   {
464                       Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
465                           _this.grid.footer.onClick('first');
466                       });
467                   }
468               });
469           }
470         },
471         xns : Roo.data,
472         '|xns' : 'Roo.data',
473         proxy : {
474          xtype : 'HttpProxy',
475          method : 'GET',
476          url : baseURL + '/Roo/core_enum.php',
477          xns : Roo.data,
478          '|xns' : 'Roo.data'
479         },
480         reader : {
481          xtype : 'JsonReader',
482          fields : [
483              {
484                  'name': 'id',
485                  'type': 'int'
486              },
487              {
488                  'name': 'etype',
489                  'type': 'string'
490              },
491              {
492                  'name': 'name',
493                  'type': 'string'
494              },
495              {
496                  'name': 'display_name',
497                  'type': 'string'
498              },
499              {
500                  'name': 'active',
501                  'type': 'int'
502              },
503              {
504                  'name': 'seqid',
505                  'type': 'int'
506              }
507          ],
508          id : 'id',
509          root : 'data',
510          totalProperty : 'total',
511          xns : Roo.data,
512          '|xns' : 'Roo.data'
513         }
514        },
515        sm : {
516         xtype : 'RowSelectionModel',
517         singleSelect : true,
518         xns : Roo.bootstrap.Table,
519         '|xns' : 'Roo.bootstrap.Table'
520        },
521        cm : [
522         {
523          xtype : 'ColumnModel',
524          dataIndex : 'id',
525          header : _this._strings['01abfc750a0c942167651c40d088531d'] /* # */,
526          md : 2,
527          renderer : function(v,x,r) {
528              //console.log(r.data.seqid);
529              //return String.format('{0}', v ? v : '');
530              
531              return 
532                  String.format('{0}', r.data.seqid ? r.data.seqid : '')
533                  +" <span style='color:lightgrey'>"
534                  + String.format('{0}', r.data.id ? r.data.id : '')
535                  +"</span>";
536          },
537          sm : 2,
538          sortable : false,
539          xs : 2,
540          xns : Roo.grid,
541          '|xns' : 'Roo.grid'
542         },
543         {
544          xtype : 'ColumnModel',
545          dataIndex : 'name',
546          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
547          md : 4,
548          renderer : function(v,x,r) { 
549              return String.format('{0}', v ? v : '');
550          },
551          sm : 4,
552          sortable : false,
553          xs : 4,
554          xns : Roo.grid,
555          '|xns' : 'Roo.grid'
556         },
557         {
558          xtype : 'ColumnModel',
559          dataIndex : 'display_name',
560          header : _this._strings['b48968e1c912da07df5e8d6d246291ec'] /* Display Name */,
561          md : 4,
562          renderer : function(v,x,r) { 
563              return String.format('{0}', v ? v : '');
564          },
565          sm : 4,
566          sortable : false,
567          xs : 4,
568          xns : Roo.grid,
569          '|xns' : 'Roo.grid'
570         },
571         {
572          xtype : 'ColumnModel',
573          dataIndex : 'active',
574          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
575          md : 2,
576          renderer : function(v,x,r) { 
577              var state = v > 0 ?  '-checked' : '';
578          
579              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
580          },
581          sm : 2,
582          sortable : false,
583          xs : 2,
584          xns : Roo.grid,
585          '|xns' : 'Roo.grid'
586         }
587        ]
588       }
589      }
590     ]
591    }
592   };  }
593 });