MOBILE-3054 Courses: Trigger update of "All sections" download icon
parent
d6f30dcd88
commit
d03845caa7
|
@ -86,7 +86,8 @@
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
<ng-container *ngFor="let module of section.modules">
|
<ng-container *ngFor="let module of section.modules">
|
||||||
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [courseId]="course.id" [downloadEnabled]="downloadEnabled" [section]="section" (completionChanged)="onCompletionChange($event)"></core-course-module>
|
<core-course-module *ngIf="module.visibleoncoursepage !== 0" [module]="module" [courseId]="course.id" [downloadEnabled]="downloadEnabled" [section]="section"
|
||||||
|
(completionChanged)="onCompletionChange($event)" (statusChanged)="onModuleStatusChange($event)"></core-course-module>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</section>
|
</section>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
|
@ -488,9 +488,9 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
if (this.downloadEnabled) {
|
if (this.downloadEnabled) {
|
||||||
// The download status of a section might have been changed from within a module page.
|
// The download status of a section might have been changed from within a module page.
|
||||||
if (this.selectedSection && this.selectedSection.id !== CoreCourseProvider.ALL_SECTIONS_ID) {
|
if (this.selectedSection && this.selectedSection.id !== CoreCourseProvider.ALL_SECTIONS_ID) {
|
||||||
this.courseHelper.calculateSectionStatus(this.selectedSection, this.course.id);
|
this.courseHelper.calculateSectionStatus(this.selectedSection, this.course.id, false, false);
|
||||||
} else {
|
} else {
|
||||||
this.courseHelper.calculateSectionsStatus(this.sections, this.course.id);
|
this.courseHelper.calculateSectionsStatus(this.sections, this.course.id, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,4 +538,13 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
// Emit a new event for other components.
|
// Emit a new event for other components.
|
||||||
this.completionChanged.emit(completionData);
|
this.completionChanged.emit(completionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recalculate the download status of each section, in response to a module being downloaded.
|
||||||
|
*
|
||||||
|
* @param {any} eventData
|
||||||
|
*/
|
||||||
|
onModuleStatusChange(eventData: any): void {
|
||||||
|
this.courseHelper.calculateSectionsStatus(this.sections, this.course.id, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Output() completionChanged?: EventEmitter<any>; // Will emit an event when the module completion changes.
|
@Output() completionChanged?: EventEmitter<any>; // Will emit an event when the module completion changes.
|
||||||
|
@Output() statusChanged?: EventEmitter<any>; // Will emit an event when the download status changes.
|
||||||
|
|
||||||
downloadStatus: string;
|
downloadStatus: string;
|
||||||
canCheckUpdates: boolean;
|
canCheckUpdates: boolean;
|
||||||
|
@ -66,6 +67,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||||
protected eventsProvider: CoreEventsProvider, protected sitesProvider: CoreSitesProvider,
|
protected eventsProvider: CoreEventsProvider, protected sitesProvider: CoreSitesProvider,
|
||||||
protected courseProvider: CoreCourseProvider) {
|
protected courseProvider: CoreCourseProvider) {
|
||||||
this.completionChanged = new EventEmitter();
|
this.completionChanged = new EventEmitter();
|
||||||
|
this.statusChanged = new EventEmitter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +151,12 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
|
||||||
this.prefetchHandler.getDownloadSize(this.module, this.courseId, true).then((size) => {
|
this.prefetchHandler.getDownloadSize(this.module, this.courseId, true).then((size) => {
|
||||||
return this.courseHelper.prefetchModule(this.prefetchHandler, this.module, size, this.courseId, refresh);
|
return this.courseHelper.prefetchModule(this.prefetchHandler, this.module, size, this.courseId, refresh);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.courseHelper.calculateSectionStatus(this.section, this.courseId, false, false);
|
const eventData = {
|
||||||
|
sectionId: this.section.id,
|
||||||
|
moduleId: this.module.id,
|
||||||
|
courseId: this.courseId
|
||||||
|
};
|
||||||
|
this.statusChanged.emit(eventData);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
// Error, hide spinner.
|
// Error, hide spinner.
|
||||||
this.spinner = false;
|
this.spinner = false;
|
||||||
|
|
Loading…
Reference in New Issue