Merge pull request #1539 from dpalou/MOBILE-2575
MOBILE-2575 course: Allow selecting another tab in coursemain
commit
c11a155fe4
|
@ -62,6 +62,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
protected module: any;
|
protected module: any;
|
||||||
protected completionObserver;
|
protected completionObserver;
|
||||||
protected courseStatusObserver;
|
protected courseStatusObserver;
|
||||||
|
protected firstTabName: string;
|
||||||
protected isDestroyed = false;
|
protected isDestroyed = false;
|
||||||
|
|
||||||
constructor(navParams: NavParams, private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider,
|
constructor(navParams: NavParams, private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider,
|
||||||
|
@ -74,6 +75,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
this.sectionId = navParams.get('sectionId');
|
this.sectionId = navParams.get('sectionId');
|
||||||
this.sectionNumber = navParams.get('sectionNumber');
|
this.sectionNumber = navParams.get('sectionNumber');
|
||||||
this.module = navParams.get('module');
|
this.module = navParams.get('module');
|
||||||
|
this.firstTabName = navParams.get('selectedTab');
|
||||||
|
|
||||||
// Get the title to display. We dont't have sections yet.
|
// Get the title to display. We dont't have sections yet.
|
||||||
this.title = courseFormatDelegate.getCourseTitle(this.course);
|
this.title = courseFormatDelegate.getCourseTitle(this.course);
|
||||||
|
@ -228,13 +230,28 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
// Load the course handlers.
|
// Load the course handlers.
|
||||||
promises.push(this.courseOptionsDelegate.getHandlersToDisplay(this.injector, this.course, refresh, false)
|
promises.push(this.courseOptionsDelegate.getHandlersToDisplay(this.injector, this.course, refresh, false)
|
||||||
.then((handlers) => {
|
.then((handlers) => {
|
||||||
|
let tabToLoad;
|
||||||
|
|
||||||
// Add the courseId to the handler component data.
|
// Add the courseId to the handler component data.
|
||||||
handlers.forEach((handler) => {
|
handlers.forEach((handler, index) => {
|
||||||
handler.data.componentData = handler.data.componentData || {};
|
handler.data.componentData = handler.data.componentData || {};
|
||||||
handler.data.componentData.courseId = this.course.id;
|
handler.data.componentData.courseId = this.course.id;
|
||||||
|
|
||||||
|
// Check if this handler should be the first selected tab.
|
||||||
|
if (this.firstTabName && handler.name == this.firstTabName) {
|
||||||
|
tabToLoad = index + 1;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.courseHandlers = handlers;
|
this.courseHandlers = handlers;
|
||||||
|
|
||||||
|
// Select the tab if needed.
|
||||||
|
this.firstTabName = undefined;
|
||||||
|
if (tabToLoad) {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.tabsComponent.selectTab(tabToLoad);
|
||||||
|
});
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return Promise.all(promises).catch((error) => {
|
return Promise.all(promises).catch((error) => {
|
||||||
|
|
|
@ -109,6 +109,12 @@ export interface CoreCourseOptionsHandlerToDisplay {
|
||||||
*/
|
*/
|
||||||
data: CoreCourseOptionsHandlerData;
|
data: CoreCourseOptionsHandlerData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the handler, or name and sub context (AddonMessages, AddonMessages:blockContact, ...).
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
name: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The highest priority is displayed first.
|
* The highest priority is displayed first.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
@ -277,7 +283,8 @@ export class CoreCourseOptionsDelegate extends CoreDelegate {
|
||||||
handlersToDisplay.push({
|
handlersToDisplay.push({
|
||||||
data: data,
|
data: data,
|
||||||
priority: handler.priority,
|
priority: handler.priority,
|
||||||
prefetch: handler.prefetch && handler.prefetch.bind(handler)
|
prefetch: handler.prefetch && handler.prefetch.bind(handler),
|
||||||
|
name: handler.name
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.logger.error('Error getting data for handler', handler.name, err);
|
this.logger.error('Error getting data for handler', handler.name, err);
|
||||||
|
|
Loading…
Reference in New Issue