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              xtype : 'Button',
119              glyphicon : 'edit',
120              html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
121              style : 'margin: 10px;',
122              weight : 'default',
123              listeners : {
124               click : function (_self, e)
125                {
126                    var sel = _this.option_grid.getSelectionModel().getSelected();
127                    
128                    if(!sel || sel.data.id * 1 < 1){
129                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
130                        return;
131                    }
132                
133                    Pman.Dialog.BAdminCoreEnum.show({ 
134                        id : sel.data.id
135                    }, function(res) {
136                        _this.option_grid.store.load({});
137                    });
138                
139                },
140               render : function (_self)
141                {
142                    _this.type_edit_btn = this;
143                    
144                    this.hide();
145                }
146              },
147              xns : Roo.bootstrap,
148              '|xns' : 'Roo.bootstrap'
149             }
150            ]
151           }
152          ]
153         }
154        ]
155       },
156       grid : {
157        xtype : 'Table',
158        cellSelection : true,
159        cls : 'table-fixed',
160        hover : true,
161        loadMask : true,
162        responsive : true,
163        rowSelection : true,
164        striped : false,
165        listeners : {
166         render : function (_self)
167          {
168              _this.type_grid = _self; 
169             
170          },
171         rowdblclick : function (_self, el, rowIndex, e)
172          {
173              var r = _this.type_grid.store.getAt(rowIndex);
174              
175              if(!r || r.data.id * 1 < 1){
176                  return;
177              }
178              
179              Pman.Dialog.BAdminCoreEnum.show({ 
180                  id : r.data.id
181              }, function(res) {
182                  _this.type_grid.footer.onClick('first');
183              });
184          }
185        },
186        xns : Roo.bootstrap,
187        '|xns' : 'Roo.bootstrap',
188        footer : {
189         xtype : 'PagingToolbar',
190         displayInfo : false,
191         name : 'footer',
192         pageSize : 100,
193         xns : Roo.bootstrap,
194         '|xns' : 'Roo.bootstrap'
195        },
196        store : {
197         xtype : 'Store',
198         remoteSort : true,
199         sortInfo : { field : 'display_name', direction: 'ASC' },
200         listeners : {
201          beforeload : function (_self, o)
202           {
203               o.params = o.params || {};
204               
205               o.params['query[empty_etype]'] = 1;
206               
207           },
208          load : function (_self, records, options)
209           {
210               _this.type_edit_btn.hide();
211           }
212         },
213         xns : Roo.data,
214         '|xns' : 'Roo.data',
215         proxy : {
216          xtype : 'HttpProxy',
217          method : 'GET',
218          url : baseURL + '/Roo/core_enum.php',
219          xns : Roo.data,
220          '|xns' : 'Roo.data'
221         },
222         reader : {
223          xtype : 'JsonReader',
224          fields : [
225              {
226                  'name': 'id',
227                  'type': 'int'
228              },
229              {
230                  'name': 'etype',
231                  'type': 'string'
232              },
233              {
234                  'name': 'name',
235                  'type': 'string'
236              },
237              {
238                  'name': 'display_name',
239                  'type': 'string'
240              },
241              {
242                  'name': 'active',
243                  'type': 'int'
244              },
245              {
246                  'name': 'seqid',
247                  'type': 'int'
248              }
249          ],
250          id : 'id',
251          root : 'data',
252          totalProperty : 'total',
253          xns : Roo.data,
254          '|xns' : 'Roo.data'
255         }
256        },
257        sm : {
258         xtype : 'RowSelectionModel',
259         singleSelect : true,
260         listeners : {
261          selectionchange : function (_self)
262           {
263               _this.option_grid.store.load({});
264           }
265         },
266         xns : Roo.bootstrap.Table,
267         '|xns' : 'Roo.bootstrap.Table'
268        },
269        cm : [
270         {
271          xtype : 'ColumnModel',
272          cursor : 'pointer',
273          dataIndex : 'display_name',
274          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
275          renderer : function(v,x,r) {
276              if (v.match(/Coba/g) || v.match(/Risk Question/g)) {
277                  return String.format('<span tooltip="{1}">Coba: {0}</span>', v, r.data.name);
278              }
279              
280              return String.format('<span tooltip="{1}">{0}</span>', v, r.data.name); 
281          },
282          sortable : true,
283          xs : 12,
284          xns : Roo.grid,
285          '|xns' : 'Roo.grid'
286         }
287        ]
288       }
289      },
290      {
291       xtype : 'Grid',
292       background : false,
293       fitContainer : true,
294       fitToFrame : true,
295       region : 'center',
296       title : _this._strings['dae8ace18bdcbcc6ae5aece263e14fe8'] /* Options */,
297       listeners : {
298        activate : function (_self)
299         {
300             _this.edit_btn.hide();
301             _this.delete_btn.hide();
302             
303             if (_this.option_grid) {
304                 _this.option_grid.store.load({});
305             }
306         },
307        render : function (_self)
308         {
309             _this.option_panel = _self;
310         }
311       },
312       xns : Roo.bootstrap.panel,
313       '|xns' : 'Roo.bootstrap.panel',
314       toolbar : {
315        xtype : 'NavSimplebar',
316        xns : Roo.bootstrap,
317        '|xns' : 'Roo.bootstrap',
318        items  : [
319         {
320          xtype : 'NavGroup',
321          xns : Roo.bootstrap,
322          '|xns' : 'Roo.bootstrap',
323          items  : [
324           {
325            xtype : 'NavItem',
326            xns : Roo.bootstrap,
327            '|xns' : 'Roo.bootstrap',
328            items  : [
329             {
330              xtype : 'Button',
331              glyphicon : 'plus',
332              html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
333              style : 'margin: 10px;',
334              weight : 'default',
335              listeners : {
336               click : function (_self, e)
337                {
338                    var sel = _this.type_grid.getSelectionModel().getSelected();
339                    
340                    if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length ){
341                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a type');
342                        return;
343                    }
344                
345                    Pman.Dialog.BAdminCoreEnum.show({ 
346                        id : 0,
347                        etype : sel.data.name
348                    }, function(res) {
349                        _this.option_grid.store.load({});
350                    });
351                
352                }
353              },
354              xns : Roo.bootstrap,
355              '|xns' : 'Roo.bootstrap'
356             },
357             {
358              xtype : 'Button',
359              glyphicon : 'edit',
360              html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
361              style : 'margin: 10px;',
362              weight : 'default',
363              listeners : {
364               click : function (_self, e)
365                {
366                    var sel = _this.option_grid.getSelectionModel().getSelected();
367                    
368                    if(!sel || sel.data.id * 1 < 1){
369                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
370                        return;
371                    }
372                
373                    Pman.Dialog.BAdminCoreEnum.show({ 
374                        id : sel.data.id
375                    }, function(res) {
376                        _this.option_grid.store.load({});
377                    });
378                
379                },
380               render : function (_self)
381                {
382                    _this.edit_btn = this;
383                    
384                    this.hide();
385                }
386              },
387              xns : Roo.bootstrap,
388              '|xns' : 'Roo.bootstrap'
389             },
390             {
391              xtype : 'Button',
392              glyphicon : 'trash',
393              html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
394              style : 'margin: 10px;',
395              weight : 'primary',
396              listeners : {
397               click : function (_self, e)
398                {
399                    var sel = _this.option_grid.getSelectionModel().getSelected();
400                    
401                    if(!sel || sel.data.id * 1 < 1){
402                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
403                        return;
404                    }
405                
406                    new Pman.Request({
407                        url: baseURL + '/Roo/Core_enum.php',
408                        method : 'POST',
409                        params : {
410                            _delete : sel.data.id
411                        }, 
412                        success : function(res) {
413                            _this.option_grid.store.load({});
414                        }
415                    });
416                
417                },
418               render : function (_self)
419                {
420                    _this.delete_btn = this;
421                    
422                    this.hide();
423                }
424              },
425              xns : Roo.bootstrap,
426              '|xns' : 'Roo.bootstrap'
427             }
428            ]
429           }
430          ]
431         }
432        ]
433       },
434       grid : {
435        xtype : 'Table',
436        cellSelection : true,
437        cls : 'table-fixed',
438        footerShow : false,
439        hover : true,
440        loadMask : true,
441        responsive : true,
442        rowSelection : true,
443        striped : true,
444        listeners : {
445         cellclick : function (_self, el, rowIndex, columnIndex, e)
446          {
447              var di = _this.option_grid.colModel.getDataIndex(columnIndex);
448              
449              if (di != 'active') {
450                  return;
451              }
452               
453              var rec = _this.option_grid.store.getAt(rowIndex);
454              
455              rec.set('active', rec.data.active ? 0 : 1);
456              
457              rec.commit();
458          },
459         render : function (_self)
460          {
461              _this.option_grid = _self; 
462          
463          },
464         rowdblclick : function (_self, el, rowIndex, e)
465          {
466              var sel = _this.option_grid.store.getAt(rowIndex);
467              
468              if(!sel || sel.data.id * 1 < 1){
469                  return;
470              }
471              
472              Pman.Dialog.BAdminCoreEnum.show({ 
473                  id : sel.data.id
474              }, function(res) {
475                  _this.option_grid.store.load({});
476              });
477              
478          }
479        },
480        xns : Roo.bootstrap,
481        '|xns' : 'Roo.bootstrap',
482        store : {
483         xtype : 'Store',
484         remoteSort : true,
485         sortinfo : { field : 'display_name', direction: 'ASC' },
486         listeners : {
487          beforeload : function (_self, o)
488           {
489               o.params = o.params || {};
490               
491               var sel = _this.type_grid.getSelectionModel().getSelected();
492               
493               if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length){
494                   this.removeAll();
495                   return false;
496               }
497               
498               o.params.etype = sel.data.name;
499               
500           },
501          load : function (_self, records, options)
502           {
503               _this.edit_btn.hide();
504               _this.delete_btn.hide();
505           },
506          update : function (_self, record, operation)
507           {
508               if (operation != 'commit') {
509                   return;
510               }
511           
512               new Pman.Request({
513                   url : baseURL + '/Roo/Core_enum',
514                   method :'POST',
515                   params : {
516                       id : record.data.id,
517                       active: record.data.active
518                   },
519                   success : function() {
520           
521                   },
522                   failure : function() 
523                   {
524                       Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
525                           _this.grid.footer.onClick('first');
526                       });
527                   }
528               });
529           }
530         },
531         xns : Roo.data,
532         '|xns' : 'Roo.data',
533         proxy : {
534          xtype : 'HttpProxy',
535          method : 'GET',
536          url : baseURL + '/Roo/core_enum.php',
537          xns : Roo.data,
538          '|xns' : 'Roo.data'
539         },
540         reader : {
541          xtype : 'JsonReader',
542          fields : [
543              {
544                  'name': 'id',
545                  'type': 'int'
546              },
547              {
548                  'name': 'etype',
549                  'type': 'string'
550              },
551              {
552                  'name': 'name',
553                  'type': 'string'
554              },
555              {
556                  'name': 'display_name',
557                  'type': 'string'
558              },
559              {
560                  'name': 'active',
561                  'type': 'int'
562              },
563              {
564                  'name': 'seqid',
565                  'type': 'int'
566              }
567          ],
568          id : 'id',
569          root : 'data',
570          totalProperty : 'total',
571          xns : Roo.data,
572          '|xns' : 'Roo.data'
573         }
574        },
575        sm : {
576         xtype : 'RowSelectionModel',
577         singleSelect : true,
578         listeners : {
579          selectionchange : function (_self)
580           {
581               _this.edit_btn.hide();
582               _this.delete_btn.hide();
583               
584               if (!this.getSelected()) {
585                   return;
586               }
587               
588               _this.edit_btn.show();
589               _this.delete_btn.show();
590               
591           }
592         },
593         xns : Roo.bootstrap.Table,
594         '|xns' : 'Roo.bootstrap.Table'
595        },
596        cm : [
597         {
598          xtype : 'ColumnModel',
599          cursor : 'pointer',
600          dataIndex : 'id',
601          header : _this._strings['01abfc750a0c942167651c40d088531d'] /* # */,
602          md : 2,
603          renderer : function(v,x,r) {
604              //console.log(r.data.seqid);
605              //return String.format('{0}', v ? v : '');
606              
607              return 
608                  String.format('{0}', r.data.seqid ? r.data.seqid : '')
609                  +" <span style='color:lightgrey'>"
610                  + String.format('{0}', r.data.id ? r.data.id : '')
611                  +"</span>";
612          },
613          sm : 2,
614          sortable : false,
615          xs : 2,
616          xns : Roo.grid,
617          '|xns' : 'Roo.grid'
618         },
619         {
620          xtype : 'ColumnModel',
621          cursor : 'pointer',
622          dataIndex : 'name',
623          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
624          md : 4,
625          renderer : function(v,x,r) { 
626              return String.format('{0}', v ? v : '');
627          },
628          sm : 4,
629          sortable : false,
630          xs : 4,
631          xns : Roo.grid,
632          '|xns' : 'Roo.grid'
633         },
634         {
635          xtype : 'ColumnModel',
636          cursor : 'pointer',
637          dataIndex : 'display_name',
638          header : _this._strings['b48968e1c912da07df5e8d6d246291ec'] /* Display Name */,
639          md : 4,
640          renderer : function(v,x,r) { 
641              return String.format('{0}', v ? v : '');
642          },
643          sm : 4,
644          sortable : false,
645          xs : 4,
646          xns : Roo.grid,
647          '|xns' : 'Roo.grid'
648         },
649         {
650          xtype : 'ColumnModel',
651          cursor : 'pointer',
652          dataIndex : 'active',
653          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
654          md : 2,
655          renderer : function(v,x,r) { 
656              var state = v > 0 ?  '-checked' : '';
657          
658              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
659          },
660          sm : 2,
661          sortable : false,
662          xs : 2,
663          xns : Roo.grid,
664          '|xns' : 'Roo.grid'
665         }
666        ]
667       }
668      }
669     ]
670    }
671   };  }
672 });