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