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