MOBILE-3071 core: Let site plugins add menu items in course
parent
79cfc44e0d
commit
0b779f4ae8
|
@ -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<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
return {
|
||||
title: 'addon.blog.blog',
|
||||
class: 'addon-blog-handler',
|
||||
|
|
|
@ -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<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData?(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
getDisplayData?(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
return {
|
||||
title: 'addon.competency.competencies',
|
||||
class: 'addon-competency-course-handler',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData?(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData>;
|
||||
getDisplayData?(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData>;
|
||||
|
||||
/**
|
||||
* 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<CoreCourseOptionsMenuHandlerData>} Data or promise resolved with data.
|
||||
*/
|
||||
getMenuDisplayData(injector: Injector, courseId: number):
|
||||
getMenuDisplayData(injector: Injector, course: any):
|
||||
CoreCourseOptionsMenuHandlerData | Promise<CoreCourseOptionsMenuHandlerData>;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
return {
|
||||
title: 'core.grades.grades',
|
||||
class: 'core-grades-course-handler',
|
||||
|
|
|
@ -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<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
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<CoreCourseOptionsMenuHandlerData>} Data or promise resolved with data.
|
||||
*/
|
||||
getMenuDisplayData(injector: Injector, course: any):
|
||||
CoreCourseOptionsMenuHandlerData | Promise<CoreCourseOptionsMenuHandlerData> {
|
||||
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -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<CoreCourseOptionsHandlerData>} Data or promise resolved with the data.
|
||||
*/
|
||||
getDisplayData(injector: Injector, courseId: number): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
getDisplayData(injector: Injector, course: any): CoreCourseOptionsHandlerData | Promise<CoreCourseOptionsHandlerData> {
|
||||
return {
|
||||
title: 'core.user.participants',
|
||||
class: 'core-user-participants-handler',
|
||||
|
|
Loading…
Reference in New Issue