MOBILE-2479 course: Pass course format instance to site plugins
This will allow site plugins to create a view exactly like topics/weeks without having to use Javascriptmain
parent
55682818ff
commit
6fdb5528ed
|
@ -77,6 +77,9 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
this.selectOptions.title = translate.instant('core.course.sections');
|
this.selectOptions.title = translate.instant('core.course.sections');
|
||||||
this.completionChanged = new EventEmitter();
|
this.completionChanged = new EventEmitter();
|
||||||
|
|
||||||
|
// Pass this instance to all components so they can use its methods and properties.
|
||||||
|
this.data.coreCourseFormatComponent = this;
|
||||||
|
|
||||||
// Listen for section status changes.
|
// Listen for section status changes.
|
||||||
this.sectionStatusObserver = eventsProvider.on(CoreEventsProvider.SECTION_STATUS_CHANGED, (data) => {
|
this.sectionStatusObserver = eventsProvider.on(CoreEventsProvider.SECTION_STATUS_CHANGED, (data) => {
|
||||||
if (this.downloadEnabled && this.sections && this.sections.length && this.course && data.sectionId &&
|
if (this.downloadEnabled && this.sections && this.sections.length && this.course && data.sectionId &&
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
import { Component, OnChanges, Input, ViewChild, Output, EventEmitter } from '@angular/core';
|
import { Component, OnChanges, Input, ViewChild, Output, EventEmitter } from '@angular/core';
|
||||||
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
|
import { CoreSitePluginsProvider } from '../../providers/siteplugins';
|
||||||
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
|
import { CoreSitePluginsPluginContentComponent } from '../plugin-content/plugin-content';
|
||||||
|
import { CoreCourseFormatComponent } from '@core/course/components/format/format';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays the index of a course format site plugin.
|
* Component that displays the index of a course format site plugin.
|
||||||
|
@ -32,6 +33,11 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges {
|
||||||
@Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
|
@Input() moduleId?: number; // The module ID to scroll to. Must be inside the initial selected section.
|
||||||
@Output() completionChanged?: EventEmitter<void>; // Will emit an event when any module completion changes.
|
@Output() completionChanged?: EventEmitter<void>; // Will emit an event when any module completion changes.
|
||||||
|
|
||||||
|
// Special input, allows access to the parent instance properties and methods.
|
||||||
|
// Please notice that all the other inputs/outputs are also accessible through this instance, so they could be removed.
|
||||||
|
// However, we decided to keep them to support ngOnChanges and to make templates easier to read.
|
||||||
|
@Input() coreCourseFormatComponent: CoreCourseFormatComponent;
|
||||||
|
|
||||||
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
|
@ViewChild(CoreSitePluginsPluginContentComponent) content: CoreSitePluginsPluginContentComponent;
|
||||||
|
|
||||||
component: string;
|
component: string;
|
||||||
|
@ -69,7 +75,8 @@ export class CoreSitePluginsCourseFormatComponent implements OnChanges {
|
||||||
initialSectionId: this.initialSectionId,
|
initialSectionId: this.initialSectionId,
|
||||||
initialSectionNumber: this.initialSectionNumber,
|
initialSectionNumber: this.initialSectionNumber,
|
||||||
moduleId: this.moduleId,
|
moduleId: this.moduleId,
|
||||||
completionChanged: this.completionChanged
|
completionChanged: this.completionChanged,
|
||||||
|
coreCourseFormatComponent: this.coreCourseFormatComponent
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue