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  "named_strings" : {
31   "email_placeholder" : "ce8ae9da5b7cd6c3df2929543a9af92d",
32   "secure_passwords_boxLabel" : "0bfe42db3eb05bf39f03812166391939",
33   "name_placeholder" : "49ee3087348e8d44e1feda1917443987",
34   "role_fieldLabel" : "bbbabdbe1b262f75d99d62880b953be1",
35   "name_fieldLabel" : "49ee3087348e8d44e1feda1917443987",
36   "role_placeholder" : "bbbabdbe1b262f75d99d62880b953be1",
37   "phone_fieldLabel" : "bcc254b55c4a1babdf1dcb82c207506b",
38   "_enable_oath_key_boxLabel" : "828e70f83623b262e14187c039df99c0",
39   "email_fieldLabel" : "ce8ae9da5b7cd6c3df2929543a9af92d",
40   "passwd2_placeholder" : "6f958ddaf50fd5ade7858ef1d1a63e51"
41  },
42  "items" : [
43   {
44    "listeners" : {
45     "show" : "function (_self)\n{\n    \n}",
46     "render" : "function (_self)\n{\n\n}"
47    },
48    "String cls" : "add-user-dialog",
49    "xtype" : "Modal",
50    "int max_width" : 650,
51    "$ xns" : "Roo.bootstrap",
52    "String title" : "Add / Edit User",
53    "items" : [
54     {
55      "listeners" : {
56       "render" : "function (_self)\n{\n    _this.layout = _self;\n}"
57      },
58      "xtype" : "Border",
59      "$ xns" : "Roo.bootstrap.layout",
60      "items" : [
61       {
62        "alwaysShowTabs" : true,
63        "String tabPosition" : "top",
64        "xtype" : "Region",
65        "$ xns" : "Roo.bootstrap.layout",
66        "* prop" : "center"
67       },
68       {
69        "listeners" : {
70         "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}",
71         "render" : "function (_self)\n{\n    _this.detail_tab = _self;\n}"
72        },
73        "id" : "DetailPanel",
74        "Boolean fitContainer" : true,
75        "xtype" : "Content",
76        "Boolean fitToFrame" : true,
77        "$ xns" : "Roo.bootstrap.panel",
78        "String region" : "center",
79        "String title" : "Details",
80        "Boolean autoScroll" : true,
81        "Boolean background" : false,
82        "items" : [
83         {
84          "String cls" : "col-md-12",
85          "xtype" : "Container",
86          "$ xns" : "Roo.bootstrap",
87          "items" : [
88           {
89            "listeners" : {
90             "actioncomplete" : "function (_self, action)\n{\n    if(action.type == 'setdata'){\n        \n        _this.dialog.setTitle(\"Add / Edit User\");\n        _this.form.findField('role').setDisabled(false);\n            \n        /*\n        * Use for init -- Call from Pman.Login.js\n        */\n        if(typeof(_this.data.role) != 'undefined' && _this.data.role == 'Administrators') {\n            _this.dialog.setTitle(\"Create Adminstrator\");\n            _this.form.findField('role').setDisabled(true);\n        }\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}",
91             "render" : "function (_self)\n{\n    _this.form = _self;\n    \n}"
92            },
93            "$ url" : "baseURL + '/Roo/core_person' ",
94            "xtype" : "Form",
95            "style" : "margin-top: 20px;",
96            "String labelAlign" : "top",
97            "$ xns" : "Roo.bootstrap",
98            "string errorMask" : true,
99            "items" : [
100             {
101              "xtype" : "Row",
102              "$ xns" : "Roo.bootstrap",
103              "items" : [
104               {
105                "Number md" : 12,
106                "xtype" : "Column",
107                "$ xns" : "Roo.bootstrap",
108                "items" : [
109                 {
110                  "Boolean allowBlank" : false,
111                  "String name" : "name",
112                  "xtype" : "Input",
113                  "string placeholder" : "Name",
114                  "String labelAlign" : "left",
115                  "string fieldLabel" : "Name",
116                  "$ xns" : "Roo.bootstrap"
117                 }
118                ]
119               }
120              ]
121             },
122             {
123              "xtype" : "Row",
124              "$ xns" : "Roo.bootstrap",
125              "items" : [
126               {
127                "Number md" : 12,
128                "xtype" : "Column",
129                "$ xns" : "Roo.bootstrap",
130                "items" : [
131                 {
132                  "String name" : "role",
133                  "xtype" : "Input",
134                  "string placeholder" : "Role",
135                  "string fieldLabel" : "Role",
136                  "String labelAlign" : "left",
137                  "$ xns" : "Roo.bootstrap"
138                 }
139                ]
140               }
141              ]
142             },
143             {
144              "xtype" : "Row",
145              "$ xns" : "Roo.bootstrap",
146              "items" : [
147               {
148                "Number md" : 12,
149                "xtype" : "Column",
150                "$ xns" : "Roo.bootstrap",
151                "items" : [
152                 {
153                  "Boolean allowBlank" : false,
154                  "String name" : "email",
155                  "xtype" : "Input",
156                  "vtype" : "email",
157                  "string placeholder" : "Email",
158                  "String labelAlign" : "left",
159                  "string fieldLabel" : "Email",
160                  "$ xns" : "Roo.bootstrap"
161                 }
162                ]
163               }
164              ]
165             },
166             {
167              "xtype" : "Row",
168              "$ xns" : "Roo.bootstrap",
169              "items" : [
170               {
171                "Number md" : 12,
172                "xtype" : "Column",
173                "$ xns" : "Roo.bootstrap",
174                "items" : [
175                 {
176                  "String name" : "phone",
177                  "xtype" : "Input",
178                  "string fieldLabel" : "Phone",
179                  "String labelAlign" : "left",
180                  "$ xns" : "Roo.bootstrap"
181                 }
182                ]
183               }
184              ]
185             },
186             {
187              "xtype" : "Row",
188              "$ xns" : "Roo.bootstrap",
189              "items" : [
190               {
191                "Number md" : 12,
192                "xtype" : "Column",
193                "$ xns" : "Roo.bootstrap",
194                "items" : [
195                 {
196                  "listeners" : {
197                   "render" : "function (_self)\n{\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}"
198                  },
199                  "String name" : "_enable_oath_key",
200                  "Boolean checked" : true,
201                  "xtype" : "CheckBox",
202                  "String boxLabel" : "Enable Two-Factor Authentication",
203                  "$ xns" : "Roo.bootstrap"
204                 }
205                ]
206               }
207              ]
208             },
209             {
210              "xtype" : "Row",
211              "$ xns" : "Roo.bootstrap",
212              "items" : [
213               {
214                "Number md" : 12,
215                "xtype" : "Column",
216                "$ xns" : "Roo.bootstrap",
217                "items" : [
218                 {
219                  "listeners" : {
220                   "render" : "function (_self)\n{\n    _this.passwordbox = this;\n}"
221                  },
222                  "String header" : "Set / Change Password",
223                  "Boolean expanded" : false,
224                  "xtype" : "Container",
225                  "String panel" : "primary",
226                  "$ xns" : "Roo.bootstrap",
227                  "Boolean expandable" : true,
228                  "items" : [
229                   {
230                    "xtype" : "Row",
231                    "$ xns" : "Roo.bootstrap",
232                    "items" : [
233                     {
234                      "xtype" : "Column",
235                      "Number xs" : 8,
236                      "$ xns" : "Roo.bootstrap",
237                      "items" : [
238                       {
239                        "String name" : "passwd1",
240                        "xtype" : "Input",
241                        "String inputType" : "password",
242                        "$ xns" : "Roo.bootstrap"
243                       }
244                      ]
245                     },
246                     {
247                      "xtype" : "Column",
248                      "Number xs" : 4,
249                      "$ xns" : "Roo.bootstrap",
250                      "items" : [
251                       {
252                        "listeners" : {
253                         "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}"
254                        },
255                        "xtype" : "Button",
256                        "$ xns" : "Roo.bootstrap",
257                        "String html" : "Generate One",
258                        "String style" : "width:100%"
259                       }
260                      ]
261                     }
262                    ]
263                   },
264                   {
265                    "String name" : "passwd2",
266                    "xtype" : "Input",
267                    "string placeholder" : "Type again to confirm",
268                    "String inputType" : "password",
269                    "$ xns" : "Roo.bootstrap"
270                   },
271                   {
272                    "String name" : "secure_passwords",
273                    "xtype" : "CheckBox",
274                    "String boxLabel" : "Use Secure Passwords",
275                    "$ xns" : "Roo.bootstrap"
276                   }
277                  ]
278                 }
279                ]
280               }
281              ]
282             },
283             {
284              "xtype" : "Row",
285              "$ xns" : "Roo.bootstrap",
286              "items" : [
287               {
288                "Number md" : 12,
289                "xtype" : "Column",
290                "$ xns" : "Roo.bootstrap",
291                "items" : [
292                 {
293                  "listeners" : {
294                   "render" : "function (_self)\n{\n    _this.qrCodeBox = this;\n    \n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}"
295                  },
296                  "String header" : "Two-Factor Authentication",
297                  "Boolean expanded" : false,
298                  "xtype" : "Container",
299                  "String panel" : "primary",
300                  "$ xns" : "Roo.bootstrap",
301                  "Boolean expandable" : true,
302                  "items" : [
303                   {
304                    "xtype" : "Row",
305                    "$ xns" : "Roo.bootstrap",
306                    "items" : [
307                     {
308                      "xtype" : "Column",
309                      "Number xs" : 4,
310                      "$ xns" : "Roo.bootstrap",
311                      "items" : [
312                       {
313                        "listeners" : {
314                         "render" : "function (_self)\n{\n    _this.generate_qrcode_btn = this;\n\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
315                         "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}"
316                        },
317                        "xtype" : "Button",
318                        "$ xns" : "Roo.bootstrap",
319                        "String html" : "Generate QR Code",
320                        "String style" : "width:100%"
321                       }
322                      ]
323                     },
324                     {
325                      "xtype" : "Column",
326                      "Number xs" : 4,
327                      "$ xns" : "Roo.bootstrap",
328                      "items" : [
329                       {
330                        "listeners" : {
331                         "render" : "function (_self)\n{\n    _this.delete_qrcode_btn = this;\n\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
332                         "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}"
333                        },
334                        "xtype" : "Button",
335                        "$ xns" : "Roo.bootstrap",
336                        "String html" : "Delete QR Code",
337                        "String style" : "width:100%"
338                       }
339                      ]
340                     },
341                     {
342                      "xtype" : "Column",
343                      "Number xs" : 4,
344                      "$ xns" : "Roo.bootstrap",
345                      "items" : [
346                       {
347                        "listeners" : {
348                         "render" : "function (_self)\n{\n    _this.show_qrcode_btn = this;\n\n    this.el.setVisibilityMode(Roo.Element.DISPLAY);\n    \n    this.el.hide();\n}",
349                         "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}"
350                        },
351                        "xtype" : "Button",
352                        "$ xns" : "Roo.bootstrap",
353                        "String html" : "Show QR Code",
354                        "String style" : "width:100%"
355                       }
356                      ]
357                     }
358                    ]
359                   }
360                  ]
361                 }
362                ]
363               }
364              ]
365             },
366             {
367              "listeners" : {
368               "render" : "function (_self)\n{\n    _this.userID = _self;\n}"
369              },
370              "String name" : "id",
371              "xtype" : "Input",
372              "String labelAlign" : "left",
373              "String inputType" : "hidden",
374              "$ xns" : "Roo.bootstrap"
375             },
376             {
377              "String name" : "company_id",
378              "xtype" : "Input",
379              "String inputType" : "hidden",
380              "$ xns" : "Roo.bootstrap"
381             }
382            ]
383           }
384          ]
385         }
386        ]
387       },
388       {
389        "listeners" : {
390         "activate" : "function (_self)\n{\n    if(_this.option_grid){\n        _this.option_grid.store.load({});\n    }\n    \n}",
391         "render" : "function (_self)\n{\n    _this.option_panel = this;\n    \n    \n}"
392        },
393        "fitToFrame" : true,
394        "xtype" : "Grid",
395        "String region" : "center",
396        "$ xns" : "Roo.bootstrap.panel",
397        "fitContainer" : true,
398        "String title" : "Group Membership",
399        "Boolean background" : true,
400        "items" : [
401         {
402          "listeners" : {
403           "render" : "function (_self)\n{\n    _this.option_grid = this;\n    \n    this.store.load({})\n}",
404           "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}"
405          },
406          "Boolean footerShow" : false,
407          "String cls" : "table-fixed",
408          "xtype" : "Table",
409          "$ xns" : "Roo.bootstrap",
410          "cellSelection" : true,
411          "Boolean loadMask" : true,
412          "* prop" : "grid",
413          "boolean condensed" : true,
414          "rowSelection" : true,
415          "items" : [
416           {
417            "listeners" : {
418             "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}"
419            },
420            "Boolean singleSelect" : true,
421            "xtype" : "RowSelectionModel",
422            "$ xns" : "Roo.bootstrap.Table",
423            "* prop" : "sm"
424           },
425           {
426            "listeners" : {
427             "beforeload" : "function (_self, options)\n{ \n    options.params = options.params || {};\n    \n    options.params._with_membership_user = _this.data.id;\n\n}"
428            },
429            "$ Object sortInfo" : "{ direction : 'ASC', field: 'id' }",
430            "xtype" : "Store",
431            "boolean remoteSort" : true,
432            "$ xns" : "Roo.data",
433            "* prop" : "store",
434            "items" : [
435             {
436              "$ url" : "baseURL + '/Roo/core_group'",
437              "xtype" : "HttpProxy",
438              "$ xns" : "Roo.data",
439              "String method" : "GET",
440              "* prop" : "proxy"
441             },
442             {
443              "xtype" : "JsonReader",
444              "String root" : "data",
445              "$ xns" : "Roo.data",
446              "String id" : "id",
447              "* prop" : "reader"
448             }
449            ]
450           },
451           {
452            "String header" : "Is a Member",
453            "String cursor" : "pointer",
454            "String dataIndex" : "group_membership_user_id",
455            "xtype" : "ColumnModel",
456            "Number xs" : 3,
457            "String align" : "center",
458            "$ xns" : "Roo.grid",
459            "$ 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 }",
460            "Boolean sortable" : false,
461            "* prop" : "cm[]"
462           },
463           {
464            "String header" : "Group Name",
465            "cursor" : "pointer",
466            "String dataIndex" : "name",
467            "xtype" : "ColumnModel",
468            "Number xs" : 9,
469            "$ xns" : "Roo.grid",
470            "Boolean sortable" : true,
471            "* prop" : "cm[]"
472           }
473          ]
474         }
475        ]
476       }
477      ]
478     },
479     {
480      "listeners" : {
481       "click" : "function (_self, e)\n{\n    _this.dialog.hide(); \n}"
482      },
483      "xtype" : "Button",
484      "$ xns" : "Roo.bootstrap",
485      "String html" : "Cancel",
486      "* prop" : "buttons[]"
487     },
488     {
489      "listeners" : {
490       "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}"
491      },
492      "String weight" : "primary",
493      "xtype" : "Button",
494      "$ xns" : "Roo.bootstrap",
495      "String html" : "Save",
496      "* prop" : "buttons[]"
497     }
498    ]
499   }
500  ]
501 }