MOBILE-3068 glossary: Add more options to glossary links
parent
8a3acc2dfd
commit
e270a1b1ff
|
@ -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) => {
|
||||||
|
return this.glossaryProvider.getGlossary(module.course, module.id).then((glossary) => {
|
||||||
const pageParams = {
|
const pageParams = {
|
||||||
courseId: module.course,
|
courseId: module.course,
|
||||||
module: module,
|
module: module,
|
||||||
glossary: module.module,
|
glossary: glossary,
|
||||||
entry: null // It does not support entry editing.
|
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();
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue