From 104beb7a1b6ef8f528c3b284f2b8a37d1e59da1f Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 5 Feb 2018 15:58:27 +0100 Subject: [PATCH] MOBILE-2335 course: Allow hiding enable download in course --- .../singleactivity/providers/handler.ts | 10 ++++++++++ src/core/course/pages/section/section.html | 2 +- src/core/course/pages/section/section.ts | 2 ++ src/core/course/providers/default-format.ts | 10 ++++++++++ src/core/course/providers/format-delegate.ts | 18 ++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/core/course/formats/singleactivity/providers/handler.ts b/src/core/course/formats/singleactivity/providers/handler.ts index 17f1a5734..ed7d44eef 100644 --- a/src/core/course/formats/singleactivity/providers/handler.ts +++ b/src/core/course/formats/singleactivity/providers/handler.ts @@ -62,6 +62,16 @@ export class CoreCourseFormatSingleActivityHandler implements CoreCourseFormatHa 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. * diff --git a/src/core/course/pages/section/section.html b/src/core/course/pages/section/section.html index dfefb39d7..8420d3fb3 100644 --- a/src/core/course/pages/section/section.html +++ b/src/core/course/pages/section/section.html @@ -4,7 +4,7 @@ - + diff --git a/src/core/course/pages/section/section.ts b/src/core/course/pages/section/section.ts index 633fa480f..d0cd1647c 100644 --- a/src/core/course/pages/section/section.ts +++ b/src/core/course/pages/section/section.ts @@ -53,6 +53,7 @@ export class CoreCourseSectionPage implements OnDestroy { prefetchCourseIcon: 'spinner' }; moduleId: number; + displayEnableDownload: boolean; protected module: any; protected completionObserver; @@ -73,6 +74,7 @@ export class CoreCourseSectionPage implements OnDestroy { // Get the title to display. We dont't have sections yet. this.title = courseFormatDelegate.getCourseTitle(this.course); + this.displayEnableDownload = courseFormatDelegate.displayEnableDownload(this.course); this.completionObserver = eventsProvider.on(CoreEventsProvider.COMPLETION_MODULE_VIEWED, (data) => { if (data && data.courseId == this.course.id) { diff --git a/src/core/course/providers/default-format.ts b/src/core/course/providers/default-format.ts index 7112efa56..2bf1991d1 100644 --- a/src/core/course/providers/default-format.ts +++ b/src/core/course/providers/default-format.ts @@ -56,6 +56,16 @@ export class CoreCourseFormatDefaultHandler implements CoreCourseFormatHandler { 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. * diff --git a/src/core/course/providers/format-delegate.ts b/src/core/course/providers/format-delegate.ts index 27553d52b..48d43bd34 100644 --- a/src/core/course/providers/format-delegate.ts +++ b/src/core/course/providers/format-delegate.ts @@ -43,6 +43,14 @@ export interface CoreCourseFormatHandler extends CoreDelegateHandler { */ 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. * @@ -150,6 +158,16 @@ export class CoreCourseFormatDelegate extends CoreDelegate { 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. *