Pman.Tab.BAdminIPAccess.bjs
[Pman.BAdmin] / Pman.Tab.BAdminIPAccess.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.BAdminIPAccess = new Roo.XComponent({
8
9  _strings : {
10   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
11   '7dce122004969d56ae2e0245cb754d35' :"Edit",
12   '01abfc750a0c942167651c40d088531d' :"#",
13   'dae8ace18bdcbcc6ae5aece263e14fe8' :"Options",
14   'b48968e1c912da07df5e8d6d246291ec' :"Display Name",
15   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
16   '49ee3087348e8d44e1feda1917443987' :"Name",
17   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
18   'e3030abfa75de4573fb37032affa11e7' :"IP Access"
19  },
20
21   part     :  ["BAdmin", "IPAccess" ],
22   order    : '006-Pman.Tab.BAdminIPAccess',
23   region   : 'center',
24   parent   : false,
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['e3030abfa75de4573fb37032affa11e7'] /* IP Access */,
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     items  : [
50      {
51       xtype : 'Grid',
52       background : false,
53       fitContainer : true,
54       fitToFrame : true,
55       region : 'center',
56       title : _this._strings['dae8ace18bdcbcc6ae5aece263e14fe8'] /* Options */,
57       listeners : {
58        activate : function (_self)
59         {
60             _this.edit_btn.hide();
61             _this.delete_btn.hide();
62             
63             if (_this.option_grid) {
64                 _this.option_grid.store.load({});
65             }
66         },
67        render : function (_self)
68         {
69             _this.option_panel = _self;
70         }
71       },
72       xns : Roo.bootstrap.panel,
73       '|xns' : 'Roo.bootstrap.panel',
74       toolbar : {
75        xtype : 'NavSimplebar',
76        xns : Roo.bootstrap,
77        '|xns' : 'Roo.bootstrap',
78        items  : [
79         {
80          xtype : 'NavGroup',
81          xns : Roo.bootstrap,
82          '|xns' : 'Roo.bootstrap',
83          items  : [
84           {
85            xtype : 'NavItem',
86            xns : Roo.bootstrap,
87            '|xns' : 'Roo.bootstrap',
88            items  : [
89             {
90              xtype : 'Element',
91              xns : Roo.bootstrap,
92              '|xns' : 'Roo.bootstrap',
93              items  : [
94               {
95                xtype : 'Row',
96                cls : 'roo-toolbar',
97                xns : Roo.bootstrap,
98                '|xns' : 'Roo.bootstrap',
99                items  : [
100                 {
101                  xtype : 'Column',
102                  md : 12,
103                  xns : Roo.bootstrap,
104                  '|xns' : 'Roo.bootstrap',
105                  items  : [
106                   {
107                    xtype : 'Button',
108                    cls : 'roo-toolbar-button',
109                    glyphicon : 'plus',
110                    html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
111                    weight : 'default',
112                    listeners : {
113                     click : function (_self, e)
114                      {
115                          var sel = _this.type_grid.getSelectionModel().getSelected();
116                          
117                          if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length ){
118                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a type');
119                              return;
120                          }
121                      
122                          Pman.Dialog.BAdminCoreEnum.show({ 
123                              id : 0,
124                              etype : sel.data.name
125                          }, function(res) {
126                              _this.option_grid.store.load({});
127                          });
128                      
129                      }
130                    },
131                    xns : Roo.bootstrap,
132                    '|xns' : 'Roo.bootstrap'
133                   },
134                   {
135                    xtype : 'Button',
136                    cls : 'roo-toolbar-button',
137                    glyphicon : 'edit',
138                    html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
139                    weight : 'default',
140                    listeners : {
141                     click : function (_self, e)
142                      {
143                          var sel = _this.option_grid.getSelectionModel().getSelected();
144                          
145                          if(!sel || sel.data.id * 1 < 1){
146                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
147                              return;
148                          }
149                      
150                          Pman.Dialog.BAdminCoreEnum.show({ 
151                              id : sel.data.id
152                          }, function(res) {
153                              _this.option_grid.store.load({});
154                          });
155                      
156                      },
157                     render : function (_self)
158                      {
159                          _this.edit_btn = this;
160                          
161                          this.hide();
162                      }
163                    },
164                    xns : Roo.bootstrap,
165                    '|xns' : 'Roo.bootstrap'
166                   },
167                   {
168                    xtype : 'Button',
169                    cls : 'roo-toolbar-button',
170                    glyphicon : 'trash',
171                    html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
172                    weight : 'primary',
173                    listeners : {
174                     click : function (_self, e)
175                      {
176                          var sel = _this.option_grid.getSelectionModel().getSelected();
177                          
178                          if(!sel || sel.data.id * 1 < 1){
179                              Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
180                              return;
181                          }
182                      
183                          new Pman.Request({
184                              url: baseURL + '/Roo/Core_enum.php',
185                              method : 'POST',
186                              params : {
187                                  _delete : sel.data.id
188                              }, 
189                              success : function(res) {
190                                  _this.option_grid.store.load({});
191                              }
192                          });
193                      
194                      },
195                     render : function (_self)
196                      {
197                          _this.delete_btn = this;
198                          
199                          this.hide();
200                      }
201                    },
202                    xns : Roo.bootstrap,
203                    '|xns' : 'Roo.bootstrap'
204                   }
205                  ]
206                 }
207                ]
208               }
209              ]
210             }
211            ]
212           }
213          ]
214         }
215        ]
216       },
217       grid : {
218        xtype : 'Table',
219        cellSelection : true,
220        cls : 'table-fixed',
221        footerShow : false,
222        hover : true,
223        loadMask : true,
224        responsive : true,
225        rowSelection : true,
226        striped : true,
227        listeners : {
228         cellclick : function (_self, el, rowIndex, columnIndex, e)
229          {
230              var di = _this.option_grid.colModel.getDataIndex(columnIndex);
231              
232              if (di != 'active') {
233                  return;
234              }
235               
236              var rec = _this.option_grid.store.getAt(rowIndex);
237              
238              rec.set('active', rec.data.active ? 0 : 1);
239              
240              rec.commit();
241          },
242         render : function (_self)
243          {
244              _this.option_grid = _self; 
245          
246          },
247         rowdblclick : function (_self, el, rowIndex, e)
248          {
249              var sel = _this.option_grid.store.getAt(rowIndex);
250              
251              if(!sel || sel.data.id * 1 < 1){
252                  return;
253              }
254              
255              Pman.Dialog.BAdminCoreEnum.show({ 
256                  id : sel.data.id
257              }, function(res) {
258                  _this.option_grid.store.load({});
259              });
260              
261          }
262        },
263        xns : Roo.bootstrap,
264        '|xns' : 'Roo.bootstrap',
265        store : {
266         xtype : 'Store',
267         remoteSort : true,
268         sortinfo : { field : 'display_name', direction: 'ASC' },
269         listeners : {
270          beforeload : function (_self, o)
271           {
272               o.params = o.params || {};
273               
274               var sel = _this.type_grid.getSelectionModel().getSelected();
275               
276               if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length){
277                   this.removeAll();
278                   return false;
279               }
280               
281           },
282          load : function (_self, records, options)
283           {
284               _this.edit_btn.hide();
285               _this.delete_btn.hide();
286           },
287          update : function (_self, record, operation)
288           {
289               if (operation != 'commit') {
290                   return;
291               }
292           
293               new Pman.Request({
294                   url : baseURL + '/Roo/Core_enum',
295                   method :'POST',
296                   params : {
297                       id : record.data.id,
298                       active: record.data.active
299                   },
300                   success : function() {
301           
302                   },
303                   failure : function() 
304                   {
305                       Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
306                           _this.grid.footer.onClick('first');
307                       });
308                   }
309               });
310           }
311         },
312         xns : Roo.data,
313         '|xns' : 'Roo.data',
314         proxy : {
315          xtype : 'HttpProxy',
316          method : 'GET',
317          url : baseURL + '/Roo/core_enum.php',
318          xns : Roo.data,
319          '|xns' : 'Roo.data'
320         },
321         reader : {
322          xtype : 'JsonReader',
323          fields : [
324              {
325                  'name': 'id',
326                  'type': 'int'
327              },
328              {
329                  'name': 'etype',
330                  'type': 'string'
331              },
332              {
333                  'name': 'name',
334                  'type': 'string'
335              },
336              {
337                  'name': 'display_name',
338                  'type': 'string'
339              },
340              {
341                  'name': 'active',
342                  'type': 'int'
343              },
344              {
345                  'name': 'seqid',
346                  'type': 'int'
347              }
348          ],
349          id : 'id',
350          root : 'data',
351          totalProperty : 'total',
352          xns : Roo.data,
353          '|xns' : 'Roo.data'
354         }
355        },
356        sm : {
357         xtype : 'RowSelectionModel',
358         singleSelect : true,
359         listeners : {
360          selectionchange : function (_self)
361           {
362               _this.edit_btn.hide();
363               _this.delete_btn.hide();
364               
365               if (!this.getSelected()) {
366                   return;
367               }
368               
369               _this.edit_btn.show();
370               _this.delete_btn.show();
371               
372           }
373         },
374         xns : Roo.bootstrap.Table,
375         '|xns' : 'Roo.bootstrap.Table'
376        },
377        cm : [
378         {
379          xtype : 'ColumnModel',
380          cursor : 'pointer',
381          dataIndex : 'id',
382          header : _this._strings['01abfc750a0c942167651c40d088531d'] /* # */,
383          md : 2,
384          renderer : function(v,x,r) {
385              //console.log(r.data.seqid);
386              //return String.format('{0}', v ? v : '');
387              
388              return 
389                  String.format('{0}', r.data.seqid ? r.data.seqid : '')
390                  +" <span style='color:lightgrey'>"
391                  + String.format('{0}', r.data.id ? r.data.id : '')
392                  +"</span>";
393          },
394          sm : 2,
395          sortable : false,
396          xs : 2,
397          xns : Roo.grid,
398          '|xns' : 'Roo.grid'
399         },
400         {
401          xtype : 'ColumnModel',
402          cursor : 'pointer',
403          dataIndex : 'name',
404          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
405          md : 4,
406          renderer : function(v,x,r) { 
407              return String.format('{0}', v ? v : '');
408          },
409          sm : 4,
410          sortable : false,
411          xs : 4,
412          xns : Roo.grid,
413          '|xns' : 'Roo.grid'
414         },
415         {
416          xtype : 'ColumnModel',
417          cursor : 'pointer',
418          dataIndex : 'display_name',
419          header : _this._strings['b48968e1c912da07df5e8d6d246291ec'] /* Display Name */,
420          md : 4,
421          renderer : function(v,x,r) { 
422              return String.format('{0}', v ? v : '');
423          },
424          sm : 4,
425          sortable : false,
426          xs : 4,
427          xns : Roo.grid,
428          '|xns' : 'Roo.grid'
429         },
430         {
431          xtype : 'ColumnModel',
432          cursor : 'pointer',
433          dataIndex : 'active',
434          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
435          md : 2,
436          renderer : function(v,x,r) { 
437              var state = v > 0 ?  '-checked' : '';
438          
439              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
440          },
441          sm : 2,
442          sortable : false,
443          xs : 2,
444          xns : Roo.grid,
445          '|xns' : 'Roo.grid'
446         }
447        ]
448       }
449      }
450     ]
451    }
452   };  }
453 });