diff --git a/src/addons/mod/forum/forum.module.ts b/src/addons/mod/forum/forum.module.ts index 4fbe6e626..cc6cc3b7c 100644 --- a/src/addons/mod/forum/forum.module.ts +++ b/src/addons/mod/forum/forum.module.ts @@ -34,6 +34,8 @@ import { AddonModForumDiscussionLinkHandler } from './services/handlers/discussi import { AddonModForumIndexLinkHandler } from './services/handlers/index-link'; import { AddonModForumListLinkHandler } from './services/handlers/list-link'; import { AddonModForumPostLinkHandler } from './services/handlers/post-link'; +import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate'; +import { AddonModForumTagAreaHandler } from './services/handlers/tag-area'; const mainMenuRoutes: Routes = [ { @@ -94,6 +96,7 @@ const courseContentsRoutes: Routes = conditionalRoutes( CoreContentLinksDelegate.instance.registerHandler(AddonModForumIndexLinkHandler.instance); CoreContentLinksDelegate.instance.registerHandler(AddonModForumListLinkHandler.instance); CoreContentLinksDelegate.instance.registerHandler(AddonModForumPostLinkHandler.instance); + CoreTagAreaDelegate.instance.registerHandler(AddonModForumTagAreaHandler.instance); }, }, ], diff --git a/src/addons/mod/forum/services/handlers/tag-area.ts b/src/addons/mod/forum/services/handlers/tag-area.ts new file mode 100644 index 000000000..f93819405 --- /dev/null +++ b/src/addons/mod/forum/services/handlers/tag-area.ts @@ -0,0 +1,62 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import { Injectable, Type } from '@angular/core'; + +import { CoreTagAreaHandler } from '@features/tag/services/tag-area-delegate'; +import { CoreTagFeedComponent } from '@features/tag/components/feed/feed'; +import { CoreTagHelper, CoreTagFeedElement } from '@features/tag/services/tag-helper'; +import { makeSingleton } from '@singletons'; + +/** + * Handler to support tags. + */ +@Injectable({ providedIn: 'root' }) +export class AddonModForumTagAreaHandlerService implements CoreTagAreaHandler { + + name = 'AddonModForumTagAreaHandler'; + type = 'mod_forum/forum_posts'; + + /** + * Whether or not the handler is enabled on a site level. + * + * @return Whether or not the handler is enabled on a site level. + */ + async isEnabled(): Promise { + return true; + } + + /** + * Parses the rendered content of a tag index and returns the items. + * + * @param content Rendered content. + * @return Area items (or promise resolved with the items). + */ + parseContent(content: string): CoreTagFeedElement[] { + return CoreTagHelper.instance.parseFeedContent(content); + } + + /** + * Get the component to use to display items. + * + * @param injector Injector. + * @return The component (or promise resolved with component) to use, undefined if not found. + */ + getComponent(): Type | Promise> { + return CoreTagFeedComponent; + } + +} + +export class AddonModForumTagAreaHandler extends makeSingleton(AddonModForumTagAreaHandlerService) {}