Commit c7ac0bc8 authored by Andreas Gärtner's avatar Andreas Gärtner

Task #16246: Adjusted event handler for session overview panels.

parent fe9da009
......@@ -148,7 +148,7 @@ Ext.define("ARSnova.controller.Auth", {
}
},
changeRole: function (role) {
changeRole: function (role, callback) {
console.debug("Controller: Auth.changeRole", role);
var mainTabPanel = ARSnova.app.mainTabPanel.tabPanel;
var hTP = mainTabPanel.homeTabPanel;
......@@ -158,19 +158,21 @@ Ext.define("ARSnova.controller.Auth", {
role === ARSnova.app.USER_ROLE_SPEAKER ?
role : ARSnova.app.userRole;
var animation = {
type: 'flip',
direction: role ? 'right' : left,
listeners: !callback ? {} : {
animationend: callback
}
};
switch (ARSnova.app.userRole) {
case ARSnova.app.USER_ROLE_STUDENT:
hTP.homePanel.checkLogin();
hTP.animateActiveItem(hTP.homePanel, {
type: 'flip',
direction: 'left'
});
hTP.animateActiveItem(hTP.homePanel, animation);
break;
case ARSnova.app.USER_ROLE_SPEAKER:
hTP.animateActiveItem(hTP.mySessionsPanel, {
type: 'flip',
direction: 'right'
});
hTP.animateActiveItem(hTP.mySessionsPanel, animation);
break;
}
......
......@@ -67,9 +67,13 @@ Ext.define('ARSnova.view.home.HomePanel', {
text: Messages.CHANGE_ROLE,
align: 'right',
ui: 'confirm',
handler: function () {
scope: this,
handler: function (button) {
button.disable();
ARSnova.app.getController('Auth').changeRole(
ARSnova.app.USER_ROLE_SPEAKER
ARSnova.app.USER_ROLE_SPEAKER, function () {
button.enable();
}
);
}
});
......@@ -231,29 +235,7 @@ Ext.define('ARSnova.view.home.HomePanel', {
this.add(this.matrixButtonPanel);
}
this.onBefore('painted', function () {
var me = this;
if (ARSnova.app.userRole !== ARSnova.app.USER_ROLE_SPEAKER) {
var handler = function success(sessions) {
me.caption.summarize(sessions, {
questions: true,
unanswered: false,
unredInterposed: false,
interposed: true,
answers: true
});
me.add(me.caption);
};
var p1 = this.loadVisitedSessions();
var p2 = this.loadMySessions();
// get the summary of all session lists
RSVP.all([p1, p2]).then(handler, function error() {
// errors swallow results, retest each promise seperately to figure out if one succeeded
p1.then(handler);
p2.then(handler);
});
}
});
this.on('activate', this.onActivate);
this.on('resize', function () {
this.resizeSessionButtons();
......@@ -261,6 +243,30 @@ Ext.define('ARSnova.view.home.HomePanel', {
});
},
onActivate: function () {
var me = this;
if (ARSnova.app.userRole !== ARSnova.app.USER_ROLE_SPEAKER) {
var handler = function success(sessions) {
me.caption.summarize(sessions, {
questions: true,
unanswered: false,
unredInterposed: false,
interposed: true,
answers: true
});
me.add(me.caption);
};
var p1 = this.loadVisitedSessions();
var p2 = this.loadMySessions();
// get the summary of all session lists
RSVP.all([p1, p2]).then(handler, function error() {
// errors swallow results, retest each promise seperately to figure out if one succeeded
p1.then(handler);
p2.then(handler);
});
}
},
checkLogin: function () {
if (ARSnova.app.loginMode === ARSnova.app.LOGIN_THM) {
this.logoutButton.addCls('thm');
......
......@@ -84,9 +84,12 @@ Ext.define('ARSnova.view.home.MySessionsPanel', {
text: Messages.CHANGE_ROLE,
align: 'right',
ui: 'confirm',
handler: function () {
handler: function (button) {
button.disable();
ARSnova.app.getController('Auth').changeRole(
ARSnova.app.USER_ROLE_STUDENT
ARSnova.app.USER_ROLE_STUDENT, function () {
button.enable();
}
);
}
});
......@@ -353,47 +356,41 @@ Ext.define('ARSnova.view.home.MySessionsPanel', {
this.lastVisitedSessionsForm
]);
this.onBefore('painted', function () {
var me = this;
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
var handler = function success(sessions) {
me.caption.summarize(sessions, {
unredInterposed: false
});
me.add(me.caption);
};
var p1 = this.loadCreatedSessions();
var p2 = this.loadVisitedSessions();
var p3 = this.loadCreatedPublicPoolSessions();
// get the summary of all session lists
RSVP.all([p1, p2, p3]).then(handler, function error() {
// errors swallow results, retest each promise seperately to figure out if one succeeded
p1.then(handler);
p2.then(handler);
p3.then(handler);
});
}
this.on('activate', this.onActivate);
this.on('resize', function () {
this.resizeMySessionsButtons();
this.resizeLastVisitedSessionButtons();
});
},
this.on('activate', function () {
switch (ARSnova.app.userRole) {
case ARSnova.app.USER_ROLE_SPEAKER:
this.backButton.hide();
this.logoutButton.show();
break;
default:
break;
}
onActivate: function () {
var me = this;
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
this.backButton.hide();
this.logoutButton.show();
if (ARSnova.app.loginMode === ARSnova.app.LOGIN_THM) {
this.logoutButton.addCls('thm');
}
});
this.on('resize', function () {
this.resizeMySessionsButtons();
this.resizeLastVisitedSessionButtons();
});
var handler = function success(sessions) {
me.caption.summarize(sessions, {
unredInterposed: false
});
me.add(me.caption);
};
var p1 = this.loadCreatedSessions();
var p2 = this.loadVisitedSessions();
var p3 = this.loadCreatedPublicPoolSessions();
// get the summary of all session lists
RSVP.all([p1, p2, p3]).then(handler, function error() {
// errors swallow results, retest each promise seperately to figure out if one succeeded
p1.then(handler);
p2.then(handler);
p3.then(handler);
});
}
},
resizeMySessionsButtons: function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment