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

Task #14393: Add switch role possibility if user is logged in as speaker

parent 5ec0151d
......@@ -224,6 +224,9 @@ Ext.application({
/* show diagnosis tab panel */
mainTabPanel.diagnosisPanel.tab.show();
/* check existing login in stored session */
ARSnova.app.getController('Sessions').checkExistingSessionLogin();
mainTabPanel.animateActiveItem(mainTabPanel.homeTabPanel, 'slide');
var hTP = mainTabPanel.homeTabPanel;
switch (ARSnova.app.userRole) {
......@@ -237,12 +240,6 @@ Ext.application({
default:
break;
}
if (sessionStorage.getItem("keyword") !== null && sessionStorage.getItem("keyword") !== "") {
return ARSnova.app.getController('Sessions').login({
keyword: sessionStorage.getItem("keyword")
});
}
},
/**
......
......@@ -160,7 +160,7 @@ Ext.define("ARSnova.controller.Auth", {
var animation = {
type: 'flip',
direction: role ? 'right' : left,
direction: role ? 'right' : 'left',
listeners: !callback ? {} : {
animationend: callback
}
......
......@@ -172,10 +172,15 @@ Ext.define("ARSnova.controller.Sessions", {
tabPanel.feedbackTabPanel.tab.hide();
},
reloadData: function () {
reloadData: function (animation) {
var tabPanel = ARSnova.app.mainTabPanel.tabPanel;
var hideLoadMask = Ext.emptyFn;
animation = !!animation ? animation : {
type: 'slide',
duration: 700
};
if (ARSnova.app.isSessionOwner && ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
ARSnova.app.sessionModel.fireEvent(ARSnova.app.sessionModel.events.sessionJoinAsSpeaker);
/* add speaker in class panel */
......@@ -187,10 +192,7 @@ Ext.define("ARSnova.controller.Sessions", {
tabPanel.speakerTabPanel.tab.show();
tabPanel.speakerTabPanel.renew();
}
tabPanel.animateActiveItem(tabPanel.speakerTabPanel, {
type: 'slide',
duration: 700
});
tabPanel.animateActiveItem(tabPanel.speakerTabPanel, animation);
tabPanel.speakerTabPanel.inClassPanel.registerListeners();
/* add feedback statistic panel*/
......@@ -231,21 +233,22 @@ Ext.define("ARSnova.controller.Sessions", {
tabPanel.feedbackTabPanel.renew();
}
tabPanel.animateActiveItem(tabPanel.userTabPanel, {
type: 'slide',
duration: 700
});
tabPanel.animateActiveItem(tabPanel.userTabPanel, animation);
}
/* add feedback questions panel*/
if (!tabPanel.feedbackQuestionsPanel) {
tabPanel.feedbackQuestionsPanel = Ext.create('ARSnova.view.feedbackQuestions.TabPanel');
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
tabPanel.insert(2, tabPanel.feedbackQuestionsPanel);
} else {
tabPanel.insert(4, tabPanel.feedbackQuestionsPanel);
}
}
if (!tabPanel.userTabPanel) {
tabPanel.insert(2, tabPanel.feedbackQuestionsPanel);
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
tabPanel.feedbackQuestionsPanel.tab.show();
} else {
tabPanel.insert(4, tabPanel.feedbackQuestionsPanel);
tabPanel.feedbackQuestionsPanel.tab.hide();
}
......@@ -377,6 +380,59 @@ Ext.define("ARSnova.controller.Sessions", {
});
},
changeRole: function () {
var tabPanel = ARSnova.app.mainTabPanel.tabPanel;
var hideLoadMask = ARSnova.app.showLoadMask(Messages.LOAD_MASK_LOGIN);
var reloadSession = function (animationDirection) {
ARSnova.app.socket.setSession(null);
ARSnova.app.socket.setSession(sessionStorage.getItem('keyword'));
ARSnova.app.mainTabPanel.tabPanel.updateHomeBadge();
ARSnova.app.getController('Sessions').reloadData({
direction: animationDirection,
type: 'flip'
});
hideLoadMask();
};
if (ARSnova.app.userRole === ARSnova.app.USER_ROLE_SPEAKER) {
localStorage.setItem('lastVisitedRole', ARSnova.app.USER_ROLE_SPEAKER);
localStorage.setItem('role', ARSnova.app.USER_ROLE_STUDENT);
ARSnova.app.userRole = ARSnova.app.USER_ROLE_STUDENT;
/* hide speaker tab panel and destroy listeners */
tabPanel.speakerTabPanel.tab.hide();
tabPanel.speakerTabPanel.inClassPanel.destroyListeners();
reloadSession('right');
} else {
if (localStorage.getItem('lastVisitedRole') === ARSnova.app.USER_ROLE_SPEAKER) {
localStorage.setItem('role', ARSnova.app.USER_ROLE_SPEAKER);
ARSnova.app.userRole = ARSnova.app.USER_ROLE_SPEAKER;
localStorage.removeItem('lastVisitedRole');
/* hide user tab panel and destroy listeners */
tabPanel.userTabPanel.tab.hide();
tabPanel.userQuestionsPanel.tab.hide();
tabPanel.userTabPanel.inClassPanel.destroyListeners();
reloadSession('left');
}
}
},
checkExistingSessionLogin: function () {
if (localStorage.getItem('lastVisitedRole') === ARSnova.app.USER_ROLE_SPEAKER) {
localStorage.setItem('role', ARSnova.app.USER_ROLE_SPEAKER);
ARSnova.app.userRole = ARSnova.app.USER_ROLE_SPEAKER;
localStorage.removeItem('lastVisitedRole');
} else {
if (sessionStorage.getItem("keyword") !== null && sessionStorage.getItem("keyword") !== "") {
ARSnova.app.getController('Sessions').login({
keyword: sessionStorage.getItem("keyword")
});
}
}
},
setActive: function (options) {
ARSnova.app.sessionModel.lock(sessionStorage.getItem("keyword"), options.active, {
success: function () {
......
......@@ -34,7 +34,7 @@ Ext.define('ARSnova.view.SessionStatusButton', {
this.sessionIsClosed = Ext.create('ARSnova.view.MatrixButton', {
buttonConfig: 'icon',
cls: 'actionButton',
cls: 'smallerActionButton',
text: Messages.START_SESSION,
imageCls: 'icon-lock thm-orange',
imageStyle: {
......@@ -48,7 +48,7 @@ Ext.define('ARSnova.view.SessionStatusButton', {
this.sessionIsOpen = Ext.create('ARSnova.view.MatrixButton', {
buttonConfig: 'icon',
cls: 'actionButton',
cls: 'smallerActionButton',
text: Messages.STOP_SESSION,
imageCls: 'icon-unlock',
imageStyle: {
......@@ -104,6 +104,11 @@ Ext.define('ARSnova.view.SessionStatusButton', {
this.isRendered = true;
},
setActionButtonCls: function (buttonCls) {
this.sessionIsClosed.setCls(buttonCls);
this.sessionIsOpen.setCls(buttonCls);
},
sessionClosedSuccessfully: function () {
this.isOpen = false;
this.sessionIsClosed.show();
......
......@@ -139,7 +139,10 @@ Ext.define('ARSnova.view.speaker.InClass', {
cls: 'roleIconBtn',
buttonConfig: 'icon',
imageCls: 'icon-speaker',
hidden: true
hidden: true,
handler: function () {
ARSnova.app.getController('Sessions').changeRole();
}
});
this.actionButtonPanel = Ext.create('Ext.Panel', {
......@@ -222,27 +225,13 @@ Ext.define('ARSnova.view.speaker.InClass', {
hidden: true
});
this.inClassItems = Ext.create('Ext.form.FormPanel', {
scrollable: null,
items: [{
cls: 'gravure selectable',
html: Messages.SESSION_ID + ": " + ARSnova.app.formatSessionID(sessionStorage.getItem("keyword"))
}, this.actionButtonPanel, this.inClassButtons, {
xtype: 'formpanel',
cls: 'standardForm topPadding',
scrollable: null,
items: this.caption
}]
});
this.sessionStatusButton = Ext.create('ARSnova.view.SessionStatusButton');
this.deleteSessionButton = Ext.create('ARSnova.view.MatrixButton', {
id: 'delete-session-button',
text: Messages.DELETE_SESSION,
buttonConfig: 'icon',
cls: 'actionButton',
cls: 'smallerActionButton',
imageCls: 'icon-close thm-red',
scope: this,
handler: function () {
......@@ -273,11 +262,39 @@ Ext.define('ARSnova.view.speaker.InClass', {
type: 'hbox',
pack: 'center'
},
items: [{
xtype: 'spacer',
flex: '3',
width: true,
hidden: true
}, this.sessionStatusButton, {
xtype: 'spacer',
hidden: true
}, this.roleIconButton, {
xtype: 'spacer',
hidden: true
}, this.deleteSessionButton, {
xtype: 'spacer',
flex: '3',
width: true,
hidden: true
}]
});
items: [
this.sessionStatusButton,
this.deleteSessionButton
]
this.inClassItems = Ext.create('Ext.form.FormPanel', {
scrollable: null,
items: [{
cls: 'gravure selectable',
html: Messages.SESSION_ID + ": " + ARSnova.app.formatSessionID(
sessionStorage.getItem("keyword")
)
}, this.actionButtonPanel, this.inClassButtons, {
xtype: 'formpanel',
cls: 'standardForm topPadding',
scrollable: null,
items: this.caption
}, this.inClassActions]
});
this.badgeOptions = {
......@@ -287,7 +304,7 @@ Ext.define('ARSnova.view.speaker.InClass', {
numUnredInterposed: 0
};
this.add([this.toolbar, this.inClassItems, this.inClassActions]);
this.add([this.toolbar, this.inClassItems]);
this.on('destroy', this.destroyListeners);
this.onBefore('painted', function () {
......@@ -307,11 +324,27 @@ Ext.define('ARSnova.view.speaker.InClass', {
sTP.animateActiveItem(sTP.showcaseQuestionPanel, 'slide');
},
showShowcaseActionElements: function (show) {
updateActionButtonElements: function (showElements) {
var buttonCls = showElements ? 'actionButton' : 'smallerActionButton';
var me = this;
if (showElements) {
this.actionButtonPanel.insert(3, me.roleIconButton);
} else {
this.inClassActions.insert(3, me.roleIconButton);
}
this.actionButtonPanel.getInnerItems().forEach(function (element) {
if (element !== me.createAdHocQuestionButton) {
element.setHidden(!show);
element.setHidden(!showElements);
}
});
this.inClassActions.getInnerItems().forEach(function (element) {
if (!(element === me.sessionStatusButton ||
element === me.deleteSessionButton)) {
element.setHidden(showElements);
} else {
me.sessionStatusButton.setActionButtonCls(buttonCls);
me.deleteSessionButton.setCls(buttonCls);
}
});
},
......@@ -358,7 +391,7 @@ Ext.define('ARSnova.view.speaker.InClass', {
sTP.showcaseQuestionPanel.setController(ARSnova.app.getController('Questions'));
sTP.showcaseQuestionPanel.setLectureMode();
sTP.inClassPanel.showShowcaseActionElements(false);
sTP.inClassPanel.updateActionButtonElements(false);
sTP.inClassPanel.updateAudienceQuestionBadge();
},
......@@ -400,7 +433,7 @@ Ext.define('ARSnova.view.speaker.InClass', {
} else {
me.showcaseActionButton.setButtonText(Messages.SHOWCASE_MODE_PLURAL);
}
me.showShowcaseActionElements(true);
me.updateActionButtonElements(!!numQuestions);
}
ARSnova.app.questionModel.countLectureQuestionAnswers(sessionStorage.getItem("keyword"), {
......
......@@ -102,7 +102,7 @@ Ext.define('ARSnova.view.user.InClass', {
this.voteButton = Ext.create('ARSnova.view.MatrixButton', {
text: Messages.GIVE_FEEDBACK,
cls: 'smallerActionButton',
cls: ARSnova.app.isSessionOwner ? 'smallerActionButton' : 'actionButton',
buttonConfig: 'icon',
imageCls: 'icon-bullhorn',
controller: 'Feedback',
......@@ -112,7 +112,7 @@ Ext.define('ARSnova.view.user.InClass', {
this.feedbackButton = Ext.create('ARSnova.view.MatrixButton', {
text: Messages.QUESTION_REQUEST_ADHOC,
cls: 'smallerActionButton',
cls: ARSnova.app.isSessionOwner ? 'smallerActionButton' : 'actionButton',
buttonConfig: 'icon',
imageCls: 'icon-question thm-green',
handler: function () {
......@@ -125,7 +125,11 @@ Ext.define('ARSnova.view.user.InClass', {
this.roleIconButton = Ext.create('ARSnova.view.MatrixButton', {
cls: 'roleIconBtn',
buttonConfig: 'icon',
imageCls: 'icon-users'
imageCls: 'icon-users',
hidden: !ARSnova.app.isSessionOwner,
handler: function () {
ARSnova.app.getController('Sessions').changeRole();
}
});
this.actionButtonPanel = Ext.create('Ext.Panel', {
......@@ -138,16 +142,20 @@ Ext.define('ARSnova.view.user.InClass', {
items: [{
xtype: 'spacer',
width: true,
flex: '3',
width: true
hidden: !ARSnova.app.isSessionOwner
}, this.feedbackButton, {
xtype: 'spacer'
xtype: 'spacer',
hidden: !ARSnova.app.isSessionOwner
}, this.roleIconButton, {
xtype: 'spacer'
xtype: 'spacer',
hidden: !ARSnova.app.isSessionOwner
}, this.voteButton, {
xtype: 'spacer',
width: true,
flex: '3',
width: true
hidden: !ARSnova.app.isSessionOwner
}
]
});
......
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