sync
[Pman.BAdmin] / Pman.Tab.BAdminStaff.bjs
1 {
2  "name" : "Pman.Tab.BAdminStaff",
3  "parent" : "Pman.Tab.BAdmin",
4  "title" : "",
5  "path" : "/home/alan/gitlive/Pman.BAdmin/Pman.Tab.BAdminStaff.bjs",
6  "permname" : "",
7  "modOrder" : "003",
8  "strings" : {
9   "1c76cbfe21c6f44c1d1e59d54f3e4420" : "Company",
10   "0bf419ac695151a786ed60eeec73d87b" : "Office / Dept.",
11   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
12   "b15aafc19dc2ba4b788adf77268d8ca4" : "Hide Inactive",
13   "f29c99f082755399839b64ebaf9f608a" : "List / View",
14   "4f3cdff2e6a5e08440be182ef40d93f7" : "Print / Export",
15   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
16   "9e727fdd3aec8274f46685441900280d" : "Project",
17   "a37ede293936e29279ed543129451ec3" : "Groups",
18   "7dce122004969d56ae2e0245cb754d35" : "Edit",
19   "05b763f7d24f32575493b3c23f299b0e" : "Add To Group",
20   "aba9f7d7443652e858969bfc280690b1" : "Manage Groups ",
21   "e0a7cc944485bdedafb92b0cf98632fa" : "Remove From Group",
22   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
23   "25f57527ae8a27c94fb5230b5486c743" : "Permission List",
24   "054176c3a541fb2d4b63e29360c749aa" : "Members List",
25   "8a25a3ae30ab6e8ceb5b8c4009a3336f" : "Role / Position",
26   "17050e1914aff1e423a84e76db8ab0d1" : "[All]",
27   "5bc3fd20294c17c9803942958fd7f26d" : "Show Inactive",
28   "4d1c8263ba1036754f8db14a98f9f006" : "Reload",
29   "74251a9b957f96bca3985fbac6840c52" : "Users / Permissions",
30   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
31   "ec3249f16ee5880d4c1acb752e5c925f" : "Switch to Selected User",
32   "a1fa27779242b4902f7ae3bdd5c6d508" : "Type",
33   "49ee3087348e8d44e1feda1917443987" : "Name",
34   "4d3d769b812b6faa6b76e1a8abaece2d" : "Active",
35   "e55f75a29310d7b60f7ac1d390c8ae42" : "Module",
36   "ed5dea09095f671b801bee34ea28a319" : "Permission",
37   "9810aa2b9f44401be4bf73188ef2b67d" : "Fax"
38  },
39  "named_strings" : {
40   "activeButton_offtext" : "5bc3fd20294c17c9803942958fd7f26d",
41   "activeButton_ontext" : "b15aafc19dc2ba4b788adf77268d8ca4",
42   "activeButton_html" : "5bc3fd20294c17c9803942958fd7f26d"
43  },
44  "items" : [
45   {
46    "listeners" : {
47     "activate" : "function (_self)\n{\n    if ( _this.group_grid) {\n         _this.group_grid.store.load({});\n    }\n}"
48    },
49    "xtype" : "Nest",
50    "$ xns" : "Roo.bootstrap.panel",
51    "String title" : "Users / Permissions",
52    "Boolean background" : true,
53    "items" : [
54     {
55      "xtype" : "Border",
56      "$ xns" : "Roo.bootstrap.layout",
57      "* prop" : "layout",
58      "items" : [
59       {
60        "String tabPosition" : "top",
61        "xtype" : "Region",
62        "$ xns" : "Roo.bootstrap.layout",
63        "* prop" : "center"
64       },
65       {
66        "String tabPosition" : "top",
67        "Number width" : 250,
68        "xtype" : "Region",
69        "$ xns" : "Roo.bootstrap.layout",
70        "* prop" : "west",
71        "Boolean split" : true
72       },
73       {
74        "listeners" : {
75         "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}",
76         "render" : "function (_self)\n{\n    _this.member_panel = _self; \n}"
77        },
78        "Boolean fitContainer" : true,
79        "xtype" : "Grid",
80        "Boolean fitToFrame" : true,
81        "String region" : "center",
82        "$ xns" : "Roo.bootstrap.panel",
83        "String title" : "Members List",
84        "Boolean background" : false,
85        "Boolean closable" : false,
86        "items" : [
87         {
88          "xtype" : "NavSimplebar",
89          "$ xns" : "Roo.bootstrap",
90          "* prop" : "toolbar",
91          "items" : [
92           {
93            "xtype" : "NavGroup",
94            "$ xns" : "Roo.bootstrap",
95            "items" : [
96             {
97              "xtype" : "NavItem",
98              "$ xns" : "Roo.bootstrap",
99              "items" : [
100               {
101                "xtype" : "Element",
102                "$ xns" : "Roo.bootstrap",
103                "items" : [
104                 {
105                  "String cls" : "roo-toolbar",
106                  "xtype" : "Row",
107                  "$ xns" : "Roo.bootstrap",
108                  "items" : [
109                   {
110                    "Number md" : 12,
111                    "xtype" : "Column",
112                    "$ xns" : "Roo.bootstrap",
113                    "items" : [
114                     {
115                      "listeners" : {
116                       "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}"
117                      },
118                      "String cls" : "roo-toolbar-button",
119                      "String weight" : "default",
120                      "xtype" : "Button",
121                      "$ xns" : "Roo.bootstrap",
122                      "String html" : "Add",
123                      "String glyphicon" : "plus"
124                     },
125                     {
126                      "listeners" : {
127                       "render" : "function (_self)\n{\n    _this.edit_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
128                       "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}"
129                      },
130                      "String cls" : "roo-toolbar-button",
131                      "String weight" : "default",
132                      "xtype" : "Button",
133                      "$ xns" : "Roo.bootstrap",
134                      "String html" : "Edit",
135                      "String glyphicon" : "edit"
136                     },
137                     {
138                      "listeners" : {
139                       "render" : "function (_self)\n{\n    _this.delete_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
140                       "click" : "function (_self, e)\n{\n    // from pman.js\n    Pman.genericDelete(_this.member_panel, 'core_person');\n    \n    \n}"
141                      },
142                      "String cls" : "roo-toolbar-button",
143                      "String weight" : "primary",
144                      "xtype" : "Button",
145                      "$ xns" : "Roo.bootstrap",
146                      "String html" : "Delete",
147                      "String glyphicon" : "trash"
148                     },
149                     {
150                      "listeners" : {
151                       "render" : "function (_self)\n{\n    _this.addToGroupBtn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
152                       "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}"
153                      },
154                      "String cls" : "roo-toolbar-button",
155                      "String weight" : "default",
156                      "xtype" : "Button",
157                      "$ xns" : "Roo.bootstrap",
158                      "String html" : "Add To Group",
159                      "String glyphicon" : "plus"
160                     },
161                     {
162                      "listeners" : {
163                       "render" : "function (_self)\n{\n    _this.removeFromGroupBtn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
164                       "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}"
165                      },
166                      "String cls" : "roo-toolbar-button",
167                      "String weight" : "default",
168                      "xtype" : "Button",
169                      "$ xns" : "Roo.bootstrap",
170                      "String html" : "Remove From Group",
171                      "String glyphicon" : "trash"
172                     },
173                     {
174                      "listeners" : {
175                       "render" : "function (_self)\n{\n    _this.switch_btn = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
176                       "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}"
177                      },
178                      "String cls" : "roo-toolbar-button",
179                      "String weight" : "default",
180                      "xtype" : "Button",
181                      "$ xns" : "Roo.bootstrap",
182                      "String html" : "Switch to Selected User",
183                      "String glyphicon" : "user"
184                     }
185                    ]
186                   }
187                  ]
188                 }
189                ]
190               }
191              ]
192             }
193            ]
194           }
195          ]
196         },
197         {
198          "listeners" : {
199           "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}",
200           "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}",
201           "render" : "function (_self)\n{\n    _this.member_grid = _self;\n   \n}"
202          },
203          "String cls" : "table-fixed",
204          "Boolean cellSelection" : true,
205          "boolean hover" : true,
206          "boolean striped" : false,
207          "xtype" : "Table",
208          "boolean responsive" : true,
209          "Boolean rowSelection" : true,
210          "$ xns" : "Roo.bootstrap",
211          "Boolean loadMask" : true,
212          "* prop" : "grid",
213          "items" : [
214           {
215            "listeners" : {
216             "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}"
217            },
218            "xtype" : "RowSelectionModel",
219            "$ xns" : "Roo.bootstrap.Table",
220            "* prop" : "sm"
221           },
222           {
223            "listeners" : {
224             "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}",
225             "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}",
226             "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}"
227            },
228            "xtype" : "Store",
229            "boolean remoteSort" : true,
230            "$ xns" : "Roo.data",
231            "$ sortInfo" : "{ field: 'name', direction: 'ASC' }",
232            "* prop" : "store",
233            "items" : [
234             {
235              "xtype" : "JsonReader",
236              "String root" : "data",
237              "$ xns" : "Roo.data",
238              "String id" : "id",
239              "* prop" : "reader",
240              "String totalProperty" : "total"
241             },
242             {
243              "$ url" : "baseURL + '/Roo/core_person'",
244              "xtype" : "HttpProxy",
245              "$ xns" : "Roo.data",
246              "String method" : "GET",
247              "* prop" : "proxy"
248             }
249            ]
250           },
251           {
252            "String header" : "Project",
253            "String cursor" : "pointer",
254            "String dataIndex" : "project_id_code",
255            "xtype" : "ColumnModel",
256            "$ xns" : "Roo.grid",
257            "$ renderer" : "function(v,x,r) {\n    if (r.data.office_id) {\n        return String.format('{0} - {1}', v, r.data.office_id_name); \n    } \n    return String.format('{0}', v); \n}",
258            "Boolean sortable" : false,
259            "* prop" : "cm[]",
260            "Boolean hidden" : true
261           },
262           {
263            "String header" : "Type",
264            "String cursor" : "pointer",
265            "Number md" : 1,
266            "String dataIndex" : "company_id_comptype",
267            "xtype" : "ColumnModel",
268            "Number xs" : 1,
269            "$ xns" : "Roo.grid",
270            "$ renderer" : "function(v,x,r) {\n    if (r.data.office_id) {\n            return String.format('{0} - {1}', v, r.data.office_id_name); \n       } \n   return String.format('{0}', v);\n}",
271            "Boolean sortable" : true,
272            "* prop" : "cm[]",
273            "Number sm" : 1
274           },
275           {
276            "String header" : "Company",
277            "String cursor" : "pointer",
278            "Number md" : 2,
279            "String dataIndex" : "company_id_name",
280            "xtype" : "ColumnModel",
281            "Number xs" : 2,
282            "$ xns" : "Roo.grid",
283            "$ renderer" : "function(v,x,r) {\n    if (r.data.office_id) {\n        return String.format('{0} - {1}', v, r.data.office_id_name); \n    } \n    return String.format('{0}', v); \n}",
284            "Boolean sortable" : true,
285            "* prop" : "cm[]",
286            "Number sm" : 2
287           },
288           {
289            "String header" : "Name",
290            "String cursor" : "pointer",
291            "Number md" : 2,
292            "String dataIndex" : "name",
293            "xtype" : "ColumnModel",
294            "Number xs" : 2,
295            "$ xns" : "Roo.grid",
296            "$ 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}",
297            "Boolean sortable" : true,
298            "* prop" : "cm[]",
299            "Number sm" : 2
300           },
301           {
302            "String header" : "Office / Dept.",
303            "String cursor" : "pointer",
304            "Number md" : 1,
305            "String dataIndex" : "office_id_name",
306            "xtype" : "ColumnModel",
307            "Number xs" : 1,
308            "$ xns" : "Roo.grid",
309            "$ renderer" : "function(v) { return String.format('{0}', v); }",
310            "Boolean sortable" : true,
311            "* prop" : "cm[]",
312            "Number sm" : 1
313           },
314           {
315            "String header" : "Role / Position",
316            "String cursor" : "pointer",
317            "Number md" : 1,
318            "String dataIndex" : "role",
319            "xtype" : "ColumnModel",
320            "Number xs" : 1,
321            "$ xns" : "Roo.grid",
322            "$ renderer" : "function(v) { return String.format('{0}', v); }",
323            "Boolean sortable" : true,
324            "* prop" : "cm[]",
325            "Number sm" : 1
326           },
327           {
328            "String header" : "Phone",
329            "String cursor" : "pointer",
330            "Number md" : 1,
331            "String dataIndex" : "phone",
332            "xtype" : "ColumnModel",
333            "Number xs" : 1,
334            "$ xns" : "Roo.grid",
335            "$ renderer" : "function(v) { return String.format('{0}', v); }",
336            "Boolean sortable" : true,
337            "* prop" : "cm[]",
338            "Number sm" : 1
339           },
340           {
341            "String header" : "Fax",
342            "String cursor" : "pointer",
343            "Number md" : 1,
344            "String dataIndex" : "fax",
345            "xtype" : "ColumnModel",
346            "Number xs" : 1,
347            "$ xns" : "Roo.grid",
348            "$ renderer" : "function(v) { return String.format('{0}', v); }",
349            "Boolean sortable" : true,
350            "* prop" : "cm[]",
351            "Number sm" : 1
352           },
353           {
354            "String header" : "Email",
355            "String cursor" : "pointer",
356            "Number md" : 2,
357            "String dataIndex" : "email",
358            "xtype" : "ColumnModel",
359            "Number xs" : 2,
360            "$ xns" : "Roo.grid",
361            "$ 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}",
362            "Boolean sortable" : true,
363            "* prop" : "cm[]",
364            "Number sm" : 2
365           },
366           {
367            "String header" : "Active",
368            "String cursor" : "pointer",
369            "Object listeners" : "{\n    \"click\" : function (e){\n        console.log(\"listener fired\");\n    }\n}",
370            "Number md" : 1,
371            "String dataIndex" : "active",
372            "xtype" : "ColumnModel",
373            "Number xs" : 1,
374            "$ xns" : "Roo.grid",
375            "$ renderer" : "function(v) {  \n//    var state = v> 0 ?  '-checked' : '';\n    var state = v> 0 ?  'check-' : '';\n    \n    //return '<img class=\\\"x-grid-check-icon' + state + '\\\" src=\\\"' + Roo.BLANK_IMAGE_URL + '\\\"/>';\n    return '<i class=\\\"far fa-'+ state + 'square-o fa-2x\\\" aria-hidden=\\\"true\\\"></i>';\n                \n }",
376            "Boolean sortable" : true,
377            "* prop" : "cm[]",
378            "Number sm" : 1
379           },
380           {
381            "Number pageSize" : 25,
382            "Boolean displayInfo" : false,
383            "xtype" : "PagingToolbar",
384            "$ xns" : "Roo.bootstrap",
385            "* prop" : "footer",
386            "string name" : "footer",
387            "items" : [
388             {
389              "listeners" : {
390               "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}",
391               "render" : "function (_self)\n{\n    _this.footerActiveBtn = this;\n}"
392              },
393              "String cls" : "btn btn-default",
394              "String _offtext" : "Show Inactive",
395              "xtype" : "Button",
396              "String _ontext" : "Hide Inactive",
397              "$ xns" : "Roo.bootstrap",
398              "Boolean pressed" : false,
399              "String style" : "margin-left: 10px;",
400              "String html" : "Show Inactive",
401              "* prop" : "buttons[]",
402              "name" : "activeButton"
403             }
404            ]
405           }
406          ]
407         }
408        ]
409       },
410       {
411        "listeners" : {
412         "activate" : "function (_self)\n{\n    if(_this.permission_grid) {\n        _this.permission_grid.store.load({});\n    }\n}",
413         "render" : "function (_self)\n{\n    _this.permission_panel = this;\n}"
414        },
415        "Boolean fitContainer" : true,
416        "xtype" : "Grid",
417        "Boolean fitToFrame" : true,
418        "String region" : "center",
419        "$ xns" : "Roo.bootstrap.panel",
420        "String title" : "Permission List",
421        "Boolean background" : true,
422        "Boolean closable" : false,
423        "items" : [
424         {
425          "listeners" : {
426           "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}",
427           "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}"
428          },
429          "Boolean cellSelection" : true,
430          "String cls" : "table-fixed",
431          "Boolean footerShow" : false,
432          "boolean striped" : true,
433          "boolean hover" : true,
434          "xtype" : "Table",
435          "boolean responsive" : true,
436          "Boolean rowSelection" : true,
437          "$ xns" : "Roo.bootstrap",
438          "Boolean loadMask" : true,
439          "* prop" : "grid",
440          "items" : [
441           {
442            "Boolean singleSelect" : true,
443            "xtype" : "RowSelectionModel",
444            "$ xns" : "Roo.bootstrap.Table",
445            "* prop" : "sm"
446           },
447           {
448            "listeners" : {
449             "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}",
450             "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}"
451            },
452            "xtype" : "Store",
453            "boolean remoteSort" : true,
454            "$ xns" : "Roo.data",
455            "$ sortInfo" : "{ field: 'rightname', direction: 'ASC' }",
456            "* prop" : "store",
457            "items" : [
458             {
459              "$ 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]",
460              "xtype" : "JsonReader",
461              "String root" : "data",
462              "$ xns" : "Roo.data",
463              "String id" : "id",
464              "* prop" : "reader",
465              "String totalProperty" : "total"
466             },
467             {
468              "xtype" : "HttpProxy",
469              "$ xns" : "Roo.data",
470              "String method" : "GET",
471              "* prop" : "proxy",
472              "$ String url" : "baseURL + '/BAdmin/GroupRights.php'"
473             }
474            ]
475           },
476           {
477            "String header" : "[All]",
478            "String dataIndex" : "id",
479            "$ 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) ? '-checked' : '';\n    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
480            "xtype" : "ColumnModel",
481            "Number xs" : 1,
482            "$ xns" : "Roo.grid",
483            "Boolean sortable" : false,
484            "* prop" : "cm[]"
485           },
486           {
487            "String header" : "Module",
488            "String dataIndex" : "rightname",
489            "$ Function renderer" : "function (v) {\n    return String.format('<span tooltip=\"{1}\">{0}</span>', v.split('.').shift(), v);\n}",
490            "xtype" : "ColumnModel",
491            "Number xs" : 2,
492            "$ xns" : "Roo.grid",
493            "* prop" : "cm[]"
494           },
495           {
496            "String header" : "Permission",
497            "String dataIndex" : "descript",
498            "$ Function renderer" : "function (v) {\n    return String.format('{0}', v ? v : '');\n}",
499            "xtype" : "ColumnModel",
500            "Number xs" : 4,
501            "$ xns" : "Roo.grid",
502            "* prop" : "cm[]"
503           },
504           {
505            "String header" : "Add",
506            "String dataIndex" : "add",
507            "$ 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) ? '-checked' : '';\n    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
508            "xtype" : "ColumnModel",
509            "Number xs" : 1,
510            "$ xns" : "Roo.grid",
511            "Boolean sortable" : false,
512            "* prop" : "cm[]"
513           },
514           {
515            "String header" : "Edit",
516            "String dataIndex" : "edit",
517            "$ 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) ? '-checked' : '';\n    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
518            "xtype" : "ColumnModel",
519            "Number xs" : 1,
520            "$ xns" : "Roo.grid",
521            "Boolean sortable" : false,
522            "* prop" : "cm[]"
523           },
524           {
525            "String header" : "Delete",
526            "String dataIndex" : "delete",
527            "$ 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) ? '-checked' : '';\n    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
528            "xtype" : "ColumnModel",
529            "Number xs" : 1,
530            "$ xns" : "Roo.grid",
531            "Boolean sortable" : false,
532            "* prop" : "cm[]"
533           },
534           {
535            "String header" : "List / View",
536            "String dataIndex" : "view",
537            "$ 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) ? '-checked' : '';\n    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
538            "xtype" : "ColumnModel",
539            "Number xs" : 1,
540            "$ xns" : "Roo.grid",
541            "Boolean sortable" : false,
542            "* prop" : "cm[]"
543           },
544           {
545            "String header" : "Print / Export",
546            "String dataIndex" : "print",
547            "$ 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) ? '-checked' : '';\n    \n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n}",
548            "xtype" : "ColumnModel",
549            "Number xs" : 1,
550            "$ xns" : "Roo.grid",
551            "Boolean sortable" : false,
552            "* prop" : "cm[]"
553           }
554          ]
555         }
556        ]
557       },
558       {
559        "listeners" : {
560         "activate" : "function (_self)\n{\n    if (_this.group_grid) {\n        _this.group_grid.store.load({});\n    }\n}",
561         "render" : "function (_self)\n{\n    _this.group_panel = _self;\n}"
562        },
563        "Boolean fitContainer" : true,
564        "xtype" : "Grid",
565        "Boolean fitToFrame" : true,
566        "String region" : "west",
567        "$ xns" : "Roo.bootstrap.panel",
568        "String title" : "Groups",
569        "Boolean background" : false,
570        "items" : [
571         {
572          "xtype" : "NavSimplebar",
573          "$ xns" : "Roo.bootstrap",
574          "* prop" : "toolbar",
575          "items" : [
576           {
577            "xtype" : "NavGroup",
578            "$ xns" : "Roo.bootstrap",
579            "items" : [
580             {
581              "Boolean preventDefault" : true,
582              "xtype" : "NavSidebarItem",
583              "$ xns" : "Roo.bootstrap",
584              "String html" : "Manage Groups ",
585              "String glyphicon" : "menu-hamburger",
586              "items" : [
587               {
588                "xtype" : "Menu",
589                "$ xns" : "Roo.bootstrap",
590                "* prop" : "menu",
591                "items" : [
592                 {
593                  "listeners" : {
594                   "click" : "function (_self, e)\n{\n    Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){\n        _this.group_grid.store.load({});\n    });\n}"
595                  },
596                  "Boolean preventDefault" : true,
597                  "xtype" : "MenuItem",
598                  "String fa" : "fa fa-plus",
599                  "$ xns" : "Roo.bootstrap",
600                  "Boolean isContainer" : false,
601                  "String html" : "Add"
602                 },
603                 {
604                  "listeners" : {
605                   "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}"
606                  },
607                  "Boolean preventDefault" : true,
608                  "xtype" : "MenuItem",
609                  "String fa" : "fa fa-pencil",
610                  "$ xns" : "Roo.bootstrap",
611                  "Boolean isContainer" : false,
612                  "String html" : "Edit"
613                 },
614                 {
615                  "listeners" : {
616                   "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}"
617                  },
618                  "Boolean preventDefault" : true,
619                  "xtype" : "MenuItem",
620                  "String fa" : "fa fa-trash",
621                  "$ xns" : "Roo.bootstrap",
622                  "Boolean isContainer" : false,
623                  "String html" : "Delete"
624                 },
625                 {
626                  "listeners" : {
627                   "click" : "function (_self, e)\n{\n    _this.group_grid.store.load({});\n}"
628                  },
629                  "Boolean preventDefault" : true,
630                  "xtype" : "MenuItem",
631                  "String fa" : "fa fa-refresh",
632                  "$ xns" : "Roo.bootstrap",
633                  "Boolean isContainer" : false,
634                  "String html" : "Reload"
635                 }
636                ]
637               }
638              ]
639             }
640            ]
641           }
642          ]
643         },
644         {
645          "listeners" : {
646           "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}",
647           "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}",
648           "render" : "function (_self)\n{\n    _this.group_grid = _self; \n\n    if (_this.group_panel.active) {\n        _this.group_grid.store.load({});\n    }\n}"
649          },
650          "String cls" : "table-fixed",
651          "Boolean footerShow" : false,
652          "boolean hover" : true,
653          "boolean striped" : true,
654          "xtype" : "Table",
655          "boolean responsive" : true,
656          "Boolean rowSelection" : true,
657          "$ xns" : "Roo.bootstrap",
658          "Boolean loadMask" : true,
659          "* prop" : "grid",
660          "items" : [
661           {
662            "listeners" : {
663             "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}"
664            },
665            "Boolean singleSelect" : true,
666            "xtype" : "RowSelectionModel",
667            "$ xns" : "Roo.bootstrap.Table",
668            "* prop" : "sm"
669           },
670           {
671            "listeners" : {
672             "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}"
673            },
674            "xtype" : "Store",
675            "boolean remoteSort" : true,
676            "$ xns" : "Roo.data",
677            "$ sortInfo" : "{ field: 'name', direction: 'ASC'}",
678            "* prop" : "store",
679            "items" : [
680             {
681              "xtype" : "JsonReader",
682              "String root" : "data",
683              "$ xns" : "Roo.data",
684              "String id" : "id",
685              "* prop" : "reader",
686              "String totalProperty" : "total"
687             },
688             {
689              "$ url" : "baseURL + '/Roo/core_group'",
690              "xtype" : "HttpProxy",
691              "$ xns" : "Roo.data",
692              "String method" : "GET",
693              "* prop" : "proxy"
694             }
695            ]
696           },
697           {
698            "String header" : "Name",
699            "String cursor" : "pointer",
700            "Number md" : 12,
701            "String dataIndex" : "name",
702            "xtype" : "ColumnModel",
703            "Number xs" : 12,
704            "$ xns" : "Roo.grid",
705            "$ 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}",
706            "Boolean sortable" : false,
707            "* prop" : "cm[]",
708            "Number sm" : 12
709           }
710          ]
711         }
712        ]
713       }
714      ]
715     }
716    ]
717   }
718  ]
719 }