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   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
10   "b15aafc19dc2ba4b788adf77268d8ca4" : "Hide Inactive",
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" : 12,
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                 }
179                ]
180               }
181              ]
182             }
183            ]
184           }
185          ]
186         },
187         {
188          "listeners" : {
189           "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}",
190           "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}",
191           "render" : "function (_self)\n{\n    _this.member_grid = _self;\n   \n}"
192          },
193          "String cls" : "table-fixed",
194          "Boolean cellSelection" : true,
195          "boolean hover" : true,
196          "boolean striped" : false,
197          "xtype" : "Table",
198          "boolean responsive" : true,
199          "Boolean rowSelection" : true,
200          "$ xns" : "Roo.bootstrap",
201          "Boolean loadMask" : true,
202          "* prop" : "grid",
203          "items" : [
204           {
205            "listeners" : {
206             "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}"
207            },
208            "xtype" : "RowSelectionModel",
209            "$ xns" : "Roo.bootstrap.Table",
210            "* prop" : "sm"
211           },
212           {
213            "listeners" : {
214             "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}",
215             "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}",
216             "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}"
217            },
218            "xtype" : "Store",
219            "boolean remoteSort" : true,
220            "$ xns" : "Roo.data",
221            "$ sortInfo" : "{ field: 'name', direction: 'ASC' }",
222            "* prop" : "store",
223            "items" : [
224             {
225              "xtype" : "JsonReader",
226              "String root" : "data",
227              "$ xns" : "Roo.data",
228              "String id" : "id",
229              "* prop" : "reader",
230              "String totalProperty" : "total"
231             },
232             {
233              "$ url" : "baseURL + '/Roo/core_person'",
234              "xtype" : "HttpProxy",
235              "$ xns" : "Roo.data",
236              "String method" : "GET",
237              "* prop" : "proxy"
238             }
239            ]
240           },
241           {
242            "Object listeners" : "{\n    \"click\" : function (e){\n        console.log(\"listener fired\");\n    }\n}",
243            "String header" : "Active",
244            "String cursor" : "pointer",
245            "Number md" : 1,
246            "String dataIndex" : "active",
247            "xtype" : "ColumnModel",
248            "Number xs" : 1,
249            "String align" : "center",
250            "$ xns" : "Roo.grid",
251            "$ 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 }",
252            "Boolean sortable" : true,
253            "* prop" : "cm[]",
254            "Number sm" : 1
255           },
256           {
257            "String header" : "Name",
258            "String cursor" : "pointer",
259            "Number md" : 3,
260            "String dataIndex" : "name",
261            "xtype" : "ColumnModel",
262            "Number xs" : 3,
263            "$ xns" : "Roo.grid",
264            "$ 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}",
265            "Boolean sortable" : true,
266            "* prop" : "cm[]",
267            "Number sm" : 3
268           },
269           {
270            "String header" : "Role / Position",
271            "String cursor" : "pointer",
272            "Number md" : 2,
273            "String dataIndex" : "role",
274            "xtype" : "ColumnModel",
275            "Number xs" : 2,
276            "$ xns" : "Roo.grid",
277            "$ renderer" : "function(v) { return String.format('{0}', v); }",
278            "Boolean sortable" : true,
279            "* prop" : "cm[]",
280            "Number sm" : 2
281           },
282           {
283            "String header" : "Phone",
284            "String cursor" : "pointer",
285            "Number md" : 2,
286            "String dataIndex" : "phone",
287            "xtype" : "ColumnModel",
288            "Number xs" : 2,
289            "$ xns" : "Roo.grid",
290            "$ renderer" : "function(v) { return String.format('{0}', v); }",
291            "* prop" : "cm[]",
292            "Number sm" : 2
293           },
294           {
295            "String header" : "Email",
296            "String cursor" : "pointer",
297            "Number md" : 4,
298            "String dataIndex" : "email",
299            "xtype" : "ColumnModel",
300            "Number xs" : 4,
301            "$ xns" : "Roo.grid",
302            "$ 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}",
303            "Boolean sortable" : true,
304            "* prop" : "cm[]",
305            "Number sm" : 4
306           },
307           {
308            "Number pageSize" : 25,
309            "Boolean displayInfo" : false,
310            "xtype" : "PagingToolbar",
311            "$ xns" : "Roo.bootstrap",
312            "* prop" : "footer",
313            "string name" : "footer",
314            "items" : [
315             {
316              "listeners" : {
317               "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}",
318               "render" : "function (_self)\n{\n    _this.footerActiveBtn = this;\n}"
319              },
320              "String cls" : "btn btn-default",
321              "String _offtext" : "Show Inactive",
322              "xtype" : "Button",
323              "String _ontext" : "Hide Inactive",
324              "$ xns" : "Roo.bootstrap",
325              "Boolean pressed" : false,
326              "String style" : "margin-left: 10px;",
327              "String html" : "Show Inactive",
328              "* prop" : "buttons[]",
329              "name" : "activeButton"
330             }
331            ]
332           }
333          ]
334         }
335        ]
336       },
337       {
338        "listeners" : {
339         "activate" : "function (_self)\n{\n    if(_this.permission_grid) {\n        _this.permission_grid.store.load({});\n    }\n}",
340         "render" : "function (_self)\n{\n    _this.permission_panel = this;\n}"
341        },
342        "Boolean fitContainer" : true,
343        "xtype" : "Grid",
344        "Boolean fitToFrame" : true,
345        "String region" : "center",
346        "$ xns" : "Roo.bootstrap.panel",
347        "String title" : "Permission List",
348        "Boolean background" : true,
349        "Boolean closable" : false,
350        "items" : [
351         {
352          "listeners" : {
353           "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}",
354           "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}"
355          },
356          "Boolean footerShow" : false,
357          "Boolean cellSelection" : true,
358          "String cls" : "table-fixed",
359          "boolean striped" : true,
360          "boolean hover" : true,
361          "xtype" : "Table",
362          "boolean responsive" : true,
363          "Boolean rowSelection" : true,
364          "$ xns" : "Roo.bootstrap",
365          "Boolean loadMask" : true,
366          "* prop" : "grid",
367          "items" : [
368           {
369            "Boolean singleSelect" : true,
370            "xtype" : "RowSelectionModel",
371            "$ xns" : "Roo.bootstrap.Table",
372            "* prop" : "sm"
373           },
374           {
375            "listeners" : {
376             "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}",
377             "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}"
378            },
379            "xtype" : "Store",
380            "boolean remoteSort" : true,
381            "$ xns" : "Roo.data",
382            "$ sortInfo" : "{ field: 'rightname', direction: 'ASC' }",
383            "* prop" : "store",
384            "items" : [
385             {
386              "$ 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]",
387              "xtype" : "JsonReader",
388              "String root" : "data",
389              "$ xns" : "Roo.data",
390              "String id" : "id",
391              "* prop" : "reader",
392              "String totalProperty" : "total"
393             },
394             {
395              "xtype" : "HttpProxy",
396              "$ xns" : "Roo.data",
397              "String method" : "GET",
398              "* prop" : "proxy",
399              "$ String url" : "baseURL + '/BAdmin/GroupRights.php'"
400             }
401            ]
402           },
403           {
404            "String header" : "[All]",
405            "String dataIndex" : "id",
406            "$ 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",
407            "xtype" : "ColumnModel",
408            "Number xs" : 1,
409            "String align" : "center",
410            "$ xns" : "Roo.grid",
411            "Boolean sortable" : false,
412            "* prop" : "cm[]"
413           },
414           {
415            "String header" : "Module",
416            "String dataIndex" : "rightname",
417            "$ Function renderer" : "function (v) {\n    return String.format('<span tooltip=\"{1}\">{0}</span>', v.split('.').shift(), v);\n}",
418            "xtype" : "ColumnModel",
419            "Number xs" : 2,
420            "$ xns" : "Roo.grid",
421            "* prop" : "cm[]"
422           },
423           {
424            "String header" : "Permission",
425            "String dataIndex" : "descript",
426            "$ Function renderer" : "function (v) {\n    return String.format('{0}', v ? v : '');\n}",
427            "xtype" : "ColumnModel",
428            "Number xs" : 4,
429            "$ xns" : "Roo.grid",
430            "* prop" : "cm[]"
431           },
432           {
433            "String header" : "Add",
434            "String dataIndex" : "add",
435            "$ 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}",
436            "xtype" : "ColumnModel",
437            "Number xs" : 1,
438            "String align" : "center",
439            "$ xns" : "Roo.grid",
440            "Boolean sortable" : false,
441            "* prop" : "cm[]"
442           },
443           {
444            "String header" : "Edit",
445            "String dataIndex" : "edit",
446            "$ 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}",
447            "xtype" : "ColumnModel",
448            "Number xs" : 1,
449            "String align" : "center",
450            "$ xns" : "Roo.grid",
451            "Boolean sortable" : false,
452            "* prop" : "cm[]"
453           },
454           {
455            "String header" : "Delete",
456            "String dataIndex" : "delete",
457            "$ 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}",
458            "xtype" : "ColumnModel",
459            "Number xs" : 1,
460            "String align" : "center",
461            "$ xns" : "Roo.grid",
462            "Boolean sortable" : false,
463            "* prop" : "cm[]"
464           },
465           {
466            "String header" : "List / View",
467            "String dataIndex" : "view",
468            "$ 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}",
469            "xtype" : "ColumnModel",
470            "Number xs" : 1,
471            "String align" : "center",
472            "$ xns" : "Roo.grid",
473            "Boolean sortable" : false,
474            "* prop" : "cm[]"
475           },
476           {
477            "String header" : "Print / Export",
478            "String dataIndex" : "print",
479            "$ 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}",
480            "xtype" : "ColumnModel",
481            "Number xs" : 1,
482            "String align" : "center",
483            "$ xns" : "Roo.grid",
484            "Boolean sortable" : false,
485            "* prop" : "cm[]"
486           }
487          ]
488         }
489        ]
490       },
491       {
492        "listeners" : {
493         "activate" : "function (_self)\n{\n    if (_this.group_grid) {\n        _this.group_grid.store.load({});\n    }\n}",
494         "render" : "function (_self)\n{\n    _this.group_panel = _self;\n}"
495        },
496        "Boolean fitContainer" : true,
497        "xtype" : "Grid",
498        "Boolean fitToFrame" : true,
499        "String region" : "west",
500        "$ xns" : "Roo.bootstrap.panel",
501        "String title" : "Groups",
502        "Boolean background" : false,
503        "items" : [
504         {
505          "xtype" : "NavSimplebar",
506          "$ xns" : "Roo.bootstrap",
507          "* prop" : "toolbar",
508          "items" : [
509           {
510            "xtype" : "NavGroup",
511            "$ xns" : "Roo.bootstrap",
512            "items" : [
513             {
514              "Boolean preventDefault" : true,
515              "xtype" : "NavSidebarItem",
516              "$ xns" : "Roo.bootstrap",
517              "String html" : "Manage Groups ",
518              "String glyphicon" : "menu-hamburger",
519              "items" : [
520               {
521                "xtype" : "Menu",
522                "$ xns" : "Roo.bootstrap",
523                "* prop" : "menu",
524                "items" : [
525                 {
526                  "listeners" : {
527                   "click" : "function (_self, e)\n{\n    Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){\n        _this.group_grid.store.load({});\n    });\n}"
528                  },
529                  "Boolean preventDefault" : true,
530                  "xtype" : "MenuItem",
531                  "String fa" : "fa fa-plus",
532                  "$ xns" : "Roo.bootstrap",
533                  "Boolean isContainer" : false,
534                  "String html" : "Add"
535                 },
536                 {
537                  "listeners" : {
538                   "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}"
539                  },
540                  "Boolean preventDefault" : true,
541                  "xtype" : "MenuItem",
542                  "String fa" : "fa fa-pencil",
543                  "$ xns" : "Roo.bootstrap",
544                  "Boolean isContainer" : false,
545                  "String html" : "Edit"
546                 },
547                 {
548                  "listeners" : {
549                   "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}"
550                  },
551                  "Boolean preventDefault" : true,
552                  "xtype" : "MenuItem",
553                  "String fa" : "fa fa-trash",
554                  "$ xns" : "Roo.bootstrap",
555                  "Boolean isContainer" : false,
556                  "String html" : "Delete"
557                 },
558                 {
559                  "listeners" : {
560                   "click" : "function (_self, e)\n{\n    _this.group_grid.store.load({});\n}"
561                  },
562                  "Boolean preventDefault" : true,
563                  "xtype" : "MenuItem",
564                  "String fa" : "fa fa-refresh",
565                  "$ xns" : "Roo.bootstrap",
566                  "Boolean isContainer" : false,
567                  "String html" : "Reload"
568                 }
569                ]
570               }
571              ]
572             }
573            ]
574           }
575          ]
576         },
577         {
578          "listeners" : {
579           "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}",
580           "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}",
581           "render" : "function (_self)\n{\n    _this.group_grid = _self; \n\n    if (_this.group_panel.active) {\n        _this.group_grid.store.load({});\n    }\n}"
582          },
583          "String cls" : "table-fixed",
584          "Boolean footerShow" : false,
585          "boolean hover" : true,
586          "boolean striped" : true,
587          "xtype" : "Table",
588          "boolean responsive" : true,
589          "Boolean rowSelection" : true,
590          "$ xns" : "Roo.bootstrap",
591          "Boolean loadMask" : true,
592          "* prop" : "grid",
593          "items" : [
594           {
595            "listeners" : {
596             "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}"
597            },
598            "Boolean singleSelect" : true,
599            "xtype" : "RowSelectionModel",
600            "$ xns" : "Roo.bootstrap.Table",
601            "* prop" : "sm"
602           },
603           {
604            "listeners" : {
605             "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}"
606            },
607            "xtype" : "Store",
608            "boolean remoteSort" : true,
609            "$ xns" : "Roo.data",
610            "$ sortInfo" : "{ field: 'name', direction: 'ASC'}",
611            "* prop" : "store",
612            "items" : [
613             {
614              "xtype" : "JsonReader",
615              "String root" : "data",
616              "$ xns" : "Roo.data",
617              "String id" : "id",
618              "* prop" : "reader",
619              "String totalProperty" : "total"
620             },
621             {
622              "$ url" : "baseURL + '/Roo/core_group'",
623              "xtype" : "HttpProxy",
624              "$ xns" : "Roo.data",
625              "String method" : "GET",
626              "* prop" : "proxy"
627             }
628            ]
629           },
630           {
631            "String header" : "Name",
632            "String cursor" : "pointer",
633            "Number md" : 12,
634            "String dataIndex" : "name",
635            "xtype" : "ColumnModel",
636            "Number xs" : 12,
637            "$ xns" : "Roo.grid",
638            "$ renderer" : "function(v,x,r) { \n    //console.log(r.data);\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    if (v == 'Administrators') {\n        return '<b>' + \"Adminstrators\" + '</b>';\n    }\n    \n    if (r.data.leader) {\n        return v + ' (' + r.data.leader_name + ')';\n    }\n    \n    return String.format('{0} ({1})',v, r.json.group_member_count);\n}",
639            "Boolean sortable" : false,
640            "* prop" : "cm[]",
641            "Number sm" : 12
642           }
643          ]
644         }
645        ]
646       }
647      ]
648     }
649    ]
650   }
651  ]
652 }