Pman.Dialog.BAdminStaff.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminStaff.bjs
1 {
2  "name" : "Pman.Dialog.BAdminStaff",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.BAdmin/Pman.Dialog.BAdminStaff.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
10   "566a352f95c879ff26e50bad767a28dc" : "Group Membership",
11   "4910043d0b2c8c864a0e8672716fee94" : "Is a Member",
12   "a60cdd3642fbe81545a3b93fe2b19dd6" : "Two-Factor Authentication",
13   "28974c2c793e780427dfb571b26443e6" : "Group Name",
14   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
15   "a6b81fd617c4f1b94f83049793cac3cd" : "Show QR Code",
16   "a0f852ef8bfccd86a0e7217d7959e3e8" : "Add / Edit User",
17   "3ec365dd533ddb7ef3d1c111186ce872" : "Details",
18   "0bfe42db3eb05bf39f03812166391939" : "Use Secure Passwords",
19   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
20   "73b00356c62eb391f571b6468be7c372" : "Generate QR Code",
21   "6f958ddaf50fd5ade7858ef1d1a63e51" : "Type again to confirm",
22   "49ee3087348e8d44e1feda1917443987" : "Name",
23   "bbbabdbe1b262f75d99d62880b953be1" : "Role",
24   "1960f813085537c64f981132e34181ca" : "Delete QR Code",
25   "c9cc8cce247e49bae79f15173ce97354" : "Save",
26   "828e70f83623b262e14187c039df99c0" : "Enable Two-Factor Authentication",
27   "acf45fd8829f809b29c601a3a193804f" : "Set / Change Password",
28   "01028205a11cf95a503c4c1d005989da" : "Generate One"
29  },
30  "items" : [
31   {
32    "listeners" : {
33     "beforeshow" : "function (_self)\n{\n    //_console.log(_this.detail_tab);\n}",
34     "show" : "function (_self)\n{\n    //_this.dialog.items[0].getRegion('center').showPanel(0); \n\n    //setting first adminstrator in open system\n    \n    if(typeof(_this.data.role) != 'undefined' && _this.data.role == 'Administrators') {\n        \n        Roo.select('.add-user-dialog .modal-title').first().dom.innerHTML = \"Create Adminstrator\";\n        \n        _this.form.findField('role').inputEl().dom.disabled = true;\n    }\n    _this.layout.showPanel('DetailPanel');\n}",
35     "render" : "function (_self)\n{\n    this.bodyEl.setHeight(600);\n}"
36    },
37    "String cls" : "add-user-dialog",
38    "Boolean fitwindow" : false,
39    "xtype" : "Modal",
40    "int maxWidth" : 650,
41    "$ xns" : "Roo.bootstrap",
42    "String title" : "Add / Edit User",
43    "items" : [
44     {
45      "listeners" : {
46       "render" : "function (_self)\n{\n    _this.layout = _self;\n}"
47      },
48      "xtype" : "Border",
49      "$ xns" : "Roo.bootstrap.layout",
50      "items" : [
51       {
52        "alwaysShowTabs" : true,
53        "String tabPosition" : "top",
54        "xtype" : "Region",
55        "$ xns" : "Roo.bootstrap.layout",
56        "* prop" : "center"
57       },
58       {
59        "listeners" : {
60         "activate" : "function (_self)\n{\n    /*var url = 'about:blank';\n    \n    if(_this.data.id * 1 > 0){\n        url = baseURL + '/Coba/Report/ApplicationSummary/' + _this.data.id;\n    }\n     \n    _this.app_summary_frame.el.dom.src = url;*/\n    \n}",
61         "render" : "function (_self)\n{\n    _this.detail_tab = _self;\n}"
62        },
63        "id" : "DetailPanel",
64        "Boolean fitContainer" : true,
65        "xtype" : "Content",
66        "Boolean fitToFrame" : true,
67        "$ xns" : "Roo.bootstrap.panel",
68        "String region" : "center",
69        "String title" : "Details",
70        "Boolean autoScroll" : true,
71        "Boolean background" : false,
72        "items" : [
73         {
74          "String cls" : "col-md-12",
75          "xtype" : "Container",
76          "$ xns" : "Roo.bootstrap",
77          "items" : [
78           {
79            "listeners" : {
80             "actioncomplete" : "function (_self, action)\n{\n    if(action.type == 'setdata'){\n        \n        _this.form.findField('passwd1').el.select('input',true).first().dom.type=\"password\";\n        _this.form.findField('passwd2').show();\n        _this.passwordbox.collapse();\n        \n        _this.qrCodeBox.collapse();\n        _this.qrCodeBox.el.hide();\n        _this.form.findField('_enable_oath_key').setValue(1);\n        _this.form.findField('_enable_oath_key').el.show();\n        \n        _this.generate_qrcode_btn.el.hide();\n        _this.delete_qrcode_btn.el.hide();\n        _this.show_qrcode_btn.el.hide();\n        \n        if(_this.data.id * 1 > 0) {\n            this.doAction('load',{ method: 'GET', params: { '_id' : _this.data.id }});\n        }\n        \n        this.clearInvalid();\n        \n        return;\n    }\n   \n    if (action.type == 'load') {\n    \n        _this.data = action.result.data;\n        \n        _this.qrCodeBox.el.show();\n        _this.form.findField('_enable_oath_key').setValue(0);\n        _this.form.findField('_enable_oath_key').el.hide();\n        \n        _this.generate_qrcode_btn.el.show();\n        _this.delete_qrcode_btn.el.hide();\n        _this.show_qrcode_btn.el.hide();\n            \n        _this.qrCodeBox.collapse();\n        \n        if(_this.data.length_oath_key * 1 > 0){\n            _this.delete_qrcode_btn.el.show();\n            _this.show_qrcode_btn.el.show();\n            _this.qrCodeBox.expand();\n        }\n        \n        return;\n    }\n    \n    if (action.type == 'submit') { // only submitted here if we are \n    \n        _this.dialog.hide();\n       \n        if (_this.callback) {\n            _this.callback.call(this, action.result.data);\n        }\n        \n        return;\n        \n    }\n}",
81             "beforeaction" : "function (_self, action)\n{\n\n}",
82             "render" : "function (_self)\n{\n    _this.form = _self;\n    \n    //_this.findField('group_membership').setValue\n    \n    console.log(_this.form.data);\n}"
83            },
84            "$ url" : "baseURL + '/Roo/core_person' ",
85            "style" : "margin-top: 20px;",
86            "xtype" : "Form",
87            "String labelAlign" : "top",
88            "$ xns" : "Roo.bootstrap",
89            "string errorMask" : true,
90            "items" : [
91             {
92              "xtype" : "Row",
93              "$ xns" : "Roo.bootstrap",
94              "items" : [
95               {
96                "Number md" : 12,
97                "xtype" : "Column",
98                "$ xns" : "Roo.bootstrap",
99                "items" : [
100                 {
101                  "Boolean allowBlank" : false,
102                  "String name" : "name",
103                  "xtype" : "Input",
104                  "string placeholder" : "Name",
105                  "String labelAlign" : "left",
106                  "string fieldLabel" : "Name",
107                  "$ xns" : "Roo.bootstrap"
108                 }
109                ]
110               }
111              ]
112             },
113             {
114              "xtype" : "Row",
115              "$ xns" : "Roo.bootstrap",
116              "items" : [
117               {
118                "Number md" : 12,
119                "xtype" : "Column",
120                "$ xns" : "Roo.bootstrap",
121                "items" : [
122                 {
123                  "String name" : "role",
124                  "xtype" : "Input",
125                  "string placeholder" : "Role",
126                  "string fieldLabel" : "Role",
127                  "String labelAlign" : "left",
128                  "$ xns" : "Roo.bootstrap"
129                 }
130                ]
131               }
132              ]
133             },
134             {
135              "xtype" : "Row",
136              "$ xns" : "Roo.bootstrap",
137              "items" : [
138               {
139                "Number md" : 12,
140                "xtype" : "Column",
141                "$ xns" : "Roo.bootstrap",
142                "items" : [
143                 {
144                  "Boolean allowBlank" : false,
145                  "String name" : "email",
146                  "xtype" : "Input",
147                  "vtype" : "email",
148                  "string placeholder" : "Email",
149                  "String labelAlign" : "left",
150                  "string fieldLabel" : "Email",
151                  "$ xns" : "Roo.bootstrap"
152                 }
153                ]
154               }
155              ]
156             },
157             {
158              "xtype" : "Row",
159              "$ xns" : "Roo.bootstrap",
160              "items" : [
161               {
162                "Number md" : 12,
163                "xtype" : "Column",
164                "$ xns" : "Roo.bootstrap",
165                "items" : [
166                 {
167                  "String name" : "phone",
168                  "xtype" : "Input",
169                  "string fieldLabel" : "Phone",
170                  "String labelAlign" : "left",
171                  "$ xns" : "Roo.bootstrap"
172                 }
173                ]
174               }
175              ]
176             },
177             {
178              "xtype" : "Row",
179              "$ xns" : "Roo.bootstrap",
180              "items" : [
181               {
182                "Number md" : 12,
183                "xtype" : "Column",
184                "$ xns" : "Roo.bootstrap",
185                "items" : [
186                 {
187                  "listeners" : {
188                   "render" : "function (_self)\n{\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}"
189                  },
190                  "String name" : "_enable_oath_key",
191                  "Boolean checked" : true,
192                  "xtype" : "CheckBox",
193                  "String boxLabel" : "Enable Two-Factor Authentication",
194                  "$ xns" : "Roo.bootstrap"
195                 }
196                ]
197               }
198              ]
199             },
200             {
201              "xtype" : "Row",
202              "$ xns" : "Roo.bootstrap",
203              "items" : [
204               {
205                "Number md" : 12,
206                "xtype" : "Column",
207                "$ xns" : "Roo.bootstrap",
208                "items" : [
209                 {
210                  "listeners" : {
211                   "render" : "function (_self)\n{\n    _this.passwordbox = this;\n}"
212                  },
213                  "String header" : "Set / Change Password",
214                  "Boolean expanded" : false,
215                  "xtype" : "Container",
216                  "String panel" : "primary",
217                  "$ xns" : "Roo.bootstrap",
218                  "Boolean expandable" : true,
219                  "items" : [
220                   {
221                    "xtype" : "Row",
222                    "$ xns" : "Roo.bootstrap",
223                    "items" : [
224                     {
225                      "xtype" : "Column",
226                      "Number xs" : 8,
227                      "$ xns" : "Roo.bootstrap",
228                      "items" : [
229                       {
230                        "String name" : "passwd1",
231                        "xtype" : "Input",
232                        "String inputType" : "password",
233                        "$ xns" : "Roo.bootstrap"
234                       }
235                      ]
236                     },
237                     {
238                      "xtype" : "Column",
239                      "Number xs" : 4,
240                      "$ xns" : "Roo.bootstrap",
241                      "items" : [
242                       {
243                        "listeners" : {
244                         "click" : "function (_self, e)\n{\n    var pw = Math.random().toString(36).slice(-12);\n    _this.form.findField('passwd1').el.select('input',true).first().dom.type=\"input\";\n    _this.form.findField('passwd1').setValue(pw);\n    _this.form.findField('passwd2').hide();\n    \n    \n}"
245                        },
246                        "xtype" : "Button",
247                        "$ xns" : "Roo.bootstrap",
248                        "String html" : "Generate One",
249                        "String style" : "width:100%"
250                       }
251                      ]
252                     }
253                    ]
254                   },
255                   {
256                    "String name" : "passwd2",
257                    "xtype" : "Input",
258                    "string placeholder" : "Type again to confirm",
259                    "String inputType" : "password",
260                    "$ xns" : "Roo.bootstrap"
261                   },
262                   {
263                    "String name" : "secure_passwords",
264                    "xtype" : "CheckBox",
265                    "String boxLabel" : "Use Secure Passwords",
266                    "$ xns" : "Roo.bootstrap"
267                   }
268                  ]
269                 }
270                ]
271               }
272              ]
273             },
274             {
275              "xtype" : "Row",
276              "$ xns" : "Roo.bootstrap",
277              "items" : [
278               {
279                "Number md" : 12,
280                "xtype" : "Column",
281                "$ xns" : "Roo.bootstrap",
282                "items" : [
283                 {
284                  "listeners" : {
285                   "render" : "function (_self)\n{\n    _this.qrCodeBox = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}"
286                  },
287                  "String header" : "Two-Factor Authentication",
288                  "Boolean expanded" : false,
289                  "xtype" : "Container",
290                  "String panel" : "primary",
291                  "$ xns" : "Roo.bootstrap",
292                  "Boolean expandable" : true,
293                  "items" : [
294                   {
295                    "xtype" : "Row",
296                    "$ xns" : "Roo.bootstrap",
297                    "items" : [
298                     {
299                      "xtype" : "Column",
300                      "Number xs" : 4,
301                      "$ xns" : "Roo.bootstrap",
302                      "items" : [
303                       {
304                        "listeners" : {
305                         "render" : "function (_self)\n{\n    _this.generate_qrcode_btn = this;\n\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
306                         "click" : "function (_self, e)\n{\n    if(_this.data.id * 1 < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please save the user first');\n        return;\n    }\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/Core_person.php',\n        method : 'POST',\n        mask : 'Loading...',\n        params : {\n            id : _this.data.id,\n            _generate_oath_key : 1\n        }, \n        success : function(res) {\n            _this.delete_qrcode_btn.el.show();\n            _this.show_qrcode_btn.el.show();\n            \n            Pman.Dialog.BAdminStaffTwoFactorQRCode.show({\n                id : _this.data.id\n            });\n            \n            return;\n        }\n    });\n}"
307                        },
308                        "xtype" : "Button",
309                        "$ xns" : "Roo.bootstrap",
310                        "String html" : "Generate QR Code",
311                        "String style" : "width:100%"
312                       }
313                      ]
314                     },
315                     {
316                      "xtype" : "Column",
317                      "Number xs" : 4,
318                      "$ xns" : "Roo.bootstrap",
319                      "items" : [
320                       {
321                        "listeners" : {
322                         "render" : "function (_self)\n{\n    _this.delete_qrcode_btn = this;\n\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
323                         "click" : "function (_self, e)\n{\n    if(_this.data.id * 1 < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please save the user first');\n        return;\n    }\n    \n    new Pman.Request({\n        url: baseURL + '/Roo/Core_person.php',\n        method : 'POST',\n        mask : 'Loading...',\n        params : {\n            id : _this.data.id,\n            oath_key : ''\n        }, \n        success : function(res) {\n            _this.delete_qrcode_btn.el.hide();\n            _this.show_qrcode_btn.el.hide();\n            \n            return;\n        }\n    });\n}"
324                        },
325                        "xtype" : "Button",
326                        "$ xns" : "Roo.bootstrap",
327                        "String html" : "Delete QR Code",
328                        "String style" : "width:100%"
329                       }
330                      ]
331                     },
332                     {
333                      "xtype" : "Column",
334                      "Number xs" : 4,
335                      "$ xns" : "Roo.bootstrap",
336                      "items" : [
337                       {
338                        "listeners" : {
339                         "render" : "function (_self)\n{\n    _this.show_qrcode_btn = this;\n\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
340                         "click" : "function (_self, e)\n{\n    if(_this.data.id * 1 < 1){\n        Roo.bootstrap.MessageBox.alert('Error', 'Please save the user first');\n        return;\n    }\n    \n    Pman.Dialog.BAdminStaffTwoFactorQRCode.show({\n        id : _this.data.id\n    });\n}"
341                        },
342                        "xtype" : "Button",
343                        "$ xns" : "Roo.bootstrap",
344                        "String html" : "Show QR Code",
345                        "String style" : "width:100%"
346                       }
347                      ]
348                     }
349                    ]
350                   }
351                  ]
352                 }
353                ]
354               }
355              ]
356             },
357             {
358              "listeners" : {
359               "render" : "function (_self)\n{\n    _this.userID = _self;\n}"
360              },
361              "String name" : "id",
362              "xtype" : "Input",
363              "String labelAlign" : "left",
364              "String inputType" : "hidden",
365              "$ xns" : "Roo.bootstrap"
366             },
367             {
368              "String name" : "company_id",
369              "xtype" : "Input",
370              "String inputType" : "hidden",
371              "$ xns" : "Roo.bootstrap"
372             },
373             {
374              "String name" : "membership_list",
375              "xtype" : "Input",
376              "String labelAlign" : "left",
377              "String inputType" : "hidden",
378              "$ xns" : "Roo.bootstrap"
379             }
380            ]
381           }
382          ]
383         }
384        ]
385       },
386       {
387        "listeners" : {
388         "activate" : "function (_self)\n{\n    if(_this.option_grid){\n        _this.option_grid.store.load({});\n    }\n    \n}",
389         "render" : "function (_self)\n{\n    _this.option_panel = this;\n    \n    \n}"
390        },
391        "fitToFrame" : true,
392        "xtype" : "Grid",
393        "String region" : "center",
394        "$ xns" : "Roo.bootstrap.panel",
395        "fitContainer" : true,
396        "String title" : "Group Membership",
397        "Boolean background" : true,
398        "items" : [
399         {
400          "listeners" : {
401           "render" : "function (_self)\n{\n    _this.option_grid = this;\n    \n    this.store.load({})\n}",
402           "rowclick" : "function (_self, el, rowIndex, e)\n{\n    //var di = this.colModel.getDataIndex(columnIndex);\n    \n    // check if the name is the result name from dataobject core_group_member\n    /*if (di != 'group_membership_user_id') {\n        return;\n    }*/\n    \n    \n    \n    var rec = this.store.getAt(rowIndex);\n\n    rec.set('group_membership_user_id', rec.data.group_membership_user_id * 1 == 0 ? -1 : 0);\n\n    rec.commit();\n    \n    var membership_active_arr = [];\n    // loop throught the new list , rebuild the list of current options\n    \n    // record is the first parameter\n    \n    _this.option_grid.store.each(function(record){\n        var gmuid = record.data.group_membership_user_id;\n        var gid = record.data.id;\n        if(gmuid * 1 != 0){\n            membership_active_arr.push(gid);\n        }\n    });\n    \n    var membership_active_list = \"\";\n    membership_active_list = membership_active_arr.join();\n    \n    _this.form.findField(\"membership_list\").setValue(membership_active_list);\n}"
403          },
404          "Boolean footerShow" : false,
405          "String cls" : "table-fixed",
406          "String layout" : "fixed",
407          "xtype" : "Table",
408          "$ xns" : "Roo.bootstrap",
409          "cellSelection" : false,
410          "Boolean loadMask" : true,
411          "* prop" : "grid",
412          "boolean condensed" : true,
413          "rowSelection" : true,
414          "items" : [
415           {
416            "listeners" : {
417             "selectionchange" : "function (_self)\n{\n    /*_this.type_edit_btn.hide();\n    \n    if(this.getSelected()){\n        _this.type_edit_btn.show();\n    }*/\n    \n    _this.option_grid.store.load({});\n    \n    \n}"
418            },
419            "Boolean singleSelect" : true,
420            "xtype" : "RowSelectionModel",
421            "$ xns" : "Roo.bootstrap.Table",
422            "* prop" : "sm"
423           },
424           {
425            "listeners" : {
426             "beforeload" : "function (_self, options)\n{ \n    options.params = options.params || {};\n    \n    options.params._with_membership_user = _this.data.id;\n\n    /*if(typeof(_this.data.id) == 'undefined' || _this.data.id * 1 < 1){\n        this.removeAll();\n        return false;\n    }\n    \n    options.params.is_active = 1;\n    options.params.dec_type = 'checklist';\n    \n    options.params._ext_data_id = _this.data.id;\n    \n    options.params._with_others = 1;\n    \n    options.params._show_deleted = _this.documentStatusBtn.pressed ? 1 : 0;*/\n    \n}"
427            },
428            "$ Object sortInfo" : "{ direction : 'ASC', field: 'id' }",
429            "xtype" : "Store",
430            "boolean remoteSort" : true,
431            "$ xns" : "Roo.data",
432            "* prop" : "store",
433            "items" : [
434             {
435              "$ url" : "baseURL + '/Roo/core_group'",
436              "xtype" : "HttpProxy",
437              "$ xns" : "Roo.data",
438              "String method" : "GET",
439              "* prop" : "proxy"
440             },
441             {
442              "xtype" : "JsonReader",
443              "String root" : "data",
444              "$ xns" : "Roo.data",
445              "String id" : "id",
446              "* prop" : "reader"
447             }
448            ]
449           },
450           {
451            "String header" : "Is a Member",
452            "String cursor" : "pointer",
453            "String dataIndex" : "group_membership_user_id",
454            "xtype" : "ColumnModel",
455            "$ xns" : "Roo.grid",
456            "$ renderer" : "function(v,x,r) {\n    \n    var state = v != 0 ?  '-check' : '';\n    \n    return '<i class=\\\"far fa'+ state + '-square-o fa-2x\\\" aria-hidden=\\\"true\\\"></i>';\n}",
457            "Boolean sortable" : false,
458            "* prop" : "cm[]"
459           },
460           {
461            "String header" : "Group Name",
462            "cursor" : "pointer",
463            "String dataIndex" : "name",
464            "xtype" : "ColumnModel",
465            "$ xns" : "Roo.grid",
466            "Boolean sortable" : true,
467            "* prop" : "cm[]"
468           }
469          ]
470         }
471        ]
472       }
473      ]
474     },
475     {
476      "listeners" : {
477       "click" : "function (_self, e)\n{\n    _this.dialog.hide(); \n}"
478      },
479      "xtype" : "Button",
480      "$ xns" : "Roo.bootstrap",
481      "String html" : "Cancel",
482      "* prop" : "buttons[]"
483     },
484     {
485      "listeners" : {
486       "click" : "function (_self, e)\n{\n    if(!_this.form.isValid()){\n        //Roo.bootstrap.MessageBox.alert('Error', 'Please Correct all the errors in red');\n        return;\n    }\n    \n    var myID = _this.form.findField('id').getValue() * 1;\n    var myName = _this.form.findField('name').getValue();\n\n    if (_this.form.findField('company_id') && !_this.form.findField('company_id').getValue()) {\n        Roo.bootstrap.MessageBox.alert(\"Error\", \"Select a Company\");\n        return;\n    }\n        \n       // validate password match (only needed if we are not using generated one..\n    if (_this.form.findField('passwd1') \n            && _this.form.findField('passwd1').getValue().length > 0 \n            && _this.form.findField('passwd1').inputEl().dom.type == \"password\") {\n            \n        var p1 = _this.form.findField('passwd1').getValue();\n        var p2 = _this.form.findField('passwd2').getValue();\n            \n            \n        if (Pman.Login.authUser.id < 0 && !p1.length) {\n            Roo.bootstrap.MessageBox.alert(\"Error\", \"You must create a password for the admin account\");\n            return;\n        }\n            \n            \n        if (p1.length || p2.length) {\n            if (p1 != p2) {\n                Roo.bootstrap.MessageBox.alert(\"Error\", \"Passwords do not match\");\n                return;\n            }\n        }\n            \n        \n    }\n    \n    // get the list of record with tick\n    \n    _this.form.doAction(\"submit\");\n    \n    return;\n\n}"
487      },
488      "String weight" : "primary",
489      "xtype" : "Button",
490      "$ xns" : "Roo.bootstrap",
491      "String html" : "Save",
492      "* prop" : "buttons[]"
493     }
494    ]
495   }
496  ]
497 }