Pman.Dialog.VerifyAccess.bjs
[Pman.Core] / Pman.Dialog.VerifyAccess.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.VerifyAccess= function() {}
8 Roo.apply(Pman.Dialog.VerifyAccess.prototype, {
9
10  _strings : {
11   'd41d8cd98f00b204e9800998ecf8427e' :"",
12   'b945ed1d61d8edbe16a1192ad6d2fd58' :"Please enter a memorable password for logging into your application",
13   '07ae22a49223522664766d12c37a4eeb' :"Activate Your account",
14   'ee7ad62ad69b9ab5f25d273e4e0a1736' :"Your Username",
15   '51eea3dc60ae3a0b1bb8188bc6337dc2' :"enter password",
16   '1849ffc8731b5e74ae6157c91ba73575' :"Please confirm your password",
17   'd71940f24ee38ee09f6e06b908480bcf' :"Resend email",
18   '14cf5e829f5cb6fbf8cb54f7c5ff4ca9' :"Start the application process   "
19  },
20
21  dialog : false,
22  callback:  false,
23
24  show : function(data, cb)
25  {
26   if (!this.dialog) {
27    this.create();
28   }
29
30   this.callback = cb;
31   this.data = data;
32   this.dialog.show(this.data._el);
33   if (this.form) {
34    this.form.reset();
35    this.form.setValues(data);
36    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
37   }
38
39  },
40
41  create : function()
42  {
43   var _this = this;
44   this.dialog = Roo.factory({
45     xtype : 'Modal',
46     allow_close : false,
47     cls : 'enable-overflow',
48     size : 'sm',
49     title : _this._strings['07ae22a49223522664766d12c37a4eeb'] /* Activate Your account */,
50     listeners : {
51      render : function (_self)
52       {
53           _this.modal = _self;
54       },
55      show : function (_self)
56       {
57           var path = window.location.pathname.split('/');
58           
59           var verify_key = path.pop();
60           
61           var id = path.pop();
62           
63           var show_err = function(msg,title,show_resend_btn) {
64               _this.form.hide();
65               _this.btn_ok.hide();
66               _this.error_row.el.show();
67               _this.text_el.el.dom.innerHTML = msg;
68               _this.modal.setTitle(title);
69               if(show_resend_btn){
70                   _this.btn_resend.show();
71               }
72           }
73           
74           new Pman.Request({
75               url: baseURL + '/Register/Confirm',
76               method : 'POST',
77               params : {
78                   id : id,
79                   verify_key : verify_key,
80                   _to_data : 1
81               }, 
82               success : function(res) {
83                   _this.form.setValues(res.data);
84                   return;
85               },
86               failure: function(res) {
87                   
88                   switch(res.errorMsg) {
89                       case 'already_registered':
90                           _this.dialog.hide();
91                           Coba.Dialog.Login.show({});
92                           break;
93       
94                       case 'multi_account':
95                           show_err('This email has been registered for multiple account. Please contact to your distributor to synchronize them',
96                                    'System Error',
97                                     false);
98                           break;
99       
100                       case 'broken_link':
101                           show_err('The link you clicked on was broken, on not complete, please copy and paste the full URL from the email you received',
102                                    'Invalid Link',
103                                    false);
104                           break;
105       
106                       case 'expired':
107                           show_err('This activation link is already expired, please click Resend email to get the updated activated link',
108                                    'Link Expired',
109                                    true);                   
110                           break;
111       
112                       
113                       default:
114                           show_err(res.errorMsg,'Error', false);
115                           break;
116                   }            
117       
118                   
119                   return;
120              }
121           });
122       }
123     },
124     xns : Roo.bootstrap,
125     '|xns' : 'Roo.bootstrap',
126     buttons : [
127      {
128       xtype : 'Button',
129       html : _this._strings['14cf5e829f5cb6fbf8cb54f7c5ff4ca9'] /* Start the application process    */,
130       weight : 'primary',
131       listeners : {
132        click : function (_self, e)
133         {
134             if(!_this.form.isValid()){
135                 return;
136             }
137             
138             var p1 = _this.form.findField('password').getValue();
139             var p2 = _this.form.findField('password1').getValue();
140             
141             if (p1 != p2) {
142                 _this.form.findField('password1').markInvalid('Password do not match');
143                 return;
144             }
145             
146             _this.dialog.el.mask('Sending...');
147             _this.form.doAction('submit');
148             
149         },
150        render : function (_self)
151         {
152             _this.btn_ok = _self;
153         }
154       },
155       xns : Roo.bootstrap,
156       '|xns' : 'Roo.bootstrap'
157      },
158      {
159       xtype : 'Button',
160       html : _this._strings['d71940f24ee38ee09f6e06b908480bcf'] /* Resend email */,
161       weight : 'primary',
162       listeners : {
163        click : function (_self, e)
164         {
165             var path = window.location.pathname.split('/');
166             
167             var verify_key = path.pop();
168             
169             var id = path.pop();
170             
171             new Pman.Request({
172                 url: baseURL + '/Roo/Coba_application_signup',
173                 method : 'POST',
174                 mask : 'Sending...',
175                 params : {
176                     _resend : id
177                 }, 
178                 success : function(res) {
179                     var msg = "We have re-sent you an invitation via email." +
180                                 "<br/><br/>" + 
181                                 "Please check your inbox for the final registration step." + 
182                                  "<br/><br/>" + 
183                                 "<B>(Note. emails may accidentally be sent to your Spam Folder)</B>";
184                                 
185                     Roo.bootstrap.MessageBox.alert('Please check your email', msg) ;
186                 },
187                 failure: function(res) {
188                     Roo.bootstrap.MessageBox.alert('Error', res.errorMsg) ;
189                 }
190             });
191         },
192        render : function (_self)
193         {
194             _this.btn_resend = _self;
195              this.el.setVisibilityMode(Roo.Element.DISPLAY);
196              this.el.hide();
197         }
198       },
199       xns : Roo.bootstrap,
200       '|xns' : 'Roo.bootstrap'
201      }
202     ],
203     items  : [
204      {
205       xtype : 'Form',
206       errorMask : true,
207       loadMask : false,
208       url : baseURL + '/Register/Confirm',
209       listeners : {
210        actioncomplete : function (_self, action)
211         {
212             if (action.type == 'setdata') {
213             
214                 _this.form.findField('password').focus();
215                 
216                 return;
217             }
218             if (action.type == 'load') {
219                 
220                 return;
221             }
222             if (action.type =='submit') {
223                 
224                 _this.dialog.hide();
225                 
226                 Roo.get(document.body).mask('Start your Application');
227                 
228                 setTimeout(function() {
229                     window.location.href = baseURL;
230                 }, 500); 
231                 
232                 return;
233             }
234             
235         },
236        actionfailed : function (_self, action)
237         {
238             _this.dialog.el.unmask();
239             Roo.log("action failed");
240             Roo.log(action);
241           
242             if(!action.result.errorMsg){
243                 Roo.bootstrap.MessageBox.alert("Error", "Please contact system adminisrator");
244             }
245            
246             var msg = action.result.errorMsg;
247            
248             if(msg.length >= 200){
249                 msg = msg.substring(0,199) + '...'
250             }
251             
252             Roo.bootstrap.MessageBox.alert("Error", msg);
253         },
254        render : function (_self,e)
255         {
256             _this.form = _self;
257             
258         }
259       },
260       xns : Roo.bootstrap,
261       '|xns' : 'Roo.bootstrap',
262       items  : [
263        {
264         xtype : 'Row',
265         xns : Roo.bootstrap,
266         '|xns' : 'Roo.bootstrap',
267         items  : [
268          {
269           xtype : 'Column',
270           xs : 12,
271           xns : Roo.bootstrap,
272           '|xns' : 'Roo.bootstrap',
273           items  : [
274            {
275             xtype : 'Input',
276             fieldLabel : _this._strings['ee7ad62ad69b9ab5f25d273e4e0a1736'] /* Your Username */,
277             labelAlign : 'top',
278             name : 'email',
279             readOnly : true,
280             xns : Roo.bootstrap,
281             '|xns' : 'Roo.bootstrap'
282            }
283           ]
284          }
285         ]
286        },
287        {
288         xtype : 'Row',
289         listeners : {
290          render : function (_self)
291           {
292               _this.row_pwd_label = _self;
293           }
294         },
295         xns : Roo.bootstrap,
296         '|xns' : 'Roo.bootstrap',
297         items  : [
298          {
299           xtype : 'Column',
300           xs : 12,
301           xns : Roo.bootstrap,
302           '|xns' : 'Roo.bootstrap',
303           items  : [
304            {
305             xtype : 'FieldLabel',
306             html : _this._strings['b945ed1d61d8edbe16a1192ad6d2fd58'] /* Please enter a memorable password for logging into your application */,
307             xns : Roo.bootstrap,
308             '|xns' : 'Roo.bootstrap'
309            }
310           ]
311          }
312         ]
313        },
314        {
315         xtype : 'Row',
316         listeners : {
317          render : function (_self)
318           {
319               _this.row_pwd1 = _self;
320           }
321         },
322         xns : Roo.bootstrap,
323         '|xns' : 'Roo.bootstrap',
324         items  : [
325          {
326           xtype : 'Column',
327           xs : 12,
328           xns : Roo.bootstrap,
329           '|xns' : 'Roo.bootstrap',
330           items  : [
331            {
332             xtype : 'SecurePass',
333             allowBlank : false,
334             inputType : 'password',
335             labelAlign : 'top',
336             name : 'password',
337             placeholder : _this._strings['51eea3dc60ae3a0b1bb8188bc6337dc2'] /* enter password */,
338             xns : Roo.bootstrap,
339             '|xns' : 'Roo.bootstrap'
340            }
341           ]
342          }
343         ]
344        },
345        {
346         xtype : 'Row',
347         listeners : {
348          render : function (_self)
349           {
350               _this.row_pwd2 = _self;
351           }
352         },
353         xns : Roo.bootstrap,
354         '|xns' : 'Roo.bootstrap',
355         items  : [
356          {
357           xtype : 'Column',
358           xs : 12,
359           xns : Roo.bootstrap,
360           '|xns' : 'Roo.bootstrap',
361           items  : [
362            {
363             xtype : 'Input',
364             allowBlank : false,
365             inputType : 'password',
366             invalidText : 'The passwords you entered do not match',
367             name : 'password1',
368             placeholder : _this._strings['1849ffc8731b5e74ae6157c91ba73575'] /* Please confirm your password */,
369             validator : function(v){
370                 
371                 if(_this.form.findField('password').getValue() == v) {
372                     
373                     return true;
374                 }
375                 
376                 return false;
377             },
378             xns : Roo.bootstrap,
379             '|xns' : 'Roo.bootstrap'
380            }
381           ]
382          }
383         ]
384        },
385        {
386         xtype : 'Row',
387         xns : Roo.bootstrap,
388         '|xns' : 'Roo.bootstrap',
389         items  : [
390          {
391           xtype : 'Column',
392           xs : 8,
393           xns : Roo.bootstrap,
394           '|xns' : 'Roo.bootstrap',
395           items  : [
396            {
397             xtype : 'Input',
398             inputType : 'hidden',
399             name : 'id',
400             xns : Roo.bootstrap,
401             '|xns' : 'Roo.bootstrap'
402            },
403            {
404             xtype : 'Input',
405             inputType : 'hidden',
406             name : 'verify_key',
407             xns : Roo.bootstrap,
408             '|xns' : 'Roo.bootstrap'
409            }
410           ]
411          }
412         ]
413        }
414       ]
415      },
416      {
417       xtype : 'Row',
418       listeners : {
419        render : function (_self)
420         {
421             _this.error_row = this;
422             
423             this.el.setVisibilityMode(Roo.Element.DISPLAY);
424             
425             this.el.hide();
426         }
427       },
428       xns : Roo.bootstrap,
429       '|xns' : 'Roo.bootstrap',
430       items  : [
431        {
432         xtype : 'Column',
433         xs : 12,
434         xns : Roo.bootstrap,
435         '|xns' : 'Roo.bootstrap',
436         items  : [
437          {
438           xtype : 'Element',
439           html : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
440           listeners : {
441            render : function (_self)
442             {
443                 _this.text_el = _self;
444             }
445           },
446           xns : Roo.bootstrap,
447           '|xns' : 'Roo.bootstrap'
448          }
449         ]
450        }
451       ]
452      }
453     ]
454    }  );
455  }
456 });
457 Roo.apply(Pman.Dialog.VerifyAccess, Pman.Dialog.VerifyAccess.prototype);