Skip to content

Commit

Permalink
Added footer. It is now possible to logout.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Töyrä committed May 25, 2012
1 parent cb8ad26 commit b0585d4
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 115 deletions.
13 changes: 10 additions & 3 deletions app/controller/MainPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Ext.define('EM.controller.MainPanel', {
refs: {
forgotPasswordButton: '#login-form #forgot-password',
loginButton: '#login-form #login',
logoutButton: '#logout',
loginForm: '#login-form',
loginFormFields: '#login-form field',
mainPanel: '#main-panel',
Expand All @@ -27,6 +28,9 @@ Ext.define('EM.controller.MainPanel', {
loginButton: {
tap: 'doValidateForm'
},
logoutButton: {
tap: 'doLogout'
}
}
},

Expand Down Expand Up @@ -105,10 +109,13 @@ Ext.define('EM.controller.MainPanel', {
},

doLogout: function() {
console.log("logging out");
var loginForm = this.getLoginForm();
loginForm.reset();

EM.app.setUserData({});
this.dirtyRememberMe();
this.getMainPanel().setActiveItem(0);
this.showValidationErrorMessage('Du är nu utloggad, glöm inte att omgångarna har ett datum som du senast måste tippa klart dem.');
},

doLoginRequest: function() {
Expand Down Expand Up @@ -159,11 +166,11 @@ Ext.define('EM.controller.MainPanel', {
} else {
switch(response.status) {
case 401: // User is not authorized to login
this.showValidationErrorMessage('Inloggningen misslyckades. Kontrollera dina loginuppgifter.');
this.showValidationErrorMessage('Felaktigt användarnamn eller lösenord. Försök igen.');
break;

default: // All other kinds of errors
this.showValidationErrorMessage('Kunde inte kontakta servern. Försök igen lite senare.');
this.showValidationErrorMessage('Ursäkta, det går inte att logga in nu av någon okänd anledning. Försök igen senare.');
}
}
}
Expand Down
17 changes: 14 additions & 3 deletions app/controller/ResultsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ Ext.define('EM.controller.ResultsPage', {
launch: function() {},

config: {
views: ['MatchList', 'MyStats', 'ResultsPage', 'RoundSelector', 'TopScorer', 'Top4'],
views: ['Footer', 'MatchList', 'MyStats', 'ResultsPage', 'RoundSelector', 'TopScorer', 'Top4'],

refs: {
footer: {
selector: 'footer',
xtype: 'footer',
autoCreate: true
},
logoutLink: '#logout',
lastUpdated: '#matches-last-updated',
top4: {
selector: 'top-4',
Expand Down Expand Up @@ -132,9 +138,12 @@ Ext.define('EM.controller.ResultsPage', {
this.getResultsPage().add(this.getTop4());
this.getResultsPage().add(this.getTopScorer());
this.getResultsPage().add(this.getMatchList());
this.getResultsPage().add(this.getFooter());

this.doUpdateLastUpdated();
this.roundFilterByKey('roundId', activeRoundId); // Filter the matchlist and display the first round of matches.

//console.log("logoutLink: ", this.getLogoutLink());
}
});
},
Expand Down Expand Up @@ -181,20 +190,22 @@ Ext.define('EM.controller.ResultsPage', {
* Display the 'Topp 4' page.
*/
doTop4: function(button, event, eventOpts) {
this.getFooter().hide();
this.getMatchList().hide();
this.getTopScorer().hide();
this.getTop4().show();
console.log("Tapped on Topp 4");
this.getFooter().show();
},

/**
* Display the 'Skyttekung' page.
*/
doTopScorer: function(button, event, eventOpts) {
this.getFooter().hide();
this.getMatchList().hide();
this.getTop4().hide();
this.getTopScorer().show();
console.log("Tapped on Skyttekung");
this.getFooter().show();
},

/**
Expand Down
37 changes: 37 additions & 0 deletions app/view/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Ext.define('EM.view.Footer', {
extend: 'Ext.Toolbar',
xtype: 'footer',

config: {
id: 'footer',

items: [
{
xtype: 'button',
text: 'Regler',
handler: function() {

}
},
{
xtype: 'button',
text: 'Bjud in en kompis',
handler: function() {

}
},
{
xtype: 'button',
text: 'Byt lösenord',
handler: function() {

}
},
{
xtype: 'button',
text: 'Logga ut',
id: 'logout',
},
],
}
})
2 changes: 1 addition & 1 deletion app/view/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Ext.define('EM.view.Main', {
items: [
{
xtype: 'resultspage'
}
},
]
});
Loading

0 comments on commit b0585d4

Please sign in to comment.