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   "aba9f7d7443652e858969bfc280690b1" : "Manage Groups ",
18   "e0a7cc944485bdedafb92b0cf98632fa" : "Remove From Group",
19   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
20   "25f57527ae8a27c94fb5230b5486c743" : "Permission List",
21   "09f0c5159c5e34504e453eff3fc70324" : "Account Management",
22   "054176c3a541fb2d4b63e29360c749aa" : "Members List",
23   "8a25a3ae30ab6e8ceb5b8c4009a3336f" : "Role / Position",
24   "17050e1914aff1e423a84e76db8ab0d1" : "[All]",
25   "5bc3fd20294c17c9803942958fd7f26d" : "Show Inactive",
26   "4d1c8263ba1036754f8db14a98f9f006" : "Reload",
27   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
28   "ec3249f16ee5880d4c1acb752e5c925f" : "Switch to Selected User",
29   "4d3d769b812b6faa6b76e1a8abaece2d" : "Active",
30   "49ee3087348e8d44e1feda1917443987" : "Name",
31   "e55f75a29310d7b60f7ac1d390c8ae42" : "Module",
32   "ed5dea09095f671b801bee34ea28a319" : "Permission"
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            "items" : [
86             {
87              "xtype" : "NavItem",
88              "$ xns" : "Roo.bootstrap",
89              "items" : [
90               {
91                "xtype" : "Element",
92                "$ xns" : "Roo.bootstrap",
93                "items" : [
94                 {
95                  "String cls" : "roo-toolbar",
96                  "xtype" : "Row",
97                  "$ xns" : "Roo.bootstrap",
98                  "items" : [
99                   {
100                    "Number md" : 9,
101                    "xtype" : "Column",
102                    "$ xns" : "Roo.bootstrap",
103                    "items" : [
104                     {
105                      "listeners" : {
106                       "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}"
107                      },
108                      "String cls" : "roo-toolbar-button",
109                      "String weight" : "default",
110                      "xtype" : "Button",
111                      "$ xns" : "Roo.bootstrap",
112                      "String html" : "Add",
113                      "String glyphicon" : "plus"
114                     },
115                     {
116                      "listeners" : {
117                       "render" : "function (_self)\n{\n    _this.edit_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
118                       "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}"
119                      },
120                      "String cls" : "roo-toolbar-button",
121                      "String weight" : "default",
122                      "xtype" : "Button",
123                      "$ xns" : "Roo.bootstrap",
124                      "String html" : "Edit",
125                      "String glyphicon" : "edit"
126                     },
127                     {
128                      "listeners" : {
129                       "render" : "function (_self)\n{\n    _this.delete_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
130                       "click" : "function (_self, e)\n{\n    // from pman.js\n    Pman.genericDelete(_this.member_panel, 'core_person');\n    \n    \n}"
131                      },
132                      "String cls" : "roo-toolbar-button",
133                      "String weight" : "primary",
134                      "xtype" : "Button",
135                      "$ xns" : "Roo.bootstrap",
136                      "String html" : "Delete",
137                      "String glyphicon" : "trash"
138                     },
139                     {
140                      "listeners" : {
141                       "render" : "function (_self)\n{\n    _this.addToGroupBtn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
142                       "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}"
143                      },
144                      "String cls" : "roo-toolbar-button",
145                      "String weight" : "default",
146                      "xtype" : "Button",
147                      "$ xns" : "Roo.bootstrap",
148                      "String html" : "Add To Group",
149                      "String glyphicon" : "plus"
150                     },
151                     {
152                      "listeners" : {
153                       "render" : "function (_self)\n{\n    _this.removeFromGroupBtn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
154                       "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}"
155                      },
156                      "String cls" : "roo-toolbar-button",
157                      "String weight" : "default",
158                      "xtype" : "Button",
159                      "$ xns" : "Roo.bootstrap",
160                      "String html" : "Remove From Group",
161                      "String glyphicon" : "trash"
162                     },
163                     {
164                      "listeners" : {
165                       "render" : "function (_self)\n{\n    _this.switch_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
166                       "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}"
167                      },
168                      "String cls" : "roo-toolbar-button",
169                      "String weight" : "default",
170                      "xtype" : "Button",
171                      "$ xns" : "Roo.bootstrap",
172                      "String html" : "Switch to Selected User",
173                      "String glyphicon" : "user"
174                     }
175                    ]
176                   },
177                   {
178                    "Number md" : 3,
179                    "String cls" : "text-right",
180                    "xtype" : "Column",
181                    "$ xns" : "Roo.bootstrap",
182                    "items" : [
183                     {
184                      "listeners" : {
185                       "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}",
186                       "render" : "function (_self)\n{\n    _this.footerActiveBtn = this;\n}"
187                      },
188                      "String cls" : "roo-toolbar-button",
189                      "String _offtext" : "Show Inactive",
190                      "String weight" : "default",
191                      "bool pressed" : false,
192                      "xtype" : "Button",
193                      "String _ontext" : "Hide Inactive",
194                      "$ xns" : "Roo.bootstrap",
195                      "String html" : "Show Inactive",
196                      "string name" : "activeButton"
197                     }
198                    ]
199                   }
200                  ]
201                 }
202                ]
203               }
204              ]
205             }
206            ]
207           }
208          ]
209         },
210         {
211          "listeners" : {
212           "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}",
213           "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}",
214           "render" : "function (_self)\n{\n    _this.member_grid = _self;\n   \n}"
215          },
216          "String cls" : "table-fixed",
217          "Boolean cellSelection" : true,
218          "boolean hover" : true,
219          "boolean striped" : false,
220          "xtype" : "Table",
221          "boolean responsive" : true,
222          "Boolean rowSelection" : true,
223          "$ xns" : "Roo.bootstrap",
224          "Boolean loadMask" : true,
225          "* prop" : "grid",
226          "items" : [
227           {
228            "listeners" : {
229             "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}"
230            },
231            "xtype" : "RowSelectionModel",
232            "$ xns" : "Roo.bootstrap.Table",
233            "* prop" : "sm"
234           },
235           {
236            "listeners" : {
237             "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}",
238             "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}",
239             "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}"
240            },
241            "xtype" : "Store",
242            "boolean remoteSort" : true,
243            "$ xns" : "Roo.data",
244            "$ sortInfo" : "{ field: 'name', direction: 'ASC' }",
245            "* prop" : "store",
246            "items" : [
247             {
248              "xtype" : "JsonReader",
249              "String root" : "data",
250              "$ xns" : "Roo.data",
251              "String id" : "id",
252              "* prop" : "reader",
253              "String totalProperty" : "total"
254             },
255             {
256              "$ url" : "baseURL + '/Roo/core_person'",
257              "xtype" : "HttpProxy",
258              "$ xns" : "Roo.data",
259              "String method" : "GET",
260              "* prop" : "proxy"
261             }
262            ]
263           },
264           {
265            "String cursor" : "pointer",
266            "String header" : "Active",
267            "Number md" : 1,
268            "String dataIndex" : "active",
269            "xtype" : "ColumnModel",
270            "Number xs" : 1,
271            "String align" : "center",
272            "$ xns" : "Roo.grid",
273            "$ 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 }",
274            "Boolean sortable" : true,
275            "* prop" : "cm[]",
276            "Number sm" : 1
277           },
278           {
279            "String header" : "Name",
280            "String cursor" : "pointer",
281            "Number md" : 3,
282            "String dataIndex" : "name",
283            "xtype" : "ColumnModel",
284            "Number xs" : 3,
285            "$ xns" : "Roo.grid",
286            "$ 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}",
287            "Boolean sortable" : true,
288            "* prop" : "cm[]",
289            "Number sm" : 3
290           },
291           {
292            "String header" : "Role / Position",
293            "String cursor" : "pointer",
294            "Number md" : 2,
295            "String dataIndex" : "role",
296            "xtype" : "ColumnModel",
297            "Number xs" : 2,
298            "$ xns" : "Roo.grid",
299            "$ renderer" : "function(v) { return String.format('{0}', v); }",
300            "Boolean sortable" : true,
301            "* prop" : "cm[]",
302            "Number sm" : 2
303           },
304           {
305            "String header" : "Phone",
306            "String cursor" : "pointer",
307            "Number md" : 2,
308            "String dataIndex" : "phone",
309            "xtype" : "ColumnModel",
310            "Number xs" : 2,
311            "$ xns" : "Roo.grid",
312            "$ renderer" : "function(v) { return String.format('{0}', v); }",
313            "* prop" : "cm[]",
314            "Number sm" : 2
315           },
316           {
317            "String header" : "Email",
318            "String cursor" : "pointer",
319            "Number md" : 4,
320            "String dataIndex" : "email",
321            "xtype" : "ColumnModel",
322            "Number xs" : 4,
323            "$ xns" : "Roo.grid",
324            "$ 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}",
325            "Boolean sortable" : true,
326            "* prop" : "cm[]",
327            "Number sm" : 2
328           },
329           {
330            "Number pageSize" : 25,
331            "Boolean displayInfo" : false,
332            "xtype" : "PagingToolbar",
333            "$ xns" : "Roo.bootstrap",
334            "* prop" : "footer",
335            "string name" : "footer"
336           }
337          ]
338         }
339        ]
340       },
341       {
342        "listeners" : {
343         "activate" : "function (_self)\n{\n    if(_this.permission_grid) {\n        _this.permission_grid.store.load({});\n    }\n}",
344         "render" : "function (_self)\n{\n    _this.permission_panel = this;\n}"
345        },
346        "Boolean fitContainer" : true,
347        "xtype" : "Grid",
348        "Boolean fitToFrame" : true,
349        "String region" : "center",
350        "$ xns" : "Roo.bootstrap.panel",
351        "String title" : "Permission List",
352        "Boolean background" : true,
353        "Boolean closable" : false,
354        "items" : [
355         {
356          "listeners" : {
357           "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}",
358           "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}"
359          },
360          "String cls" : "table-fixed",
361          "Boolean footerShow" : false,
362          "Boolean cellSelection" : true,
363          "boolean striped" : true,
364          "boolean hover" : true,
365          "xtype" : "Table",
366          "boolean responsive" : true,
367          "Boolean rowSelection" : true,
368          "$ xns" : "Roo.bootstrap",
369          "Boolean loadMask" : true,
370          "* prop" : "grid",
371          "items" : [
372           {
373            "Boolean singleSelect" : true,
374            "xtype" : "RowSelectionModel",
375            "$ xns" : "Roo.bootstrap.Table",
376            "* prop" : "sm"
377           },
378           {
379            "listeners" : {
380             "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}",
381             "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}"
382            },
383            "xtype" : "Store",
384            "boolean remoteSort" : true,
385            "$ xns" : "Roo.data",
386            "$ sortInfo" : "{ field: 'rightname', direction: 'ASC' }",
387            "* prop" : "store",
388            "items" : [
389             {
390              "$ 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]",
391              "xtype" : "JsonReader",
392              "String root" : "data",
393              "$ xns" : "Roo.data",
394              "String id" : "id",
395              "* prop" : "reader",
396              "String totalProperty" : "total"
397             },
398             {
399              "xtype" : "HttpProxy",
400              "$ xns" : "Roo.data",
401              "String method" : "GET",
402              "* prop" : "proxy",
403              "$ String url" : "baseURL + '/BAdmin/GroupRights.php'"
404             }
405            ]
406           },
407           {
408            "String header" : "[All]",
409            "String dataIndex" : "id",
410            "$ 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",
411            "xtype" : "ColumnModel",
412            "Number xs" : 1,
413            "String align" : "center",
414            "$ xns" : "Roo.grid",
415            "Boolean sortable" : false,
416            "* prop" : "cm[]"
417           },
418           {
419            "String header" : "Module",
420            "String dataIndex" : "rightname",
421            "$ Function renderer" : "function (v) {\n    return String.format('<span tooltip=\"{1}\">{0}</span>', v.split('.').shift(), v);\n}",
422            "xtype" : "ColumnModel",
423            "Number xs" : 2,
424            "$ xns" : "Roo.grid",
425            "* prop" : "cm[]"
426           },
427           {
428            "String header" : "Permission",
429            "String dataIndex" : "descript",
430            "$ Function renderer" : "function (v) {\n    return String.format('{0}', v ? v : '');\n}",
431            "xtype" : "ColumnModel",
432            "Number xs" : 4,
433            "$ xns" : "Roo.grid",
434            "* prop" : "cm[]"
435           },
436           {
437            "String header" : "Add",
438            "String dataIndex" : "add",
439            "$ 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}",
440            "xtype" : "ColumnModel",
441            "Number xs" : 1,
442            "String align" : "center",
443            "$ xns" : "Roo.grid",
444            "Boolean sortable" : false,
445            "* prop" : "cm[]"
446           },
447           {
448            "String header" : "Edit",
449            "String dataIndex" : "edit",
450            "$ 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}",
451            "xtype" : "ColumnModel",
452            "Number xs" : 1,
453            "String align" : "center",
454            "$ xns" : "Roo.grid",
455            "Boolean sortable" : false,
456            "* prop" : "cm[]"
457           },
458           {
459            "String header" : "Delete",
460            "String dataIndex" : "delete",
461            "$ 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}",
462            "xtype" : "ColumnModel",
463            "Number xs" : 1,
464            "String align" : "center",
465            "$ xns" : "Roo.grid",
466            "Boolean sortable" : false,
467            "* prop" : "cm[]"
468           },
469           {
470            "String header" : "List / View",
471            "String dataIndex" : "view",
472            "$ 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}",
473            "xtype" : "ColumnModel",
474            "Number xs" : 1,
475            "String align" : "center",
476            "$ xns" : "Roo.grid",
477            "Boolean sortable" : false,
478            "* prop" : "cm[]"
479           },
480           {
481            "String header" : "Print / Export",
482            "String dataIndex" : "print",
483            "$ 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}",
484            "xtype" : "ColumnModel",
485            "Number xs" : 1,
486            "String align" : "center",
487            "$ xns" : "Roo.grid",
488            "Boolean sortable" : false,
489            "* prop" : "cm[]"
490           }
491          ]
492         }
493        ]
494       },
495       {
496        "listeners" : {
497         "activate" : "function (_self)\n{\n    if (_this.group_grid) {\n        _this.group_grid.store.load({});\n    }\n}",
498         "render" : "function (_self)\n{\n    _this.group_panel = _self;\n}"
499        },
500        "Boolean fitContainer" : true,
501        "xtype" : "Grid",
502        "Boolean fitToFrame" : true,
503        "String region" : "west",
504        "$ xns" : "Roo.bootstrap.panel",
505        "String title" : "Groups",
506        "Boolean background" : false,
507        "items" : [
508         {
509          "xtype" : "NavSimplebar",
510          "$ xns" : "Roo.bootstrap",
511          "* prop" : "toolbar",
512          "items" : [
513           {
514            "xtype" : "NavGroup",
515            "$ xns" : "Roo.bootstrap",
516            "items" : [
517             {
518              "Boolean preventDefault" : true,
519              "xtype" : "NavSidebarItem",
520              "$ xns" : "Roo.bootstrap",
521              "String html" : "Manage Groups ",
522              "String glyphicon" : "menu-hamburger",
523              "items" : [
524               {
525                "xtype" : "Menu",
526                "$ xns" : "Roo.bootstrap",
527                "* prop" : "menu",
528                "items" : [
529                 {
530                  "listeners" : {
531                   "click" : "function (_self, e)\n{\n    Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){\n        _this.group_grid.store.load({});\n    });\n}"
532                  },
533                  "Boolean preventDefault" : true,
534                  "xtype" : "MenuItem",
535                  "String fa" : "fa fa-plus",
536                  "$ xns" : "Roo.bootstrap",
537                  "Boolean isContainer" : false,
538                  "String html" : "Add"
539                 },
540                 {
541                  "listeners" : {
542                   "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}"
543                  },
544                  "Boolean preventDefault" : true,
545                  "xtype" : "MenuItem",
546                  "String fa" : "fa fa-pencil",
547                  "$ xns" : "Roo.bootstrap",
548                  "Boolean isContainer" : false,
549                  "String html" : "Edit"
550                 },
551                 {
552                  "listeners" : {
553                   "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}"
554                  },
555                  "Boolean preventDefault" : true,
556                  "xtype" : "MenuItem",
557                  "String fa" : "fa fa-trash",
558                  "$ xns" : "Roo.bootstrap",
559                  "Boolean isContainer" : false,
560                  "String html" : "Delete"
561                 },
562                 {
563                  "listeners" : {
564                   "click" : "function (_self, e)\n{\n    _this.group_grid.store.load({});\n}"
565                  },
566                  "Boolean preventDefault" : true,
567                  "xtype" : "MenuItem",
568                  "String fa" : "fa fa-refresh",
569                  "$ xns" : "Roo.bootstrap",
570                  "Boolean isContainer" : false,
571                  "String html" : "Reload"
572                 }
573                ]
574               }
575              ]
576             }
577            ]
578           }
579          ]
580         },
581         {
582          "listeners" : {
583           "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}",
584           "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}",
585           "render" : "function (_self)\n{\n    _this.group_grid = _self; \n\n    if (_this.group_panel.active) {\n        _this.group_grid.store.load({});\n    }\n}"
586          },
587          "String cls" : "table-fixed",
588          "Boolean footerShow" : false,
589          "boolean hover" : true,
590          "boolean striped" : true,
591          "xtype" : "Table",
592          "boolean responsive" : true,
593          "Boolean rowSelection" : true,
594          "$ xns" : "Roo.bootstrap",
595          "Boolean loadMask" : true,
596          "* prop" : "grid",
597          "items" : [
598           {
599            "listeners" : {
600             "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}"
601            },
602            "Boolean singleSelect" : true,
603            "xtype" : "RowSelectionModel",
604            "$ xns" : "Roo.bootstrap.Table",
605            "* prop" : "sm"
606           },
607           {
608            "listeners" : {
609             "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}"
610            },
611            "xtype" : "Store",
612            "boolean remoteSort" : true,
613            "$ xns" : "Roo.data",
614            "$ sortInfo" : "{ field: 'name', direction: 'ASC'}",
615            "* prop" : "store",
616            "items" : [
617             {
618              "$ 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]",
619              "xtype" : "JsonReader",
620              "String root" : "data",
621              "$ xns" : "Roo.data",
622              "String id" : "id",
623              "* prop" : "reader",
624              "String totalProperty" : "total"
625             },
626             {
627              "$ url" : "baseURL + '/Roo/core_group'",
628              "xtype" : "HttpProxy",
629              "$ xns" : "Roo.data",
630              "String method" : "GET",
631              "* prop" : "proxy"
632             }
633            ]
634           },
635           {
636            "String header" : "Name",
637            "String cursor" : "pointer",
638            "Number md" : 12,
639            "String dataIndex" : "name",
640            "xtype" : "ColumnModel",
641            "Number xs" : 12,
642            "$ xns" : "Roo.grid",
643            "$ 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}",
644            "Boolean sortable" : false,
645            "* prop" : "cm[]",
646            "Number sm" : 12
647           }
648          ]
649         }
650        ]
651       }
652      ]
653     }
654    ]
655   }
656  ]
657 }