MOBILE-3068 glossary: Add more options to glossary links

main
Pau Ferrer Ocaña 2019-08-09 14:58:55 +02:00
parent 8a3acc2dfd
commit e270a1b1ff
2 changed files with 19 additions and 10 deletions

View File

@ -18,6 +18,7 @@ import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper'; import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreDomUtilsProvider } from '@providers/utils/dom';
import { AddonModGlossaryProvider } from './glossary';
/** /**
* Content links handler for glossary new entry. * Content links handler for glossary new entry.
@ -31,7 +32,7 @@ export class AddonModGlossaryEditLinkHandler extends CoreContentLinksHandlerBase
pattern = /\/mod\/glossary\/edit\.php.*([\?\&](cmid)=\d+)/; pattern = /\/mod\/glossary\/edit\.php.*([\?\&](cmid)=\d+)/;
constructor(private linkHelper: CoreContentLinksHelperProvider, private courseProvider: CoreCourseProvider, constructor(private linkHelper: CoreContentLinksHelperProvider, private courseProvider: CoreCourseProvider,
private domUtils: CoreDomUtilsProvider) { private domUtils: CoreDomUtilsProvider, private glossaryProvider: AddonModGlossaryProvider) {
super(); super();
} }
@ -53,14 +54,16 @@ export class AddonModGlossaryEditLinkHandler extends CoreContentLinksHandlerBase
cmId = parseInt(params.cmid, 10); cmId = parseInt(params.cmid, 10);
this.courseProvider.getModuleBasicInfo(cmId, siteId).then((module) => { this.courseProvider.getModuleBasicInfo(cmId, siteId).then((module) => {
const pageParams = { return this.glossaryProvider.getGlossary(module.course, module.id).then((glossary) => {
courseId: module.course, const pageParams = {
module: module, courseId: module.course,
glossary: module.module, module: module,
entry: null // It does not support entry editing. glossary: glossary,
}; entry: null // It does not support entry editing.
};
return this.linkHelper.goInSite(navCtrl, 'AddonModGlossaryEditPage', pageParams, siteId); this.linkHelper.goInSite(navCtrl, 'AddonModGlossaryEditPage', pageParams, siteId);
});
}).finally(() => { }).finally(() => {
// Just in case. In fact we need to dismiss the modal before showing a toast or error message. // Just in case. In fact we need to dismiss the modal before showing a toast or error message.
modal.dismiss(); modal.dismiss();

View File

@ -27,7 +27,7 @@ import { AddonModGlossaryProvider } from './glossary';
export class AddonModGlossaryEntryLinkHandler extends CoreContentLinksHandlerBase { export class AddonModGlossaryEntryLinkHandler extends CoreContentLinksHandlerBase {
name = 'AddonModGlossaryEntryLinkHandler'; name = 'AddonModGlossaryEntryLinkHandler';
featureName = 'CoreCourseModuleDelegate_AddonModGlossary'; featureName = 'CoreCourseModuleDelegate_AddonModGlossary';
pattern = /\/mod\/glossary\/showentry\.php.*([\&\?]eid=\d+)/; pattern = /\/mod\/glossary\/(showentry|view)\.php.*([\&\?](eid|g|mode|hook)=\d+)/;
constructor( constructor(
private domUtils: CoreDomUtilsProvider, private domUtils: CoreDomUtilsProvider,
@ -51,7 +51,13 @@ export class AddonModGlossaryEntryLinkHandler extends CoreContentLinksHandlerBas
return [{ return [{
action: (siteId, navCtrl?): void => { action: (siteId, navCtrl?): void => {
const modal = this.domUtils.showModalLoading(); const modal = this.domUtils.showModalLoading();
const entryId = parseInt(params.eid, 10); let entryId;
if (params.mode == 'entry') {
entryId = parseInt(params.hook, 10);
} else {
entryId = parseInt(params.eid, 10);
}
let promise; let promise;
if (courseId) { if (courseId) {