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