Pman.Tab.BAdminStaff.bjs
[Pman.BAdmin] / Pman.Tab.BAdminStaff.bjs
1 {
2  "name" : "Pman.Tab.BAdminStaff",
3  "parent" : "Pman.Tab.BAdmin",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.BAdmin/Pman.Tab.BAdminStaff.bjs",
6  "permname" : "",
7  "modOrder" : "003",
8  "strings" : {
9   "b15aafc19dc2ba4b788adf77268d8ca4" : "Hide Inactive",
10   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
11   "f29c99f082755399839b64ebaf9f608a" : "List / View",
12   "4f3cdff2e6a5e08440be182ef40d93f7" : "Print / Export",
13   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
14   "a37ede293936e29279ed543129451ec3" : "Groups",
15   "7dce122004969d56ae2e0245cb754d35" : "Edit",
16   "05b763f7d24f32575493b3c23f299b0e" : "Add To Group",
17   "e0a7cc944485bdedafb92b0cf98632fa" : "Remove From Group",
18   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
19   "25f57527ae8a27c94fb5230b5486c743" : "Permission List",
20   "09f0c5159c5e34504e453eff3fc70324" : "Account Management",
21   "054176c3a541fb2d4b63e29360c749aa" : "Members List",
22   "8a25a3ae30ab6e8ceb5b8c4009a3336f" : "Role / Position",
23   "17050e1914aff1e423a84e76db8ab0d1" : "[All]",
24   "5bc3fd20294c17c9803942958fd7f26d" : "Show Inactive",
25   "4d1c8263ba1036754f8db14a98f9f006" : "Reload",
26   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
27   "ec3249f16ee5880d4c1acb752e5c925f" : "Switch to Selected User",
28   "4d3d769b812b6faa6b76e1a8abaece2d" : "Active",
29   "49ee3087348e8d44e1feda1917443987" : "Name",
30   "e55f75a29310d7b60f7ac1d390c8ae42" : "Module",
31   "ed5dea09095f671b801bee34ea28a319" : "Permission",
32   "aba9f7d7443652e858969bfc280690b1" : "Manage Groups"
33  },
34  "items" : [
35   {
36    "listeners" : {
37     "activate" : "function (_self)\n{\n    if ( _this.group_grid) {\n         _this.group_grid.store.load({});\n    }\n}"
38    },
39    "xtype" : "Nest",
40    "$ xns" : "Roo.bootstrap.panel",
41    "String title" : "Account Management",
42    "Boolean background" : true,
43    "items" : [
44     {
45      "xtype" : "Border",
46      "$ xns" : "Roo.bootstrap.layout",
47      "* prop" : "layout",
48      "items" : [
49       {
50        "String tabPosition" : "top",
51        "xtype" : "Region",
52        "$ xns" : "Roo.bootstrap.layout",
53        "* prop" : "center"
54       },
55       {
56        "String tabPosition" : "top",
57        "Number width" : 250,
58        "xtype" : "Region",
59        "$ xns" : "Roo.bootstrap.layout",
60        "* prop" : "west",
61        "Boolean split" : true
62       },
63       {
64        "listeners" : {
65         "activate" : "function (_self)\n{\n    _this.edit_btn.el.hide();\n    _this.delete_btn.el.hide();\n    _this.addToGroupBtn.el.hide();\n    _this.removeFromGroupBtn.el.hide();\n    _this.switch_btn.el.hide();\n\n    if(_this.member_grid) {\n        _this.member_grid.footer.onClick('first');\n    }\n}",
66         "render" : "function (_self)\n{\n    _this.member_panel = _self; \n}"
67        },
68        "Boolean fitContainer" : true,
69        "xtype" : "Grid",
70        "Boolean fitToFrame" : true,
71        "String region" : "center",
72        "$ xns" : "Roo.bootstrap.panel",
73        "String title" : "Members List",
74        "Boolean background" : false,
75        "Boolean closable" : false,
76        "items" : [
77         {
78          "xtype" : "NavSimplebar",
79          "$ xns" : "Roo.bootstrap",
80          "* prop" : "toolbar",
81          "items" : [
82           {
83            "xtype" : "NavGroup",
84            "$ xns" : "Roo.bootstrap",
85            "String style" : "width: 100%;",
86            "items" : [
87             {
88              "xtype" : "NavItem",
89              "$ xns" : "Roo.bootstrap",
90              "String style" : "width: 100%;",
91              "items" : [
92               {
93                "xtype" : "Element",
94                "$ xns" : "Roo.bootstrap",
95                "String style" : "width: 100%;",
96                "items" : [
97                 {
98                  "String cls" : "roo-toolbar",
99                  "xtype" : "Row",
100                  "$ xns" : "Roo.bootstrap",
101                  "items" : [
102                   {
103                    "Number md" : 9,
104                    "xtype" : "Column",
105                    "$ xns" : "Roo.bootstrap",
106                    "items" : [
107                     {
108                      "listeners" : {
109                       "click" : "function (_self, e)\n{\n    Pman.Dialog.BAdminStaff.show({ \n        id : 0,\n        company_id : Pman.Login.authUser.company_id\n    }, function(res) {\n    \n        if(res.length_oath_key * 1 < 1){\n            _this.member_grid.footer.onClick('first');\n            return;\n        }\n        \n        Pman.Dialog.BAdminStaffTwoFactorQRCode.show({\n            id : res.id\n        }, function(res){\n            _this.member_grid.footer.onClick('first');\n        });\n    }); \n\n}"
110                      },
111                      "String cls" : "roo-toolbar-button",
112                      "String weight" : "default",
113                      "xtype" : "Button",
114                      "$ xns" : "Roo.bootstrap",
115                      "String html" : "Add",
116                      "String glyphicon" : "plus"
117                     },
118                     {
119                      "listeners" : {
120                       "render" : "function (_self)\n{\n    _this.edit_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
121                       "click" : "function (_self, e)\n{\n    var sel = _this.member_grid.getSelectionModel().getSelections();\n    \n    if(!sel.length){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');\n        return;\n    }\n    \n    if(sel.length > 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a single person');\n        return;\n    }\n    \n    var s = _this.member_grid.getSelectionModel().getSelected();\n    \n    if(s.data.id * 1 < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'Invalid person');\n        return;\n    }\n    \n    Pman.Dialog.BAdminStaff.show( { id : s.data.id }, function() {\n        _this.member_grid.footer.onClick('first');\n    });\n    \n}"
122                      },
123                      "String cls" : "roo-toolbar-button",
124                      "String weight" : "default",
125                      "xtype" : "Button",
126                      "$ xns" : "Roo.bootstrap",
127                      "String html" : "Edit",
128                      "String glyphicon" : "edit"
129                     },
130                     {
131                      "listeners" : {
132                       "render" : "function (_self)\n{\n    _this.delete_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
133                       "click" : "function (_self, e)\n{\n    // from pman.js\n    Pman.genericDelete(_this.member_panel, 'core_person');\n    \n    \n}"
134                      },
135                      "String cls" : "roo-toolbar-button",
136                      "String weight" : "primary",
137                      "xtype" : "Button",
138                      "$ xns" : "Roo.bootstrap",
139                      "String html" : "Delete",
140                      "String glyphicon" : "trash"
141                     },
142                     {
143                      "listeners" : {
144                       "render" : "function (_self)\n{\n    _this.addToGroupBtn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
145                       "click" : "function (_self, e)\n{\n    var sel = _this.member_grid.getSelectionModel().getSelections();\n    \n    if(!sel.length){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');\n        return;\n    }\n    \n    var ids = [];\n    \n    Roo.each(sel, function(r){\n        if(r.data.id * 1 < 1){\n            return;\n        }\n        \n        ids.push(r.data.id);\n    });\n    \n    if(!ids.length){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');\n        return;\n    }\n    \n    Pman.Dialog.BAdminAddToGroup.show({\n        user_ids : ids.join(',')\n        \n    }, function(res){\n        _this.member_grid.footer.onClick('first');\n    });\n    \n}"
146                      },
147                      "String cls" : "roo-toolbar-button",
148                      "String weight" : "default",
149                      "xtype" : "Button",
150                      "$ xns" : "Roo.bootstrap",
151                      "String html" : "Add To Group",
152                      "String glyphicon" : "plus"
153                     },
154                     {
155                      "listeners" : {
156                       "render" : "function (_self)\n{\n    _this.removeFromGroupBtn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
157                       "click" : "function (_self, e)\n{\n    var sel = _this.member_grid.getSelectionModel().getSelections();\n    \n    if(!sel.length){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');\n        return;\n    }\n    \n    var ids = [];\n    \n    Roo.each(sel, function(r){\n        if(r.data.id * 1 < 1){\n            return;\n        }\n        \n        ids.push(r.data.id);\n    });\n    \n    if(!ids.length){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a person');\n        return;\n    }\n    \n    var group = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!group || group.data.id < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');\n        return;\n    }\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/Core_group',\n        method: 'POST',\n        params: {\n            group_id : group.data.id,\n            _action : 'sub',\n            user_ids : ids.join(',')\n        },\n        success: function(res){\n            _this.member_grid.footer.onClick('first');\n            return;\n        }\n    });\n    \n    \n}"
158                      },
159                      "String cls" : "roo-toolbar-button",
160                      "String weight" : "default",
161                      "xtype" : "Button",
162                      "$ xns" : "Roo.bootstrap",
163                      "String html" : "Remove From Group",
164                      "String glyphicon" : "trash"
165                     },
166                     {
167                      "listeners" : {
168                       "render" : "function (_self)\n{\n    _this.switch_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
169                       "click" : "function (_self, e)\n{\n    var s = _this.member_grid.getSelectionModel().getSelections();\n    \n    if (s.length != 1)  {\n        Roo.MessageBox.alert(\"Error\",  \"Select a Person\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL+ '/Login.php',\n        params  :{\n            'switch' : s[0].data.id\n        },\n        method : 'GET',\n        success : function() {\n            document.location = baseURL + '?ts=' + Math.random();\n            \n        }, \n        failure : function(d) {\n            Roo.log(d);\n            Roo.MessageBox.alert(\"Error\",  d);\n        }\n    });\n}"
170                      },
171                      "String cls" : "roo-toolbar-button",
172                      "String weight" : "default",
173                      "xtype" : "Button",
174                      "$ xns" : "Roo.bootstrap",
175                      "String html" : "Switch to Selected User",
176                      "String glyphicon" : "user"
177                     }
178                    ]
179                   },
180                   {
181                    "Number md" : 3,
182                    "String cls" : "text-right",
183                    "xtype" : "Column",
184                    "$ xns" : "Roo.bootstrap",
185                    "items" : [
186                     {
187                      "listeners" : {
188                       "toggle" : "function (_self, e, pressed)\n{\n    this.setText(this.pressed ? this._ontext : this._offtext);\n\n    _this.member_grid.footer.onClick('first');\n    \n    return;\n    \n}",
189                       "render" : "function (_self)\n{\n    _this.footerActiveBtn = this;\n}"
190                      },
191                      "String cls" : "roo-toolbar-button",
192                      "String _offtext" : "Show Inactive",
193                      "String weight" : "default",
194                      "bool pressed" : false,
195                      "xtype" : "Button",
196                      "String _ontext" : "Hide Inactive",
197                      "$ xns" : "Roo.bootstrap",
198                      "String html" : "Show Inactive",
199                      "string name" : "activeButton"
200                     }
201                    ]
202                   }
203                  ]
204                 }
205                ]
206               }
207              ]
208             }
209            ]
210           }
211          ]
212         },
213         {
214          "listeners" : {
215           "rowdblclick" : "function (_self, el, rowIndex, e)\n{\n    var s = _this.member_grid.store.getAt(rowIndex);\n    \n    if(s.data.id * 1 < 1){\n        return;\n    }\n    \n    Pman.Dialog.BAdminStaff.show( { id : s.data.id }, function() {\n        _this.member_grid.footer.onClick('first');\n    });\n}",
216           "cellclick" : "function (_self, el, rowIndex, columnIndex, e)\n{\n    var di = _this.member_grid.colModel.getDataIndex(columnIndex);\n    \n    if (di != 'active') {\n        return;\n    }\n     \n    var rec = _this.member_grid.store.getAt(rowIndex);\n    \n    rec.set('active', rec.data.active ? 0 : 1);\n    rec.commit();\n\n    \n    // get the row number to make class x-row-0, x-row-1\n    \n    if(rec.data.active * 1 != 1){\n        var el = _this.member_grid.getRowDom(rowIndex);\n        \n        el.addClass('x-grid-row-fadeout');\n        \n        el.on('transitionend',function(){\n            _this.member_grid.ds.remove(rec);\n            el.remove();\n        },this,{single:true});\n    }\n}",
217           "render" : "function (_self)\n{\n    _this.member_grid = _self;\n   \n}"
218          },
219          "String cls" : "table-fixed",
220          "Boolean cellSelection" : true,
221          "boolean hover" : true,
222          "boolean striped" : false,
223          "xtype" : "Table",
224          "boolean responsive" : true,
225          "Boolean rowSelection" : true,
226          "$ xns" : "Roo.bootstrap",
227          "bool autoHideFooter" : true,
228          "Boolean loadMask" : true,
229          "* prop" : "grid",
230          "items" : [
231           {
232            "listeners" : {
233             "selectionchange" : "function (_self)\n{\n    _this.edit_btn.el.hide();\n    _this.delete_btn.el.hide();\n    _this.addToGroupBtn.el.hide();\n    _this.removeFromGroupBtn.el.hide();\n    _this.switch_btn.el.hide();\n    \n    if(!_this.member_grid.getSelectionModel().getSelections().length){\n        return;\n    }\n    \n    _this.edit_btn.el.show();\n    _this.delete_btn.el.show();\n    _this.switch_btn.el.show();\n    \n    var group = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!group || group.data.id < 1){\n        _this.addToGroupBtn.el.show();\n        return;\n    }\n    \n    _this.removeFromGroupBtn.el.show();\n    \n}"
234            },
235            "xtype" : "RowSelectionModel",
236            "$ xns" : "Roo.bootstrap.Table",
237            "* prop" : "sm"
238           },
239           {
240            "listeners" : {
241             "update" : "function (_self, record, operation)\n{\n    if (operation != 'commit') {\n        return;\n    }\n    // only used to change active status.\n     \n    new Pman.Request({\n        url : baseURL + '/Roo/core_person',\n        method :'POST',\n        params : {\n            id : record.data.id,\n            active: record.data.active\n            \n        },\n        success : function() {\n            // do nothing\n            \n        },\n        failure : function() \n        {\n            /*Roo.bootstrap.MessageBox.alert(\"Error\", \"saving failed\", function() {\n                _this.grid.footer.onClick('first');\n            });*/\n        }\n    });\n}",
242             "beforeload" : "function (_self, options)\n{\n    if (!Pman.buildCompleted) {\n        return false;\n    }\n    options.params = options.params || {};\n    \n    //options.params['query[type]'] = 0;\n    //options.params.active = 1;\n    \n    if(!_this.group_grid){\n        this.removeAll();\n        return false;\n    }\n    \n    var group = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!group){\n        this.removeAll();\n        return false;\n    }\n    \n    if(_this.footerActiveBtn && !_this.footerActiveBtn.pressed){\n        options.params.active = 1;\n    }\n    \n    options.params['query[in_group]'] = group.data.id;\n  \n}",
243             "load" : "function (_self, records, options)\n{\n    _this.edit_btn.el.hide();\n    _this.delete_btn.el.hide();\n    _this.addToGroupBtn.el.hide();\n    _this.removeFromGroupBtn.el.hide();\n    _this.switch_btn.el.hide();\n    \n    options.params.active = 1;\n    \n\n    \n}"
244            },
245            "xtype" : "Store",
246            "boolean remoteSort" : true,
247            "$ xns" : "Roo.data",
248            "$ sortInfo" : "{ field: 'name', direction: 'ASC' }",
249            "* prop" : "store",
250            "items" : [
251             {
252              "xtype" : "JsonReader",
253              "String root" : "data",
254              "$ xns" : "Roo.data",
255              "String id" : "id",
256              "* prop" : "reader",
257              "String totalProperty" : "total"
258             },
259             {
260              "$ url" : "baseURL + '/Roo/core_person'",
261              "xtype" : "HttpProxy",
262              "$ xns" : "Roo.data",
263              "String method" : "GET",
264              "* prop" : "proxy"
265             }
266            ]
267           },
268           {
269            "String cursor" : "pointer",
270            "String header" : "Active",
271            "Number md" : 1,
272            "String dataIndex" : "active",
273            "xtype" : "ColumnModel",
274            "Number xs" : 1,
275            "String align" : "center",
276            "$ xns" : "Roo.grid",
277            "$ renderer" : "function(v) {  \n\n    var state = v > 0 ?  'check-' : '';\n    var cls = v > 0 ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n         \n }",
278            "Boolean sortable" : true,
279            "* prop" : "cm[]",
280            "Number sm" : 1
281           },
282           {
283            "String header" : "Name",
284            "String cursor" : "pointer",
285            "Number md" : 3,
286            "String dataIndex" : "name",
287            "xtype" : "ColumnModel",
288            "Number xs" : 3,
289            "$ xns" : "Roo.grid",
290            "$ renderer" : "function(v,x,r) {\n    if(r.data.active * 1 != 1){\n        return \"<span class='cell-strikethrough'>\"+String.format('{0}', v)+\"</span>\"; \n    }\n    return String.format('{0}', v);\n}",
291            "Boolean sortable" : true,
292            "* prop" : "cm[]",
293            "Number sm" : 3
294           },
295           {
296            "String header" : "Role / Position",
297            "String cursor" : "pointer",
298            "Number md" : 2,
299            "String dataIndex" : "role",
300            "xtype" : "ColumnModel",
301            "Number xs" : 2,
302            "$ xns" : "Roo.grid",
303            "$ renderer" : "function(v) { return String.format('{0}', v); }",
304            "Boolean sortable" : true,
305            "* prop" : "cm[]",
306            "Number sm" : 2
307           },
308           {
309            "String header" : "Phone",
310            "String cursor" : "pointer",
311            "Number md" : 2,
312            "String dataIndex" : "phone",
313            "xtype" : "ColumnModel",
314            "Number xs" : 2,
315            "$ xns" : "Roo.grid",
316            "$ renderer" : "function(v) { return String.format('{0}', v); }",
317            "* prop" : "cm[]",
318            "Number sm" : 2
319           },
320           {
321            "String header" : "Email",
322            "String cursor" : "pointer",
323            "Number md" : 4,
324            "String dataIndex" : "email",
325            "xtype" : "ColumnModel",
326            "Number xs" : 4,
327            "$ xns" : "Roo.grid",
328            "$ renderer" : "function (v,x,r) {\n    if(r.data.active * 1 != 1){\n        return (v.length && v.indexOf('@') > 0 ) ? \n            String.format('<a href=\"mailto:{0}\" class=\"cell-strikethrough\">{0}</a>',v) : v;\n    }\n    return (v.length && v.indexOf('@') > 0 ) ? \n            String.format('<a href=\"mailto:{0}\">{0}</a>',v) : v;\n            \n}",
329            "Boolean sortable" : true,
330            "* prop" : "cm[]",
331            "Number sm" : 2
332           },
333           {
334            "Number pageSize" : 25,
335            "Boolean displayInfo" : false,
336            "xtype" : "PagingToolbar",
337            "$ xns" : "Roo.bootstrap",
338            "* prop" : "footer",
339            "string name" : "footer"
340           }
341          ]
342         }
343        ]
344       },
345       {
346        "listeners" : {
347         "activate" : "function (_self)\n{\n    if(_this.permission_grid) {\n        _this.permission_grid.store.load({});\n    }\n}",
348         "render" : "function (_self)\n{\n    _this.permission_panel = this;\n}"
349        },
350        "Boolean fitContainer" : true,
351        "xtype" : "Grid",
352        "Boolean fitToFrame" : true,
353        "String region" : "center",
354        "$ xns" : "Roo.bootstrap.panel",
355        "String title" : "Permission List",
356        "Boolean background" : true,
357        "Boolean closable" : false,
358        "items" : [
359         {
360          "listeners" : {
361           "cellclick" : "function (_self, el, rowIndex, columnIndex, e)\n{\n    var di = _this.permission_grid.colModel.getDataIndex(columnIndex);\n    \n    var r = _this.permission_grid.store.getAt(rowIndex);\n    \n    if(di == 'rightname' || di == 'descript' || r.data.id * 1 < 1) {\n        return;\n    }\n    \n    if(di == 'id'){\n        \n        var accessmask = r.data.accessmask.split('').sort().join('');\n        var fullmask = r.data.FullMask.split('').sort().join('');\n        \n        r.set('accessmask', (accessmask == fullmask) ? '' : r.data.FullMask);\n        \n        r.commit();\n        \n        return;\n    }\n    \n    var mapping = {\n        'add' : 'A',\n        'edit' : 'E',\n        'delete' : 'D',\n        'view' : 'S',\n        'print' : 'P'\n    };\n    \n    var target = mapping[di];\n    \n    if(r.data.FullMask.indexOf(target) === -1){\n        return;\n    }\n    \n    var accessmask = r.data.accessmask.split('');\n    \n    if(accessmask.indexOf(target) !== -1){\n        accessmask.splice(accessmask.indexOf(target), 1);\n    } else {\n        accessmask.push(target);\n    }\n    \n    r.set('accessmask', accessmask.sort().join(''));\n    \n    r.commit();\n    \n}",
362           "render" : "function (_self)\n{\n    _this.permission_grid = this;\n    \n    if(_this.permission_panel.active) {\n        (function(){\n            _this.permission_grid.store.load({});\n        }).defer(50);\n    }\n}"
363          },
364          "Boolean footerShow" : false,
365          "Boolean cellSelection" : true,
366          "String cls" : "table-fixed",
367          "boolean striped" : true,
368          "boolean hover" : true,
369          "xtype" : "Table",
370          "boolean responsive" : true,
371          "Boolean rowSelection" : true,
372          "$ xns" : "Roo.bootstrap",
373          "Boolean loadMask" : true,
374          "* prop" : "grid",
375          "items" : [
376           {
377            "Boolean singleSelect" : true,
378            "xtype" : "RowSelectionModel",
379            "$ xns" : "Roo.bootstrap.Table",
380            "* prop" : "sm"
381           },
382           {
383            "listeners" : {
384             "update" : "function (_self, record, operation)\n{\n    if (operation != 'commit') {\n        return;\n    }\n\n    var group = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!group || group.data.id * 1 < 1){\n        return;\n    }\n    \n    var params = {};\n    \n    params.group_id = group.data.id;\n    \n    params['dataUpdate[' + record.data.id + ']'] = record.data.accessmask;\n    \n    new Pman.Request({\n        url : baseURL + '/Admin/GroupRights',\n        method :'POST',\n        params : params,\n        success : function() {\n            // do nothing\n        },\n        failure : function() \n        {\n            Roo.bootstrap.MessageBox.alert(\"Error\", \"saving failed\", function() {\n                _this.permission_grid.store.load({});\n            });\n        }\n    });\n    \n}",
385             "beforeload" : "function (_self, o)\n{\n    if (!Pman.buildCompleted) {\n        return false;\n    }\n    var group = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!group){\n        _this.permission_panel.el.mask('Please select a group');\n        this.removeAll();\n        return false;\n    }\n    \n    if(group.data.id * 1 < 1){\n        _this.permission_panel.el.mask('You can not set permissions for this group');\n        this.removeAll();\n        return false;\n    }\n    \n    _this.permission_panel.el.unmask();\n    \n    o.params = o.params || {};\n     \n    o.params._sort = 1;    \n    o.params.group_id = group.data.id;\n\n}"
386            },
387            "xtype" : "Store",
388            "boolean remoteSort" : true,
389            "$ xns" : "Roo.data",
390            "$ sortInfo" : "{ field: 'rightname', direction: 'ASC' }",
391            "* prop" : "store",
392            "items" : [
393             {
394              "$ Array fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'rightname',\n        'type': 'string'\n    },\n    {\n        'name': 'descript',\n        'type': 'string'\n    },\n    {\n        'name': 'accessmask',\n        'type': 'string'\n    },\n    {\n        'name': 'FullMask',\n        'type': 'string'\n    },\n    {\n        'name': 'group_id',\n        'type': 'int'\n    }\n]",
395              "xtype" : "JsonReader",
396              "String root" : "data",
397              "$ xns" : "Roo.data",
398              "String id" : "id",
399              "* prop" : "reader",
400              "String totalProperty" : "total"
401             },
402             {
403              "xtype" : "HttpProxy",
404              "$ xns" : "Roo.data",
405              "String method" : "GET",
406              "* prop" : "proxy",
407              "$ String url" : "baseURL + '/BAdmin/GroupRights.php'"
408             }
409            ]
410           },
411           {
412            "String header" : "[All]",
413            "String dataIndex" : "id",
414            "$ Function renderer" : "function (v,x,r) {\n    \n    if (!r.data.FullMask.length) {\n        return '';\n    }\n    \n    var accessmask = r.data.accessmask.split('').sort().join('');\n    var fullmask = r.data.FullMask.split('').sort().join('');\n    \n    var state = (accessmask == fullmask) ? 'check-' : '';\n    \n    var cls = (accessmask == fullmask) ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n    \n}\n",
415            "xtype" : "ColumnModel",
416            "Number xs" : 1,
417            "String align" : "center",
418            "$ xns" : "Roo.grid",
419            "Boolean sortable" : false,
420            "* prop" : "cm[]"
421           },
422           {
423            "String header" : "Module",
424            "String dataIndex" : "rightname",
425            "$ Function renderer" : "function (v) {\n    return String.format('<span tooltip=\"{1}\">{0}</span>', v.split('.').shift(), v);\n}",
426            "xtype" : "ColumnModel",
427            "Number xs" : 2,
428            "$ xns" : "Roo.grid",
429            "* prop" : "cm[]"
430           },
431           {
432            "String header" : "Permission",
433            "String dataIndex" : "descript",
434            "$ Function renderer" : "function (v) {\n    return String.format('{0}', v ? v : '');\n}",
435            "xtype" : "ColumnModel",
436            "Number xs" : 4,
437            "$ xns" : "Roo.grid",
438            "* prop" : "cm[]"
439           },
440           {
441            "String header" : "Add",
442            "String dataIndex" : "add",
443            "$ Function renderer" : "function (v,x,r) {\n    \n    if (r.data.FullMask.indexOf('A') === -1) {\n        return '';\n    }\n    \n    var state = (r.data.accessmask.indexOf('A') !== -1) ? 'check-' : '';\n    var cls = (r.data.accessmask.indexOf('A') !== -1) ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n}",
444            "xtype" : "ColumnModel",
445            "Number xs" : 1,
446            "String align" : "center",
447            "$ xns" : "Roo.grid",
448            "Boolean sortable" : false,
449            "* prop" : "cm[]"
450           },
451           {
452            "String header" : "Edit",
453            "String dataIndex" : "edit",
454            "$ Function renderer" : "function (v,x,r) {\n    \n    if (r.data.FullMask.indexOf('E') === -1) {\n        return '';\n    }\n    \n    var state = (r.data.accessmask.indexOf('E') !== -1) ? 'check-' : '';\n    var cls = (r.data.accessmask.indexOf('E') !== -1) ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n}",
455            "xtype" : "ColumnModel",
456            "Number xs" : 1,
457            "String align" : "center",
458            "$ xns" : "Roo.grid",
459            "Boolean sortable" : false,
460            "* prop" : "cm[]"
461           },
462           {
463            "String header" : "Delete",
464            "String dataIndex" : "delete",
465            "$ Function renderer" : "function (v,x,r) {\n    \n    if (r.data.FullMask.indexOf('D') === -1) {\n        return '';\n    }\n    \n    var state = (r.data.accessmask.indexOf('D') !== -1) ? 'check-' : '';\n    var cls = (r.data.accessmask.indexOf('D') !== -1) ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n    \n}",
466            "xtype" : "ColumnModel",
467            "Number xs" : 1,
468            "String align" : "center",
469            "$ xns" : "Roo.grid",
470            "Boolean sortable" : false,
471            "* prop" : "cm[]"
472           },
473           {
474            "String header" : "List / View",
475            "String dataIndex" : "view",
476            "$ Function renderer" : "function (v,x,r) {\n    \n    if (r.data.FullMask.indexOf('S') === -1) {\n        return '';\n    }\n    \n    var state = (r.data.accessmask.indexOf('S') !== -1) ? 'check-' : '';\n    var cls = (r.data.accessmask.indexOf('S') !== -1) ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n    \n}",
477            "xtype" : "ColumnModel",
478            "Number xs" : 1,
479            "String align" : "center",
480            "$ xns" : "Roo.grid",
481            "Boolean sortable" : false,
482            "* prop" : "cm[]"
483           },
484           {
485            "String header" : "Print / Export",
486            "String dataIndex" : "print",
487            "$ Function renderer" : "function (v,x,r) {\n    \n    if (r.data.FullMask.indexOf('P') === -1) {\n        return '';\n    }\n    \n    var state = (r.data.accessmask.indexOf('P') !== -1) ? 'check-' : '';\n    var cls = (r.data.accessmask.indexOf('P') !== -1) ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n    \n}",
488            "xtype" : "ColumnModel",
489            "Number xs" : 1,
490            "String align" : "center",
491            "$ xns" : "Roo.grid",
492            "Boolean sortable" : false,
493            "* prop" : "cm[]"
494           }
495          ]
496         }
497        ]
498       },
499       {
500        "listeners" : {
501         "activate" : "function (_self)\n{\n    if (_this.group_grid) {\n        _this.group_grid.store.load({});\n    }\n}",
502         "render" : "function (_self)\n{\n    _this.group_panel = _self;\n}"
503        },
504        "Boolean fitContainer" : true,
505        "xtype" : "Grid",
506        "Boolean fitToFrame" : true,
507        "String region" : "west",
508        "$ xns" : "Roo.bootstrap.panel",
509        "String title" : "Groups",
510        "Boolean background" : false,
511        "items" : [
512         {
513          "xtype" : "NavSimplebar",
514          "$ xns" : "Roo.bootstrap",
515          "* prop" : "toolbar",
516          "items" : [
517           {
518            "xtype" : "NavGroup",
519            "$ xns" : "Roo.bootstrap",
520            "items" : [
521             {
522              "xtype" : "NavItem",
523              "$ xns" : "Roo.bootstrap",
524              "items" : [
525               {
526                "xtype" : "Button",
527                "$ xns" : "Roo.bootstrap",
528                "String html" : "Manage Groups",
529                "items" : [
530                 {
531                  "xtype" : "Menu",
532                  "$ xns" : "Roo.bootstrap",
533                  "* prop" : "menu",
534                  "items" : [
535                   {
536                    "listeners" : {
537                     "click" : "function (_self, e)\n{\n    Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){\n        _this.group_grid.store.load({});\n    });\n}"
538                    },
539                    "Boolean preventDefault" : true,
540                    "xtype" : "MenuItem",
541                    "String fa" : "fa fa-plus",
542                    "$ xns" : "Roo.bootstrap",
543                    "Boolean isContainer" : false,
544                    "String html" : "Add"
545                   },
546                   {
547                    "listeners" : {
548                     "click" : "function (_self, e)\n{\n    var sel = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!sel){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');\n        return;\n    }\n    \n    if(sel.data.id * 1 < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');\n        return;\n    }\n    \n    Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){\n        _this.group_grid.store.load({});\n    });\n}"
549                    },
550                    "Boolean preventDefault" : true,
551                    "xtype" : "MenuItem",
552                    "String fa" : "fa fa-pencil",
553                    "$ xns" : "Roo.bootstrap",
554                    "Boolean isContainer" : false,
555                    "String html" : "Edit"
556                   },
557                   {
558                    "listeners" : {
559                     "click" : "function (_self, e)\n{\n    var sel = _this.group_grid.getSelectionModel().getSelected();\n    \n    if(!sel){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');\n        return;\n    }\n    \n    if(sel.data.id * 1 < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');\n        return;\n    }\n    \n    var deleteIt = function()\n    {\n        new Pman.Request({\n            url: baseURL + '/Roo/Core_group',\n            method: 'POST',\n            params: {\n                _delete : sel.data.id\n            },\n            success: function(res){\n                _this.group_grid.store.load({});\n                return;\n            }\n        });\n    }\n    \n    Roo.bootstrap.MessageBox.confirm('Confirm', 'Are you sure to delete the group?',function(ret) {\n        \n        if(ret == 'no'){\n            return;\n        }\n        \n        deleteIt();\n        \n     }, this);\n    \n    \n}"
560                    },
561                    "Boolean preventDefault" : true,
562                    "xtype" : "MenuItem",
563                    "String fa" : "fa fa-trash",
564                    "$ xns" : "Roo.bootstrap",
565                    "Boolean isContainer" : false,
566                    "String html" : "Delete"
567                   },
568                   {
569                    "listeners" : {
570                     "click" : "function (_self, e)\n{\n    _this.group_grid.store.load({});\n}"
571                    },
572                    "Boolean preventDefault" : true,
573                    "xtype" : "MenuItem",
574                    "String fa" : "fa fa-refresh",
575                    "$ xns" : "Roo.bootstrap",
576                    "Boolean isContainer" : false,
577                    "String html" : "Reload"
578                   }
579                  ]
580                 }
581                ]
582               }
583              ]
584             }
585            ]
586           }
587          ]
588         },
589         {
590          "listeners" : {
591           "rowdblclick" : "function (_self, el, rowIndex, e)\n{\n    var sel = _this.group_grid.store.getAt(rowIndex);\n    \n    if(!sel || sel.data.id * 1 < 1){\n        return;\n    }\n    \n    Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){\n        _this.group_grid.store.load({});\n    });\n}",
592           "rowsrendered" : "function (_self)\n{\n    if(this.ds.getCount() * 1 < 1){\n        return;\n    }\n    \n    var sm = _this.group_grid.getSelectionModel();\n    \n    sm.selectFirstRow();\n    sm.fireEvent('afterselectionchange', sm);\n    \n}",
593           "render" : "function (_self)\n{\n    _this.group_grid = _self; \n\n    if (_this.group_panel.active) {\n        _this.group_grid.store.load({});\n    }\n}"
594          },
595          "String cls" : "table-fixed",
596          "Boolean footerShow" : false,
597          "boolean hover" : true,
598          "boolean striped" : true,
599          "xtype" : "Table",
600          "boolean responsive" : true,
601          "Boolean rowSelection" : true,
602          "$ xns" : "Roo.bootstrap",
603          "Boolean loadMask" : true,
604          "* prop" : "grid",
605          "items" : [
606           {
607            "listeners" : {
608             "afterselectionchange" : "function (_self)\n{\n    if(_this.footerActiveBtn){\n        _this.footerActiveBtn.setActive(false);\n        _this.footerActiveBtn.fireEvent('toggle', _this.footerActiveBtn);\n    }\n    \n    if(_this.permission_grid){\n        _this.permission_grid.store.load({});\n    }\n    \n}"
609            },
610            "Boolean singleSelect" : true,
611            "xtype" : "RowSelectionModel",
612            "$ xns" : "Roo.bootstrap.Table",
613            "* prop" : "sm"
614           },
615           {
616            "listeners" : {
617             "beforeload" : "function (_self, options)\n{\n    if (!Pman.buildCompleted) {\n        return false;\n    }\n    options.params = options.params || {};\n    \n    options.params.type = 0;\n    \n    options.params._add_everyone = 1;\n\n}"
618            },
619            "xtype" : "Store",
620            "boolean remoteSort" : true,
621            "$ xns" : "Roo.data",
622            "$ sortInfo" : "{ field: 'name', direction: 'ASC'}",
623            "* prop" : "store",
624            "items" : [
625             {
626              "$ Array fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'leader',\n        'type': 'string'\n    },\n    {\n        'name': 'group_member_count',\n        'type': 'int'\n    },\n    {\n        'name': 'display_name',\n        'type': 'string'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    }\n]",
627              "xtype" : "JsonReader",
628              "String root" : "data",
629              "$ xns" : "Roo.data",
630              "String id" : "id",
631              "* prop" : "reader",
632              "String totalProperty" : "total"
633             },
634             {
635              "$ url" : "baseURL + '/Roo/core_group'",
636              "xtype" : "HttpProxy",
637              "$ xns" : "Roo.data",
638              "String method" : "GET",
639              "* prop" : "proxy"
640             }
641            ]
642           },
643           {
644            "String header" : "Name",
645            "String cursor" : "pointer",
646            "Number md" : 12,
647            "String dataIndex" : "name",
648            "xtype" : "ColumnModel",
649            "Number xs" : 12,
650            "$ xns" : "Roo.grid",
651            "$ renderer" : "function(v,x,r) { \n\n    if (r.data.id == 0) {\n        return '<b>' + \"All Staff\" + '</b>';\n    }\n    \n    if (r.data.id == -1) {\n        return '<b>' + \"Not in a Group\" + '</b>';\n    }\n\n    var vv = (r.json.display_name.length) ? r.json.display_name : v;\n    \n    if (v == 'Administrators') {\n        return '<b>' + vv + '</b>';\n    }\n    \n    if (r.data.leader) {\n        return vv + ' (' + r.json.leader_name + ')';\n    }\n    \n    return String.format('{0} ({1})',vv, r.json.group_member_count);\n}",
652            "Boolean sortable" : false,
653            "* prop" : "cm[]",
654            "Number sm" : 12
655           }
656          ]
657         }
658        ]
659       }
660      ]
661     }
662    ]
663   }
664  ]
665 }