MOBILE-3643 forum: Migrate tag-area handler
parent
bf8b33fa61
commit
bc72e93a78
|
@ -34,6 +34,8 @@ import { AddonModForumDiscussionLinkHandler } from './services/handlers/discussi
|
||||||
import { AddonModForumIndexLinkHandler } from './services/handlers/index-link';
|
import { AddonModForumIndexLinkHandler } from './services/handlers/index-link';
|
||||||
import { AddonModForumListLinkHandler } from './services/handlers/list-link';
|
import { AddonModForumListLinkHandler } from './services/handlers/list-link';
|
||||||
import { AddonModForumPostLinkHandler } from './services/handlers/post-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 = [
|
const mainMenuRoutes: Routes = [
|
||||||
{
|
{
|
||||||
|
@ -94,6 +96,7 @@ const courseContentsRoutes: Routes = conditionalRoutes(
|
||||||
CoreContentLinksDelegate.instance.registerHandler(AddonModForumIndexLinkHandler.instance);
|
CoreContentLinksDelegate.instance.registerHandler(AddonModForumIndexLinkHandler.instance);
|
||||||
CoreContentLinksDelegate.instance.registerHandler(AddonModForumListLinkHandler.instance);
|
CoreContentLinksDelegate.instance.registerHandler(AddonModForumListLinkHandler.instance);
|
||||||
CoreContentLinksDelegate.instance.registerHandler(AddonModForumPostLinkHandler.instance);
|
CoreContentLinksDelegate.instance.registerHandler(AddonModForumPostLinkHandler.instance);
|
||||||
|
CoreTagAreaDelegate.instance.registerHandler(AddonModForumTagAreaHandler.instance);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -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<boolean> {
|
||||||
|
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<unknown> | Promise<Type<unknown>> {
|
||||||
|
return CoreTagFeedComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AddonModForumTagAreaHandler extends makeSingleton(AddonModForumTagAreaHandlerService) {}
|
Loading…
Reference in New Issue