source: Dev/branches/rest-dojo-ui/client/rft/ui/LoginDialog.js @ 263

Last change on this file since 263 was 263, checked in by hendrikvanantwerpen, 13 years ago
  • [Client] Finished page framework. See rft/ui/content.js or test files for details.
  • [Client] Allow login by pressing Enter.
  • [API] On exception include details in json response.
  • [Server Use Exceptions when save() fails, iso return values.
File size: 1.4 KB
Line 
1define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dijit/Dialog',
2    'dijit/_WidgetsInTemplateMixin','../auth', 'dojo/text!./LoginDialog.html',
3    '../content','dijit/form/Form','dijit/form/Button','dijit/form/TextBox'],
4    function (declare, lang, event, Dialog, _WidgetsInTemplateMixin, auth, template, content) {
5        return declare([Dialog,_WidgetsInTemplateMixin], {
6            templateString: template,
7            widgetsInTemplate: true,
8            title: "Login",
9            baseClass: "rftLoginDialog",
10            startup: function() {
11                this.inherited(arguments);
12                this.loginForm.on('submit',lang.hitch(this,'onLogin'));
13            },
14            show: function() {
15                this.loginErrors.innerHTML = '';
16                this.loginForm.reset();
17                this.inherited(arguments);
18            },
19            onLogin: function(evt) {
20                this.loginErrors.innerHTML = '';
21                var data = this.loginForm.get('value');
22                auth.login(data.username,data.password)
23                .then(lang.hitch(this,function() {
24                    this.hide();
25                    content.initial();
26                }),lang.hitch(this,function() {
27                    this.loginErrors.innerHTML = 'Login failed.';
28                }));
29                event.stop(evt);
30                return false;
31            }
32        });
33    });
Note: See TracBrowser for help on using the repository browser.