MOBILE-2201 glossary: Tag area handler for glossary entries

main
Albert Gasset 2019-07-08 12:18:27 +02:00
parent f1591b1113
commit 0a770f8528
5 changed files with 68 additions and 3 deletions

View File

@ -588,6 +588,7 @@
"addon.mod_glossary.modulenameplural": "glossary", "addon.mod_glossary.modulenameplural": "glossary",
"addon.mod_glossary.noentriesfound": "local_moodlemobileapp", "addon.mod_glossary.noentriesfound": "local_moodlemobileapp",
"addon.mod_glossary.searchquery": "local_moodlemobileapp", "addon.mod_glossary.searchquery": "local_moodlemobileapp",
"addon.mod_glossary.tagarea_glossary_entries": "glossary",
"addon.mod_imscp.deploymenterror": "imscp", "addon.mod_imscp.deploymenterror": "imscp",
"addon.mod_imscp.modulenameplural": "imscp", "addon.mod_imscp.modulenameplural": "imscp",
"addon.mod_imscp.showmoduledescription": "local_moodlemobileapp", "addon.mod_imscp.showmoduledescription": "local_moodlemobileapp",

View File

@ -17,6 +17,7 @@ import { CoreCronDelegate } from '@providers/cron';
import { CoreCourseModuleDelegate } from '@core/course/providers/module-delegate'; import { CoreCourseModuleDelegate } from '@core/course/providers/module-delegate';
import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate'; import { CoreCourseModulePrefetchDelegate } from '@core/course/providers/module-prefetch-delegate';
import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate'; import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate';
import { CoreTagAreaDelegate } from '@core/tag/providers/area-delegate';
import { AddonModGlossaryProvider } from './providers/glossary'; import { AddonModGlossaryProvider } from './providers/glossary';
import { AddonModGlossaryOfflineProvider } from './providers/offline'; import { AddonModGlossaryOfflineProvider } from './providers/offline';
import { AddonModGlossaryHelperProvider } from './providers/helper'; import { AddonModGlossaryHelperProvider } from './providers/helper';
@ -28,6 +29,7 @@ import { AddonModGlossaryIndexLinkHandler } from './providers/index-link-handler
import { AddonModGlossaryEntryLinkHandler } from './providers/entry-link-handler'; import { AddonModGlossaryEntryLinkHandler } from './providers/entry-link-handler';
import { AddonModGlossaryListLinkHandler } from './providers/list-link-handler'; import { AddonModGlossaryListLinkHandler } from './providers/list-link-handler';
import { AddonModGlossaryEditLinkHandler } from './providers/edit-link-handler'; import { AddonModGlossaryEditLinkHandler } from './providers/edit-link-handler';
import { AddonModGlossaryTagAreaHandler } from './providers/tag-area-handler';
import { AddonModGlossaryComponentsModule } from './components/components.module'; import { AddonModGlossaryComponentsModule } from './components/components.module';
import { CoreUpdateManagerProvider } from '@providers/update-manager'; import { CoreUpdateManagerProvider } from '@providers/update-manager';
@ -56,7 +58,8 @@ export const ADDON_MOD_GLOSSARY_PROVIDERS: any[] = [
AddonModGlossaryIndexLinkHandler, AddonModGlossaryIndexLinkHandler,
AddonModGlossaryEntryLinkHandler, AddonModGlossaryEntryLinkHandler,
AddonModGlossaryListLinkHandler, AddonModGlossaryListLinkHandler,
AddonModGlossaryEditLinkHandler AddonModGlossaryEditLinkHandler,
AddonModGlossaryTagAreaHandler
] ]
}) })
export class AddonModGlossaryModule { export class AddonModGlossaryModule {
@ -65,7 +68,8 @@ export class AddonModGlossaryModule {
cronDelegate: CoreCronDelegate, syncHandler: AddonModGlossarySyncCronHandler, linksDelegate: CoreContentLinksDelegate, cronDelegate: CoreCronDelegate, syncHandler: AddonModGlossarySyncCronHandler, linksDelegate: CoreContentLinksDelegate,
indexHandler: AddonModGlossaryIndexLinkHandler, discussionHandler: AddonModGlossaryEntryLinkHandler, indexHandler: AddonModGlossaryIndexLinkHandler, discussionHandler: AddonModGlossaryEntryLinkHandler,
updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModGlossaryListLinkHandler, updateManager: CoreUpdateManagerProvider, listLinkHandler: AddonModGlossaryListLinkHandler,
editLinkHandler: AddonModGlossaryEditLinkHandler) { editLinkHandler: AddonModGlossaryEditLinkHandler, tagAreaDelegate: CoreTagAreaDelegate,
tagAreaHandler: AddonModGlossaryTagAreaHandler) {
moduleDelegate.registerHandler(moduleHandler); moduleDelegate.registerHandler(moduleHandler);
prefetchDelegate.registerHandler(prefetchHandler); prefetchDelegate.registerHandler(prefetchHandler);
@ -74,6 +78,7 @@ export class AddonModGlossaryModule {
linksDelegate.registerHandler(discussionHandler); linksDelegate.registerHandler(discussionHandler);
linksDelegate.registerHandler(listLinkHandler); linksDelegate.registerHandler(listLinkHandler);
linksDelegate.registerHandler(editLinkHandler); linksDelegate.registerHandler(editLinkHandler);
tagAreaDelegate.registerHandler(tagAreaHandler);
// Allow migrating the tables from the old app to the new schema. // Allow migrating the tables from the old app to the new schema.
updateManager.registerSiteTableMigration({ updateManager.registerSiteTableMigration({

View File

@ -26,5 +26,6 @@
"linking": "Auto-linking", "linking": "Auto-linking",
"modulenameplural": "Glossaries", "modulenameplural": "Glossaries",
"noentriesfound": "No entries were found.", "noentriesfound": "No entries were found.",
"searchquery": "Search query" "searchquery": "Search query",
"tagarea_glossary_entries": "Glossary entries"
} }

View File

@ -0,0 +1,57 @@
// (C) Copyright 2015 Martin Dougiamas
//
// 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, Injector } from '@angular/core';
import { CoreTagAreaHandler } from '@core/tag/providers/area-delegate';
import { CoreTagHelperProvider } from '@core/tag/providers/helper';
import { CoreTagFeedComponent } from '@core/tag/components/feed/feed';
/**
* Handler to support tags.
*/
@Injectable()
export class AddonModGlossaryTagAreaHandler implements CoreTagAreaHandler {
name = 'AddonModGlossaryTagAreaHandler';
type = 'mod_glossary/glossary_entries';
constructor(private tagHelper: CoreTagHelperProvider) {}
/**
* Whether or not the handler is enabled on a site level.
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return true;
}
/**
* Parses the rendered content of a tag index and returns the items.
*
* @param {string} content Rendered content.
* @return {any[]|Promise<any[]>} Area items (or promise resolved with the items).
*/
parseContent(content: string): any[] | Promise<any[]> {
return this.tagHelper.parseFeedContent(content);
}
/**
* Get the component to use to display items.
*
* @param {Injector} injector Injector.
* @return {any|Promise<any>} The component (or promise resolved with component) to use, undefined if not found.
*/
getComponent(injector: Injector): any | Promise<any> {
return CoreTagFeedComponent;
}
}

View File

@ -588,6 +588,7 @@
"addon.mod_glossary.modulenameplural": "Glossaries", "addon.mod_glossary.modulenameplural": "Glossaries",
"addon.mod_glossary.noentriesfound": "No entries were found.", "addon.mod_glossary.noentriesfound": "No entries were found.",
"addon.mod_glossary.searchquery": "Search query", "addon.mod_glossary.searchquery": "Search query",
"addon.mod_glossary.tagarea_glossary_entries": "Glossary entries",
"addon.mod_imscp.deploymenterror": "Content package error!", "addon.mod_imscp.deploymenterror": "Content package error!",
"addon.mod_imscp.modulenameplural": "IMS content packages", "addon.mod_imscp.modulenameplural": "IMS content packages",
"addon.mod_imscp.showmoduledescription": "Show description", "addon.mod_imscp.showmoduledescription": "Show description",