Pman.Dialog.BAdminPasswordReset.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminPasswordReset.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.BAdminPasswordReset= function() {}
8 Roo.apply(Pman.Dialog.BAdminPasswordReset.prototype, {
9
10  _strings : {
11   'acd43bedab51b6704bf10d9ac136a032' :"Reset management password",
12   '10ac3d04253ef7e1ddc73e6091c0cd55' :"Next",
13   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
14   'bbddd6ba0948d79e55486e615a265b56' :"Enter your new password",
15   'c4ca4238a0b923820dcc509a6f75849b' :"1",
16   '6d70a993714d2699e1d30e03d2753850' :"Please enter again to confirm"
17  },
18  _named_strings : {
19   'ResetPassword_value' : 'c4ca4238a0b923820dcc509a6f75849b' /* 1 */ ,
20   'ok_html' : '10ac3d04253ef7e1ddc73e6091c0cd55' /* Next */ ,
21   'cancel_html' : 'ea4788705e6873b424c65e91c2846b19' /* Cancel */ ,
22   'password2_fieldLabel' : '6d70a993714d2699e1d30e03d2753850' /* Please enter again to confirm */ ,
23   'password1_fieldLabel' : 'bbddd6ba0948d79e55486e615a265b56' /* Enter your new password */ 
24  },
25
26  dialog : false,
27  callback:  false,
28
29  show : function(data, cb)
30  {
31   if (!this.dialog) {
32    this.create();
33   }
34
35   this.callback = cb;
36   this.data = data;
37   this.dialog.show(this.data._el);
38   if (this.form) {
39    this.form.reset();
40    this.form.setValues(data);
41    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
42   }
43
44  },
45
46  create : function()
47  {
48   var _this = this;
49   this.dialog = Roo.factory({
50     xtype : 'Modal',
51     allow_close : false,
52     animate : false,
53     buttonPosition : 'center',
54     cls : 'enable-overflow roo-bootstrap-dialog',
55     title : _this._strings['acd43bedab51b6704bf10d9ac136a032'] /* Reset management password */,
56     listeners : {
57      show : function (_self)
58       {
59           _this.dialog.el.select('.modal-content', true).first().unmask();
60           var p1 =     _this.form.findField('password1');
61           p1.focus.defer(100, p1);
62       }
63     },
64     xns : Roo.bootstrap,
65     '|xns' : 'Roo.bootstrap',
66     buttons : [
67      {
68       xtype : 'Button',
69       html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
70       name : 'cancel',
71       weight : 'default',
72       listeners : {
73        click : function (_self, e)
74         {
75             _this.callback.call(_this, false);
76         }
77       },
78       xns : Roo.bootstrap,
79       '|xns' : 'Roo.bootstrap'
80      },
81      {
82       xtype : 'Button',
83       html : _this._strings['10ac3d04253ef7e1ddc73e6091c0cd55'] /* Next */,
84       name : 'ok',
85       weight : 'primary',
86       listeners : {
87        click : function (_self, e)
88         {
89             _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
90             _this.form.doAction('submit');
91         }
92       },
93       xns : Roo.bootstrap,
94       '|xns' : 'Roo.bootstrap'
95      }
96     ],
97     items  : [
98      {
99       xtype : 'Row',
100       xns : Roo.bootstrap,
101       '|xns' : 'Roo.bootstrap',
102       items  : [
103        {
104         xtype : 'Container',
105         cls : 'col-md-12',
106         xns : Roo.bootstrap,
107         '|xns' : 'Roo.bootstrap',
108         items  : [
109          {
110           xtype : 'Form',
111           labelAlign : 'top',
112           loadMask : false,
113           method : 'POST',
114           style : 'padding: 10px;',
115           url : baseURL + '/Login',
116           verifyCheckSum : function() 
117           { 
118               _this.dialog.hide();
119               
120               new Pman.Request({
121                   url: baseURL + '/Login',
122                   method : 'POST',
123                   mask : 'Verifying...',
124                   params : {
125                       id : _this.form.findField('id').getValue(),
126                       ts : _this.form.findField('ts').getValue(),
127                       key : _this.form.findField('key').getValue(),
128                       _verifyCheckSum : 1
129                   },
130                   success : function(res) {
131                       _this.dialog.show();
132                   },
133                   failure : function(res)
134                   {
135                       Roo.log(res);
136                       Roo.MessageBox.alert("Sorry", res, function() {
137                           _this.callback(false,false);
138                       });
139                       
140                   }
141               });
142           },
143           listeners : {
144            actioncomplete : function (_self, action) {
145             
146                 if (action.type == 'setdata') {
147                     
148                     var pathname = window.location.pathname.split('PasswordReset/');
149                     
150                     if(typeof(pathname[1]) == 'undefined'){
151                         return;
152                     }
153                     
154                     var data = pathname[1].split('/');
155                     
156                     if(data.length != 3){
157                         _this.dialog.hide();
158                         Roo.bootstrap.MessageBox.alert('Sorry', 'Account reset link is not correct - please try again or paste the link correctly');
159                         return;
160                     }
161                     
162                     _this.form.findField('id').setValue(data[0]);
163                     _this.form.findField('ts').setValue(data[1]);
164                     _this.form.findField('key').setValue(data[2]);
165                 
166                     _this.form.clearInvalid();
167                 
168                     _this.form.verifyCheckSum();
169                     
170                     return;
171                 }
172                 if (action.type == 'load') {
173                      
174                     return;
175                 }
176                 if (action.type =='submit') {
177                     
178                     _this.dialog.hide();
179                     
180                     if (_this.callback) {
181                         _this.callback.call(_this, action.result);
182                     }
183                     
184                     _this.form.reset();
185                     
186                     return;
187                     
188                 }
189             },
190            actionfailed : function (_self, action) {
191             
192                 Roo.log('action fail?');
193                 Roo.log(action);
194                 
195                 _this.dialog.el.select('.modal-content', true).first().unmask();
196                 
197                 var err = 'Fill in all the required fields';
198                 
199                 if (typeof(action) != 'undefined' && action.failureType == 'server') {
200                     err = action.result.errorMsg;
201                 }
202                 
203                 Roo.bootstrap.MessageBox.alert('Error', err);
204             },
205            render : function (_self) {
206                 _this.form = _self;
207             }
208           },
209           xns : Roo.bootstrap,
210           '|xns' : 'Roo.bootstrap',
211           items  : [
212            {
213             xtype : 'Row',
214             xns : Roo.bootstrap,
215             '|xns' : 'Roo.bootstrap',
216             items  : [
217              {
218               xtype : 'Column',
219               xs : 12,
220               xns : Roo.bootstrap,
221               '|xns' : 'Roo.bootstrap',
222               items  : [
223                {
224                 xtype : 'Input',
225                 allowBlank : false,
226                 fieldLabel : _this._strings['bbddd6ba0948d79e55486e615a265b56'] /* Enter your new password */,
227                 inputType : 'password',
228                 name : 'password1',
229                 listeners : {
230                  specialkey : function (_self, e)
231                   {
232                       if(e.getKey() == 13){
233                           _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
234                           _this.form.doAction('submit');
235                       }
236                   }
237                 },
238                 xns : Roo.bootstrap,
239                 '|xns' : 'Roo.bootstrap'
240                },
241                {
242                 xtype : 'Input',
243                 allowBlank : false,
244                 fieldLabel : _this._strings['6d70a993714d2699e1d30e03d2753850'] /* Please enter again to confirm */,
245                 inputType : 'password',
246                 name : 'password2',
247                 listeners : {
248                  specialkey : function (_self, e)
249                   {
250                       if(e.getKey() == 13){
251                           _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
252                           _this.form.doAction('submit');
253                       }
254                   }
255                 },
256                 xns : Roo.bootstrap,
257                 '|xns' : 'Roo.bootstrap'
258                },
259                {
260                 xtype : 'Input',
261                 inputType : 'hidden',
262                 name : 'id',
263                 xns : Roo.bootstrap,
264                 '|xns' : 'Roo.bootstrap'
265                },
266                {
267                 xtype : 'Input',
268                 inputType : 'hidden',
269                 name : 'ts',
270                 xns : Roo.bootstrap,
271                 '|xns' : 'Roo.bootstrap'
272                },
273                {
274                 xtype : 'Input',
275                 inputType : 'hidden',
276                 name : 'key',
277                 xns : Roo.bootstrap,
278                 '|xns' : 'Roo.bootstrap'
279                },
280                {
281                 xtype : 'Input',
282                 inputType : 'hidden',
283                 name : 'ResetPassword',
284                 value : 1,
285                 xns : Roo.bootstrap,
286                 '|xns' : 'Roo.bootstrap'
287                }
288               ]
289              }
290             ]
291            }
292           ]
293          }
294         ]
295        }
296       ]
297      }
298     ]
299    }  );
300  }
301 });
302 Roo.apply(Pman.Dialog.BAdminPasswordReset, Pman.Dialog.BAdminPasswordReset.prototype);