4f3a1a13daea6e53c66721a2945ac477e1395399
[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.MessageBox.alert("Sorry", res, function() {
136                           _this.callback(false,false);
137                       });
138                       
139                   }
140               });
141           },
142           listeners : {
143            actioncomplete : function (_self, action) {
144             
145                 if (action.type == 'setdata') {
146                     
147                     var pathname = window.location.pathname.split('PasswordReset/');
148                     
149                     if(typeof(pathname[1]) == 'undefined'){
150                         return;
151                     }
152                     
153                     var data = pathname[1].split('/');
154                     
155                     if(data.length != 3){
156                         _this.dialog.hide();
157                         Roo.bootstrap.MessageBox.alert('Sorry', 'Account reset link is not correct - please try again or paste the link correctly');
158                         return;
159                     }
160                     
161                     _this.form.findField('id').setValue(data[0]);
162                     _this.form.findField('ts').setValue(data[1]);
163                     _this.form.findField('key').setValue(data[2]);
164                 
165                     _this.form.clearInvalid();
166                 
167                     _this.form.verifyCheckSum();
168                     
169                     return;
170                 }
171                 if (action.type == 'load') {
172                      
173                     return;
174                 }
175                 if (action.type =='submit') {
176                     
177                     _this.dialog.hide();
178                     
179                     if (_this.callback) {
180                         _this.callback.call(_this, action.result);
181                     }
182                     
183                     _this.form.reset();
184                     
185                     return;
186                     
187                 }
188             },
189            actionfailed : function (_self, action) {
190             
191                 Roo.log('action fail?');
192                 Roo.log(action);
193                 
194                 _this.dialog.el.select('.modal-content', true).first().unmask();
195                 
196                 var err = 'Fill in all the required fields';
197                 
198                 if (typeof(action) != 'undefined' && action.failureType == 'server') {
199                     err = action.result.errorMsg;
200                 }
201                 
202                 Roo.bootstrap.MessageBox.alert('Error', err);
203             },
204            render : function (_self) {
205                 _this.form = _self;
206             }
207           },
208           xns : Roo.bootstrap,
209           '|xns' : 'Roo.bootstrap',
210           items  : [
211            {
212             xtype : 'Row',
213             xns : Roo.bootstrap,
214             '|xns' : 'Roo.bootstrap',
215             items  : [
216              {
217               xtype : 'Column',
218               xs : 12,
219               xns : Roo.bootstrap,
220               '|xns' : 'Roo.bootstrap',
221               items  : [
222                {
223                 xtype : 'Input',
224                 allowBlank : false,
225                 fieldLabel : _this._strings['bbddd6ba0948d79e55486e615a265b56'] /* Enter your new password */,
226                 inputType : 'password',
227                 name : 'password1',
228                 listeners : {
229                  specialkey : function (_self, e)
230                   {
231                       if(e.getKey() == 13){
232                           _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
233                           _this.form.doAction('submit');
234                       }
235                   }
236                 },
237                 xns : Roo.bootstrap,
238                 '|xns' : 'Roo.bootstrap'
239                },
240                {
241                 xtype : 'Input',
242                 allowBlank : false,
243                 fieldLabel : _this._strings['6d70a993714d2699e1d30e03d2753850'] /* Please enter again to confirm */,
244                 inputType : 'password',
245                 name : 'password2',
246                 listeners : {
247                  specialkey : function (_self, e)
248                   {
249                       if(e.getKey() == 13){
250                           _this.dialog.el.select('.modal-content', true).first().mask('Sending...');
251                           _this.form.doAction('submit');
252                       }
253                   }
254                 },
255                 xns : Roo.bootstrap,
256                 '|xns' : 'Roo.bootstrap'
257                },
258                {
259                 xtype : 'Input',
260                 inputType : 'hidden',
261                 name : 'id',
262                 xns : Roo.bootstrap,
263                 '|xns' : 'Roo.bootstrap'
264                },
265                {
266                 xtype : 'Input',
267                 inputType : 'hidden',
268                 name : 'ts',
269                 xns : Roo.bootstrap,
270                 '|xns' : 'Roo.bootstrap'
271                },
272                {
273                 xtype : 'Input',
274                 inputType : 'hidden',
275                 name : 'key',
276                 xns : Roo.bootstrap,
277                 '|xns' : 'Roo.bootstrap'
278                },
279                {
280                 xtype : 'Input',
281                 inputType : 'hidden',
282                 name : 'ResetPassword',
283                 value : 1,
284                 xns : Roo.bootstrap,
285                 '|xns' : 'Roo.bootstrap'
286                }
287               ]
288              }
289             ]
290            }
291           ]
292          }
293         ]
294        }
295       ]
296      }
297     ]
298    }  );
299  }
300 });
301 Roo.apply(Pman.Dialog.BAdminPasswordReset, Pman.Dialog.BAdminPasswordReset.prototype);