Commit 61e5e8bd authored by Andreas Gärtner's avatar Andreas Gärtner
Browse files

Task #15742: Show last viewed question after return from embedded page.

parent 4dd1515f
......@@ -118,6 +118,15 @@ Ext.define("ARSnova.controller.Application", {
if (previewPanel) {
previewPanel.showEmbeddedPagePreview(controller.embeddedPage);
} else {
var tabPanel = ARSnova.app.mainTabPanel.tabPanel;
var speakerTP = tabPanel.speakerTabPanel;
var activePanel = speakerTP ? speakerTP.getActiveItem() : tabPanel.getActiveItem();
if (tabPanel.userTabPanel && activePanel === tabPanel.userQuestionsPanel ||
speakerTP && activePanel === speakerTP.showcaseQuestionPanel) {
activePanel.saveActiveIndex();
}
ARSnova.app.mainTabPanel.tabPanel.animateActiveItem(controller.embeddedPage, 'slide');
}
});
......
......@@ -76,6 +76,7 @@ Ext.define('ARSnova.view.speaker.ShowcaseQuestionPanel', {
});
this.add([this.toolbar]);
this.lastActiveIndex = -1;
this.on('activate', this.onActivate);
this.on('activate', this.beforeActivate, this, null, 'before');
......@@ -118,6 +119,7 @@ Ext.define('ARSnova.view.speaker.ShowcaseQuestionPanel', {
this.getController().getQuestions(sessionStorage.getItem("keyword"), {
success: function (response) {
var activeIndex = 0;
var questions = Ext.decode(response.responseText);
var panel = ARSnova.app.mainTabPanel.tabPanel.speakerTabPanel.showcaseQuestionPanel;
......@@ -135,10 +137,11 @@ Ext.define('ARSnova.view.speaker.ShowcaseQuestionPanel', {
panel.addQuestion(questionsArr[questionId]);
});
// bugfix (workaround): after removing all items from carousel the active index
// is set to -1. To fix that you have manually set the activeItem on the first
// question.
panel.setActiveItem(0);
if (panel.lastActiveIndex !== -1) {
activeIndex = panel.lastActiveIndex;
panel.lastActiveIndex = -1;
}
panel.setActiveItem(activeIndex);
panel.checkFirstQuestion();
hideIndicator();
},
......@@ -167,6 +170,10 @@ Ext.define('ARSnova.view.speaker.ShowcaseQuestionPanel', {
this.add(questionPanel);
},
saveActiveIndex: function () {
this.lastActiveIndex = this.getActiveIndex();
},
checkFirstQuestion: function () {
var firstQuestionView = this.items.items[0];
......
......@@ -62,6 +62,7 @@ Ext.define('ARSnova.view.user.QuestionPanel', {
});
this.add([this.toolbar]);
this.lastActiveIndex = -1;
this.onBefore('activate', this.beforeActivate, this);
this.onAfter('activate', this.onActivate, this);
......@@ -188,6 +189,11 @@ Ext.define('ARSnova.view.user.QuestionPanel', {
self.setActiveItem(0);
userQuestionsPanel.checkAnswer();
if (self.lastActiveIndex !== -1) {
activeIndex = self.lastActiveIndex;
self.lastActiveIndex = -1;
}
if (activeIndex !== -1) {
userQuestionsPanel.setActiveItem(activeIndex);
} else {
......@@ -416,6 +422,10 @@ Ext.define('ARSnova.view.user.QuestionPanel', {
}
},
saveActiveIndex: function () {
this.lastActiveIndex = this.getActiveIndex();
},
renew: function (questionIds) {
this.activeQuestionIds = questionIds.map(function (question) {
return question._id;
......
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