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.store.load({});
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.store.load({});
256         //        _this.option_grid.footer.onClick('first');
257             }
258         },
259        render : function (_self)
260         {
261             _this.option_panel = _self;
262         }
263       },
264       xns : Roo.bootstrap.panel,
265       '|xns' : 'Roo.bootstrap.panel',
266       toolbar : {
267        xtype : 'NavSimplebar',
268        xns : Roo.bootstrap,
269        '|xns' : 'Roo.bootstrap',
270        items  : [
271         {
272          xtype : 'NavGroup',
273          xns : Roo.bootstrap,
274          '|xns' : 'Roo.bootstrap',
275          items  : [
276           {
277            xtype : 'NavSidebarItem',
278            glyphicon : 'menu-hamburger',
279            html : _this._strings['aba9f7d7443652e858969bfc280690b1'] /* Manage Groups  */,
280            preventDefault : true,
281            xns : Roo.bootstrap,
282            '|xns' : 'Roo.bootstrap',
283            menu : {
284             xtype : 'Menu',
285             xns : Roo.bootstrap,
286             '|xns' : 'Roo.bootstrap',
287             items  : [
288              {
289               xtype : 'MenuItem',
290               fa : 'fa fa-plus',
291               html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
292               isContainer : false,
293               preventDefault : true,
294               listeners : {
295                click : function (_self, e)
296                 {
297                     Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){
298                         _this.group_grid.store.load({});
299                     });
300                 }
301               },
302               xns : Roo.bootstrap,
303               '|xns' : 'Roo.bootstrap'
304              },
305              {
306               xtype : 'MenuItem',
307               fa : 'fa fa-pencil',
308               html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
309               isContainer : false,
310               preventDefault : true,
311               listeners : {
312                click : function (_self, e)
313                 {
314                     var sel = _this.group_grid.getSelectionModel().getSelected();
315                     
316                     if(!sel){
317                         Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
318                         return;
319                     }
320                     
321                     if(sel.data.id * 1 < 1){
322                         Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
323                         return;
324                     }
325                     
326                     Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){
327                         _this.group_grid.store.load({});
328                     });
329                 }
330               },
331               xns : Roo.bootstrap,
332               '|xns' : 'Roo.bootstrap'
333              },
334              {
335               xtype : 'MenuItem',
336               fa : 'fa fa-trash',
337               html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
338               isContainer : false,
339               preventDefault : true,
340               listeners : {
341                click : function (_self, e)
342                 {
343                     var sel = _this.group_grid.getSelectionModel().getSelected();
344                     
345                     if(!sel){
346                         Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
347                         return;
348                     }
349                     
350                     if(sel.data.id * 1 < 1){
351                         Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
352                         return;
353                     }
354                     
355                     var deleteIt = function()
356                     {
357                         new Pman.Request({
358                             url: baseURL + '/Roo/Core_group',
359                             method: 'POST',
360                             params: {
361                                 _delete : sel.data.id
362                             },
363                             success: function(res){
364                                 _this.group_grid.store.load({});
365                                 return;
366                             }
367                         });
368                     }
369                     
370                     Roo.bootstrap.MessageBox.confirm('Confirm', 'Are you sure to delete the group?',function(ret) {
371                         
372                         if(ret == 'no'){
373                             return;
374                         }
375                         
376                         deleteIt();
377                         
378                      }, this);
379                     
380                     
381                 }
382               },
383               xns : Roo.bootstrap,
384               '|xns' : 'Roo.bootstrap'
385              },
386              {
387               xtype : 'MenuItem',
388               fa : 'fa fa-refresh',
389               html : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
390               isContainer : false,
391               preventDefault : true,
392               listeners : {
393                click : function (_self, e)
394                 {
395                     _this.group_grid.store.load({});
396                 }
397               },
398               xns : Roo.bootstrap,
399               '|xns' : 'Roo.bootstrap'
400              }
401             ]
402            }
403           }
404          ]
405         }
406        ]
407       },
408       grid : {
409        xtype : 'Table',
410        cls : 'table-fixed',
411        footerShow : false,
412        hover : true,
413        loadMask : true,
414        responsive : true,
415        rowSelection : true,
416        striped : true,
417        listeners : {
418         render : function (_self)
419          {
420              _this.option_grid = _self; 
421          
422          }
423        },
424        xns : Roo.bootstrap,
425        '|xns' : 'Roo.bootstrap',
426        store : {
427         xtype : 'Store',
428         remoteSort : true,
429         sortinfo : { field : 'display_name', direction: 'ASC' },
430         listeners : {
431          beforeload : function (_self, o)
432           {
433               o.params = o.params || {};
434               
435               var sel = _this.type_grid.getSelectionModel().getSelected();
436               
437               if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length){
438                   this.removeAll();
439                   return false;
440               }
441               
442               o.params.etype = sel.data.name;
443               
444           }
445         },
446         xns : Roo.data,
447         '|xns' : 'Roo.data',
448         proxy : {
449          xtype : 'HttpProxy',
450          method : 'GET',
451          url : baseURL + '/Roo/core_enum.php',
452          xns : Roo.data,
453          '|xns' : 'Roo.data'
454         },
455         reader : {
456          xtype : 'JsonReader',
457          fields : [
458              {
459                  'name': 'id',
460                  'type': 'int'
461              },
462              {
463                  'name': 'etype',
464                  'type': 'string'
465              },
466              {
467                  'name': 'name',
468                  'type': 'string'
469              },
470              {
471                  'name': 'display_name',
472                  'type': 'string'
473              },
474              {
475                  'name': 'active',
476                  'type': 'int'
477              },
478              {
479                  'name': 'seqid',
480                  'type': 'int'
481              }
482          ],
483          id : 'id',
484          root : 'data',
485          totalProperty : 'total',
486          xns : Roo.data,
487          '|xns' : 'Roo.data'
488         }
489        },
490        sm : {
491         xtype : 'RowSelectionModel',
492         singleSelect : true,
493         xns : Roo.bootstrap.Table,
494         '|xns' : 'Roo.bootstrap.Table'
495        },
496        cm : [
497         {
498          xtype : 'ColumnModel',
499          dataIndex : 'name',
500          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
501          md : 12,
502          renderer : function(v,x,r) { 
503              
504              if (r.data.id == 0) {
505                  return '<b>' + "All Staff" + '</b>';
506              }
507              
508              if (r.data.id == -1) {
509                  return '<b>' + "Not in a Group" + '</b>';
510              }
511              
512              if (v == 'Administrators') {
513                  return '<b>' + "Adminstrators" + '</b>';
514              }
515              
516              if (r.data.leader) {
517                  return v + ' (' + r.data.leader_name + ')';
518              }
519              
520              return v;
521          },
522          sm : 12,
523          sortable : false,
524          xs : 12,
525          xns : Roo.grid,
526          '|xns' : 'Roo.grid'
527         }
528        ]
529       }
530      }
531     ]
532    }
533   };  }
534 });