diff --git a/src/addon/blog/providers/course-option-handler.ts b/src/addon/blog/providers/course-option-handler.ts index 9c28973fb..5617d6c92 100644 --- a/src/addon/blog/providers/course-option-handler.ts +++ b/src/addon/blog/providers/course-option-handler.ts @@ -78,10 +78,10 @@ export class AddonBlogCourseOptionHandler implements CoreCourseOptionsHandler { * Returns the data needed to render the handler. * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsHandlerData|Promise} Data or promise resolved with the data. */ - getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise { + getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise { return { title: 'addon.blog.blog', class: 'addon-blog-handler', diff --git a/src/addon/competency/providers/course-option-handler.ts b/src/addon/competency/providers/course-option-handler.ts index f05219300..2f8176995 100644 --- a/src/addon/competency/providers/course-option-handler.ts +++ b/src/addon/competency/providers/course-option-handler.ts @@ -63,10 +63,10 @@ export class AddonCompetencyCourseOptionHandler implements CoreCourseOptionsHand * Returns the data needed to render the handler. * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsHandlerData|Promise} Data or promise resolved with the data. */ - getDisplayData?(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise { + getDisplayData?(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise { return { title: 'addon.competency.competencies', class: 'addon-competency-course-handler', diff --git a/src/addon/storagemanager/providers/coursemenu-handler.ts b/src/addon/storagemanager/providers/coursemenu-handler.ts index e2aad3def..69a578fe0 100644 --- a/src/addon/storagemanager/providers/coursemenu-handler.ts +++ b/src/addon/storagemanager/providers/coursemenu-handler.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Injectable } from '@angular/core'; +import { Injectable, Injector } from '@angular/core'; import { CoreCourseOptionsMenuHandler, CoreCourseOptionsMenuHandlerData } from '@core/course/providers/options-delegate'; /** @@ -49,9 +49,11 @@ export class AddonStorageManagerCourseMenuHandler implements CoreCourseOptionsMe /** * Returns the data needed to render the handler. * + * @param {Injector} injector Injector. + * @param {any} course The course. * @return {CoreCourseOptionsMenuHandlerData} Data needed to render the handler. */ - getMenuDisplayData(): CoreCourseOptionsMenuHandlerData { + getMenuDisplayData(injector: Injector, course: any): CoreCourseOptionsMenuHandlerData { return { icon: 'cube', title: 'addon.storagemanager.managestorage', diff --git a/src/core/course/providers/options-delegate.ts b/src/core/course/providers/options-delegate.ts index cccfde281..b99cc7760 100644 --- a/src/core/course/providers/options-delegate.ts +++ b/src/core/course/providers/options-delegate.ts @@ -52,10 +52,10 @@ export interface CoreCourseOptionsHandler extends CoreDelegateHandler { * Returns the data needed to render the handler. * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsHandlerData|Promise} Data or promise resolved with the data. */ - getDisplayData?(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise; + getDisplayData?(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise; /** * Should invalidate the data to determine if the handler is enabled for a certain course. @@ -84,10 +84,10 @@ export interface CoreCourseOptionsMenuHandler extends CoreCourseOptionsHandler { * Returns the data needed to render the handler. * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsMenuHandlerData|Promise} Data or promise resolved with data. */ - getMenuDisplayData(injector: Injector, courseId: number): + getMenuDisplayData(injector: Injector, course: any): CoreCourseOptionsMenuHandlerData | Promise; } diff --git a/src/core/grades/providers/course-option-handler.ts b/src/core/grades/providers/course-option-handler.ts index ae04b5574..d544e4e85 100644 --- a/src/core/grades/providers/course-option-handler.ts +++ b/src/core/grades/providers/course-option-handler.ts @@ -80,10 +80,10 @@ export class CoreGradesCourseOptionHandler implements CoreCourseOptionsHandler { * Returns the data needed to render the handler. * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsHandlerData|Promise} Data or promise resolved with the data. */ - getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise { + getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise { return { title: 'core.grades.grades', class: 'core-grades-course-handler', diff --git a/src/core/siteplugins/classes/handlers/course-option-handler.ts b/src/core/siteplugins/classes/handlers/course-option-handler.ts index 0ecaa7515..e918ecf11 100644 --- a/src/core/siteplugins/classes/handlers/course-option-handler.ts +++ b/src/core/siteplugins/classes/handlers/course-option-handler.ts @@ -14,7 +14,9 @@ import { Injector } from '@angular/core'; import { CoreSitePluginsProvider } from '../../providers/siteplugins'; -import { CoreCourseOptionsHandler, CoreCourseOptionsHandlerData } from '@core/course/providers/options-delegate'; +import { + CoreCourseOptionsHandler, CoreCourseOptionsHandlerData, CoreCourseOptionsMenuHandlerData +} from '@core/course/providers/options-delegate'; import { CoreSitePluginsBaseHandler } from './base-handler'; import { CoreSitePluginsCourseOptionComponent } from '../../components/course-option/course-option'; @@ -23,12 +25,14 @@ import { CoreSitePluginsCourseOptionComponent } from '../../components/course-op */ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandler implements CoreCourseOptionsHandler { priority: number; + isMenuHandler: boolean; constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any, protected initResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) { super(name); this.priority = handlerSchema.priority; + this.isMenuHandler = !!handlerSchema.ismenuhandler; } /** @@ -46,13 +50,13 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl } /** - * Returns the data needed to render the handler. + * Returns the data needed to render the handler (if it isn't a menu handler). * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsHandlerData|Promise} Data or promise resolved with the data. */ - getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise { + getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise { return { title: this.title, class: this.handlerSchema.displaydata.class, @@ -63,6 +67,33 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl }; } + /** + * Returns the data needed to render the handler (if it's a menu handler). + * + * @param {Injector} injector Injector. + * @param {any} course The course. + * @return {CoreCourseOptionsMenuHandlerData|Promise} Data or promise resolved with data. + */ + getMenuDisplayData(injector: Injector, course: any): + CoreCourseOptionsMenuHandlerData | Promise { + + return { + title: this.title, + class: this.handlerSchema.displaydata.class, + icon: this.handlerSchema.displaydata.icon || '', + page: 'CoreSitePluginsPluginPage', + pageParams: { + title: this.title, + component: this.plugin.component, + method: this.handlerSchema.method, + args: { + courseid: course.id + }, + initResult: this.initResult + } + }; + } + /** * Called when a course is downloaded. It should prefetch all the data to be able to see the plugin in offline. * diff --git a/src/core/user/providers/course-option-handler.ts b/src/core/user/providers/course-option-handler.ts index 4f91bb0ff..9636dcfeb 100644 --- a/src/core/user/providers/course-option-handler.ts +++ b/src/core/user/providers/course-option-handler.ts @@ -79,10 +79,10 @@ export class CoreUserParticipantsCourseOptionHandler implements CoreCourseOption * Returns the data needed to render the handler. * * @param {Injector} injector Injector. - * @param {number} courseId The course ID. + * @param {number} course The course. * @return {CoreCourseOptionsHandlerData|Promise} Data or promise resolved with the data. */ - getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise { + getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise { return { title: 'core.user.participants', class: 'core-user-participants-handler',