MOBILE-3218 links: Implement all index handlers enabled on activity
parent
ed1fc4c09d
commit
30e6feab24
|
@ -16,6 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||
import { AddonModBookProvider } from './book';
|
||||
|
||||
/**
|
||||
* Handler to treat links to book.
|
||||
|
@ -24,7 +25,8 @@ import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
|||
export class AddonModBookLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModBookLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected bookProvider: AddonModBookProvider) {
|
||||
super(courseHelper, 'AddonModBook', 'book');
|
||||
}
|
||||
|
||||
|
@ -50,4 +52,17 @@ export class AddonModBookLinkHandler extends CoreContentLinksModuleIndexHandler
|
|||
}
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.bookProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModDataProvider } from './data';
|
||||
|
||||
/**
|
||||
* Handler to treat links to data.
|
||||
|
@ -23,7 +24,21 @@ import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|||
export class AddonModDataLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModDataLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected dataProvider: AddonModDataProvider) {
|
||||
super(courseHelper, 'AddonModData', 'data');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.dataProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModFeedbackProvider } from './feedback';
|
||||
|
||||
/**
|
||||
* Handler to treat links to feedback.
|
||||
|
@ -23,7 +24,21 @@ import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|||
export class AddonModFeedbackLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModFeedbackLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected feedbackProvider: AddonModFeedbackProvider) {
|
||||
super(courseHelper, 'AddonModFeedback', 'feedback');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.feedbackProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModForumProvider } from './forum';
|
||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
|
@ -27,7 +26,7 @@ import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
|||
export class AddonModForumIndexLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModForumIndexLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider, protected forumProvider: AddonModForumProvider,
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider) {
|
||||
super(courseHelper, 'AddonModForum', 'forum');
|
||||
|
||||
|
@ -35,20 +34,6 @@ export class AddonModForumIndexLinkHandler extends CoreContentLinksModuleIndexHa
|
|||
this.pattern = new RegExp('\/mod\/forum\/view\.php.*([\&\?](f|id)=\\d+)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of actions for a link (url).
|
||||
*
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModImscpProvider } from './imscp';
|
||||
|
||||
/**
|
||||
* Handler to treat links to IMSCP.
|
||||
|
@ -23,7 +24,21 @@ import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|||
export class AddonModImscpLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModImscpLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected imscpProvider: AddonModImscpProvider) {
|
||||
super(courseHelper, 'AddonModImscp', 'imscp');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.imscpProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModPageProvider } from './page';
|
||||
|
||||
/**
|
||||
* Handler to treat links to resource.
|
||||
|
@ -23,7 +24,21 @@ import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|||
export class AddonModPageLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModPageLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected pageProvider: AddonModPageProvider) {
|
||||
super(courseHelper, 'AddonModPage', 'page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.pageProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,18 +27,4 @@ export class AddonModQuizIndexLinkHandler extends CoreContentLinksModuleIndexHan
|
|||
constructor(courseHelper: CoreCourseHelperProvider, protected quizProvider: AddonModQuizProvider) {
|
||||
super(courseHelper, 'AddonModQuiz', 'quiz');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
* If not defined, defaults to true.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.quizProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@core/contentlinks/classes/module-index-handler';
|
||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||
import { AddonModResourceProvider } from './resource';
|
||||
|
||||
/**
|
||||
* Handler to treat links to resource.
|
||||
|
@ -23,7 +24,21 @@ import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
|||
export class AddonModResourceLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModResourceLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected resourceProvider: AddonModResourceProvider) {
|
||||
super(courseHelper, 'AddonModResource', 'resource');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.resourceProvider.isPluginEnabled();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,21 @@ import { AddonModWorkshopProvider } from './workshop';
|
|||
export class AddonModWorkshopLinkHandler extends CoreContentLinksModuleIndexHandler {
|
||||
name = 'AddonModWorkshopLinkHandler';
|
||||
|
||||
constructor(courseHelper: CoreCourseHelperProvider) {
|
||||
constructor(courseHelper: CoreCourseHelperProvider,
|
||||
protected workshopProvider: AddonModWorkshopProvider) {
|
||||
super(courseHelper, AddonModWorkshopProvider.COMPONENT, 'workshop');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the handler is enabled for a certain site (site + user) and a URL.
|
||||
*
|
||||
* @param siteId The site ID.
|
||||
* @param url The URL to treat.
|
||||
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
|
||||
* @param courseId Course ID related to the URL. Optional but recommended.
|
||||
* @return Whether the handler is enabled for the URL and site.
|
||||
*/
|
||||
isEnabled(siteId: string, url: string, params: any, courseId?: number): boolean | Promise<boolean> {
|
||||
return this.workshopProvider.isPluginEnabled(siteId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue