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