1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Roo.namespace('Pman.Dialog');
7 Pman.Dialog.BAdminStaff= function() {}
8 Roo.apply(Pman.Dialog.BAdminStaff.prototype, {
11 'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
12 '566a352f95c879ff26e50bad767a28dc' :"Group Membership",
13 '4910043d0b2c8c864a0e8672716fee94' :"Is a Member",
14 '28974c2c793e780427dfb571b26443e6' :"Group Name",
15 'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
16 'a0f852ef8bfccd86a0e7217d7959e3e8' :"Add / Edit User",
17 '3ec365dd533ddb7ef3d1c111186ce872' :"Details",
18 '0bfe42db3eb05bf39f03812166391939' :"Use Secure Passwords",
19 'ea4788705e6873b424c65e91c2846b19' :"Cancel",
20 '6f958ddaf50fd5ade7858ef1d1a63e51' :"Type again to confirm",
21 '49ee3087348e8d44e1feda1917443987' :"Name",
22 'bbbabdbe1b262f75d99d62880b953be1' :"Role",
23 'c9cc8cce247e49bae79f15173ce97354' :"Save",
24 '828e70f83623b262e14187c039df99c0' :"Enable Two-Factor Authentication",
25 'acf45fd8829f809b29c601a3a193804f' :"Set / Change Password",
26 '01028205a11cf95a503c4c1d005989da' :"Generate One"
29 'email_placeholder' : 'ce8ae9da5b7cd6c3df2929543a9af92d' /* Email */ ,
30 'secure_passwords_boxLabel' : '0bfe42db3eb05bf39f03812166391939' /* Use Secure Passwords */ ,
31 'name_placeholder' : '49ee3087348e8d44e1feda1917443987' /* Name */ ,
32 'role_fieldLabel' : 'bbbabdbe1b262f75d99d62880b953be1' /* Role */ ,
33 'name_fieldLabel' : '49ee3087348e8d44e1feda1917443987' /* Name */ ,
34 'role_placeholder' : 'bbbabdbe1b262f75d99d62880b953be1' /* Role */ ,
35 'phone_fieldLabel' : 'bcc254b55c4a1babdf1dcb82c207506b' /* Phone */ ,
36 '_enable_oath_key_boxLabel' : '828e70f83623b262e14187c039df99c0' /* Enable Two-Factor Authentication */ ,
37 'email_fieldLabel' : 'ce8ae9da5b7cd6c3df2929543a9af92d' /* Email */ ,
38 'passwd2_placeholder' : '6f958ddaf50fd5ade7858ef1d1a63e51' /* Type again to confirm */
44 show : function(data, cb)
52 this.dialog.show(this.data._el);
55 this.form.setValues(data);
56 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
64 this.dialog = Roo.factory({
66 cls : 'add-user-dialog',
70 title : _this._strings['a0f852ef8bfccd86a0e7217d7959e3e8'] /* Add / Edit User */,
72 render : function (_self)
78 '|xns' : 'Roo.bootstrap',
82 html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
84 click : function (_self, e)
90 '|xns' : 'Roo.bootstrap'
94 html : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
97 click : function (_self, e)
99 if(!_this.form.isValid()){
100 //Roo.bootstrap.MessageBox.alert('Error', 'Please Correct all the errors in red');
104 var myID = _this.form.findField('id').getValue() * 1;
105 var myName = _this.form.findField('name').getValue();
107 if (_this.form.findField('company_id') && !_this.form.findField('company_id').getValue()) {
108 Roo.bootstrap.MessageBox.alert("Error", "Select a Company");
112 // validate password match (only needed if we are not using generated one..
113 if (_this.form.findField('passwd1')
114 && _this.form.findField('passwd1').getValue().length > 0
115 && _this.form.findField('passwd1').inputEl().dom.type == "password") {
117 var p1 = _this.form.findField('passwd1').getValue();
118 var p2 = _this.form.findField('passwd2').getValue();
121 if (Pman.Login.authUser.id < 0 && !p1.length) {
122 Roo.bootstrap.MessageBox.alert("Error", "You must create a password for the admin account");
127 if (p1.length || p2.length) {
129 Roo.bootstrap.MessageBox.alert("Error", "Passwords do not match");
137 // get the list of record with tick
139 _this.form.doAction("submit");
146 '|xns' : 'Roo.bootstrap'
153 render : function (_self)
155 _this.layout = _self;
158 xns : Roo.bootstrap.layout,
159 '|xns' : 'Roo.bootstrap.layout',
162 alwaysShowTabs : true,
164 xns : Roo.bootstrap.layout,
165 '|xns' : 'Roo.bootstrap.layout'
176 title : _this._strings['3ec365dd533ddb7ef3d1c111186ce872'] /* Details */,
178 activate : function (_self)
180 /*var url = 'about:blank';
182 if(_this.data.id * 1 > 0){
183 url = baseURL + '/Coba/Report/ApplicationSummary/' + _this.data.id;
186 _this.app_summary_frame.el.dom.src = url;*/
188 render : function (_self)
190 _this.detail_tab = _self;
193 xns : Roo.bootstrap.panel,
194 '|xns' : 'Roo.bootstrap.panel',
200 '|xns' : 'Roo.bootstrap',
206 style : 'margin-top: 20px;',
207 url : baseURL + '/Roo/core_person',
209 actioncomplete : function (_self, action)
211 if(action.type == 'setdata'){
213 _this.layout.showPanel('DetailPanel');
215 _this.dialog.setTitle("Add / Edit User");
216 _this.form.findField('role').setDisabled(false);
219 * Use for init -- Call from Pman.Login.js
222 typeof(_this.data.role) != 'undefined' &&
223 _this.data.role == 'Administrators'
225 _this.dialog.setTitle("Create Adminstrator");
226 _this.form.findField('role').setDisabled(true);
229 _this.form.findField('passwd1').el.select('input',true).first().dom.type="password";
230 _this.form.findField('passwd2').show();
231 _this.passwordbox.collapse();
233 _this.form.findField('secure_passwords').setValue(1);
235 if(_this.data.id * 1 > 0) {
236 this.doAction('load',{ method: 'GET', params: { '_id' : _this.data.id }});
243 _this.dialog.resize();
248 if (action.type == 'load') {
250 _this.data = action.result.data;
254 _this.form.findField('_enable_oath_key').setChecked(false,false);
256 if(_this.data.length_oath_key != '0') {
257 _this.form.findField('_enable_oath_key').setChecked(true,false);
263 if (action.type == 'submit') { // only submitted here if we are
267 if (_this.callback) {
268 _this.callback.call(this, action.result.data);
274 render : function (_self)
280 '|xns' : 'Roo.bootstrap',
285 '|xns' : 'Roo.bootstrap',
291 '|xns' : 'Roo.bootstrap',
296 fieldLabel : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
299 placeholder : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
301 '|xns' : 'Roo.bootstrap'
310 '|xns' : 'Roo.bootstrap',
316 '|xns' : 'Roo.bootstrap',
320 fieldLabel : _this._strings['bbbabdbe1b262f75d99d62880b953be1'] /* Role */,
323 placeholder : _this._strings['bbbabdbe1b262f75d99d62880b953be1'] /* Role */,
325 '|xns' : 'Roo.bootstrap'
334 '|xns' : 'Roo.bootstrap',
340 '|xns' : 'Roo.bootstrap',
345 fieldLabel : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
348 placeholder : _this._strings['ce8ae9da5b7cd6c3df2929543a9af92d'] /* Email */,
351 '|xns' : 'Roo.bootstrap'
360 '|xns' : 'Roo.bootstrap',
366 '|xns' : 'Roo.bootstrap',
370 fieldLabel : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
374 '|xns' : 'Roo.bootstrap'
383 '|xns' : 'Roo.bootstrap',
389 '|xns' : 'Roo.bootstrap',
393 boxLabel : _this._strings['828e70f83623b262e14187c039df99c0'] /* Enable Two-Factor Authentication */,
394 name : '_enable_oath_key',
396 check : function (_self, checked)
400 this.setBoxLabel('Untick to disable Two Factor authentication');
405 this.setBoxLabel('Enable Two Factor Authentication');
407 click : function (_self, e)
409 if(!Pman.Login.authUser) {
410 Roo.bootstrap.MessageBox.alert('Error', 'Please login again');
418 Pman.Dialog.BAdminStaffTwoFactorQRCode.show({
424 _this.dialog.hide({});
428 _this.form.findField('_enable_oath_key').setChecked(false,false);
436 url : baseURL + '/Roo/Core_person',
442 success : function(res)
446 Roo.bootstrap.MessageBox.alert('Success', 'The two factor authentication has been disabled');
449 Roo.log('invalid usage');
453 failure : function(res)
455 Roo.bootstrap.MessageBox.alert('Error', res);
461 '|xns' : 'Roo.bootstrap'
470 '|xns' : 'Roo.bootstrap',
476 '|xns' : 'Roo.bootstrap',
482 header : _this._strings['acf45fd8829f809b29c601a3a193804f'] /* Set / Change Password */,
485 render : function (_self)
487 _this.passwordbox = this;
491 '|xns' : 'Roo.bootstrap',
496 '|xns' : 'Roo.bootstrap',
502 '|xns' : 'Roo.bootstrap',
506 inputType : 'password',
509 '|xns' : 'Roo.bootstrap'
517 '|xns' : 'Roo.bootstrap',
521 html : _this._strings['01028205a11cf95a503c4c1d005989da'] /* Generate One */,
522 style : 'width:100%',
524 click : function (_self, e)
526 var pw = Math.random().toString(36).replace('0.', '');
527 _this.form.findField('passwd1').el.select('input',true).first().dom.type="input";
528 _this.form.findField('passwd1').setValue(pw);
529 _this.form.findField('passwd2').hide();
533 '|xns' : 'Roo.bootstrap'
541 inputType : 'password',
543 placeholder : _this._strings['6f958ddaf50fd5ade7858ef1d1a63e51'] /* Type again to confirm */,
545 '|xns' : 'Roo.bootstrap'
549 boxLabel : _this._strings['0bfe42db3eb05bf39f03812166391939'] /* Use Secure Passwords */,
550 name : 'secure_passwords',
552 '|xns' : 'Roo.bootstrap'
562 inputType : 'hidden',
566 render : function (_self)
568 _this.userID = _self;
572 '|xns' : 'Roo.bootstrap'
576 inputType : 'hidden',
579 '|xns' : 'Roo.bootstrap'
593 title : _this._strings['566a352f95c879ff26e50bad767a28dc'] /* Group Membership */,
595 activate : function (_self)
597 if(_this.option_grid){
598 _this.option_grid.store.load({});
602 render : function (_self)
604 _this.option_panel = this;
609 xns : Roo.bootstrap.panel,
610 '|xns' : 'Roo.bootstrap.panel',
613 cellSelection : true,
618 rowSelection : false,
620 cellclick : function (_self, el, rowIndex, columnIndex, e)
622 var di = _this.option_grid.colModel.getDataIndex(columnIndex);
625 if (di != 'is_in_group') {
629 var rec = _this.option_grid.store.getAt(rowIndex);
631 if(rec.data.name == 'Administrators' && _this.data.id == Pman.Login.authUser.id){
632 Roo.bootstrap.MessageBox.alert('Error', 'You can not remove yourself from Administrators group');
636 rec.set('is_in_group', rec.data.is_in_group * 1 == 1 ? 0 : 1);
640 render : function (_self)
642 _this.option_grid = this;
648 '|xns' : 'Roo.bootstrap',
652 sortInfo : { direction : 'ASC', field: 'id' },
654 beforeload : function (_self, options)
656 options.params = options.params || {};
658 if(_this.data.id * 1 < 1){
659 _this.option_grid.el.mask('Please save the member first');
664 options.params._is_in_group = _this.data.id;
667 update : function (_self, record, operation)
669 if (operation != 'commit') {
674 user_ids : _this.data.id,
675 _action : (record.data.is_in_group * 1 == 0) ? 'sub' : 'add',
676 group_id : record.data.id
680 url : baseURL + '/Roo/Core_group',
683 success : function() {
684 //_this.option_grid.ds.load({});
694 url : baseURL + '/Roo/core_group',
699 xtype : 'JsonReader',
710 'name': 'display_name',
714 'name': 'is_in_group',
725 xtype : 'RowSelectionModel',
727 xns : Roo.bootstrap.Table,
728 '|xns' : 'Roo.bootstrap.Table'
732 xtype : 'ColumnModel',
735 dataIndex : 'is_in_group',
736 header : _this._strings['4910043d0b2c8c864a0e8672716fee94'] /* Is a Member */,
737 renderer : function(v) {
739 var state = v > 0 ? 'check-' : '';
740 var cls = v > 0 ? 'text-primary' : '';
742 return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
751 xtype : 'ColumnModel',
753 dataIndex : 'display_name',
754 header : _this._strings['28974c2c793e780427dfb571b26443e6'] /* Group Name */,
755 renderer : function(v,x,r)
757 var vv = v.length ? v : r.data.name;
759 return String.format('{0}', vv);
775 Roo.apply(Pman.Dialog.BAdminStaff, Pman.Dialog.BAdminStaff.prototype);