extjs-gpl
Version:
GPL licensed version of Sencha Ext JS
54 lines (43 loc) • 1.37 kB
JavaScript
/**
* This View Controller is associated with the Login view.
*/
Ext.define('Ticket.view.login.LoginController', {
extend: 'Ext.app.ViewController',
alias: 'controller.login',
loginText: 'Logging in...',
onSpecialKey: function(field, e) {
if (e.getKey() === e.ENTER) {
this.doLogin();
}
},
onLoginClick: function() {
this.doLogin();
},
doLogin: function() {
var form = this.lookupReference('form');
if (form.isValid()) {
Ext.getBody().mask(this.loginText);
if (!this.loginManager) {
this.loginManager = new Ticket.LoginManager({
session: this.getView().getSession(),
model: 'User'
});
}
this.loginManager.login({
data: form.getValues(),
scope: this,
success: 'onLoginSuccess',
failure: 'onLoginFailure'
});
}
},
onLoginFailure: function() {
// Do something
Ext.getBody().unmask();
},
onLoginSuccess: function(user) {
Ext.getBody().unmask();
var org = this.lookupReference('organization').getSelectedRecord();
this.fireViewEvent('login', this.getView(), user, org, this.loginManager);
}
});