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