MOBILE-2335 course: Allow hiding enable download in course

main
Dani Palou 2018-02-05 15:58:27 +01:00
parent 577a0a6598
commit 104beb7a1b
5 changed files with 41 additions and 1 deletions

View File

@ -62,6 +62,16 @@ export class CoreCourseFormatSingleActivityHandler implements CoreCourseFormatHa
return course.fullname || ''; return course.fullname || '';
} }
/**
* Whether the option to enable section/module download should be displayed. Defaults to true.
*
* @param {any} course The course to check.
* @return {boolean} Whether the option to enable section/module download should be displayed
*/
displayEnableDownload(course: any): boolean {
return false;
}
/** /**
* Whether the default section selector should be displayed. Defaults to true. * Whether the default section selector should be displayed. Defaults to true.
* *

View File

@ -4,7 +4,7 @@
<ion-buttons end> <ion-buttons end>
<core-context-menu> <core-context-menu>
<core-context-menu-item [priority]="2000" [content]="'core.settings.enabledownloadsection' | translate" (action)="toggleDownload()" [iconAction]="downloadEnabledIcon"></core-context-menu-item> <core-context-menu-item *ngIf="displayEnableDownload" [priority]="2000" [content]="'core.settings.enabledownloadsection' | translate" (action)="toggleDownload()" [iconAction]="downloadEnabledIcon"></core-context-menu-item>
<core-context-menu-item [priority]="1900" [content]="'core.course.downloadcourse' | translate" (action)="prefetchCourse()" [iconAction]="prefetchCourseData.prefetchCourseIcon" [closeOnClick]="false"></core-context-menu-item> <core-context-menu-item [priority]="1900" [content]="'core.course.downloadcourse' | translate" (action)="prefetchCourse()" [iconAction]="prefetchCourseData.prefetchCourseIcon" [closeOnClick]="false"></core-context-menu-item>
</core-context-menu> </core-context-menu>
</ion-buttons> </ion-buttons>

View File

@ -53,6 +53,7 @@ export class CoreCourseSectionPage implements OnDestroy {
prefetchCourseIcon: 'spinner' prefetchCourseIcon: 'spinner'
}; };
moduleId: number; moduleId: number;
displayEnableDownload: boolean;
protected module: any; protected module: any;
protected completionObserver; protected completionObserver;
@ -73,6 +74,7 @@ export class CoreCourseSectionPage implements OnDestroy {
// 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);
this.displayEnableDownload = courseFormatDelegate.displayEnableDownload(this.course);
this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => { this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => {
if (data && data.courseId == this.course.id) { if (data && data.courseId == this.course.id) {

View File

@ -56,6 +56,16 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler {
return true; return true;
} }
/**
* Whether the option to enable section/module download should be displayed. Defaults to true.
*
* @param {any} course The course to check.
* @return {boolean} Whether the option to enable section/module download should be displayed
*/
displayEnableDownload(course: any): boolean {
return true;
}
/** /**
* Whether the default section selector should be displayed. Defaults to true. * Whether the default section selector should be displayed. Defaults to true.
* *

View File

@ -43,6 +43,14 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler {
*/ */
canViewAllSections?(course: any): boolean; canViewAllSections?(course: any): boolean;
/**
* Whether the option to enable section/module download should be displayed. Defaults to true.
*
* @param {any} course The course to check.
* @type {boolean} Whether the option to enable section/module download should be displayed.
*/
displayEnableDownload?(course: any): boolean;
/** /**
* Whether the default section selector should be displayed. Defaults to true. * Whether the default section selector should be displayed. Defaults to true.
* *
@ -150,6 +158,16 @@ export class CoreCourseFormatDelegate extends CoreDelegate {
return this.executeFunction(course.format, 'canViewAllSections', [course]); return this.executeFunction(course.format, 'canViewAllSections', [course]);
} }
/**
* Whether the option to enable section/module download should be displayed. Defaults to true.
*
* @param {any} course The course to check.
* @return {boolean} Whether the option to enable section/module download should be displayed
*/
displayEnableDownload(course: any): boolean {
return this.executeFunction(course.format, 'displayEnableDownload', [course]);
}
/** /**
* Whether the default section selector should be displayed. Defaults to true. * Whether the default section selector should be displayed. Defaults to true.
* *