MOBILE-3779 wiki: Handle params in wiki index link
parent
9a63793cf2
commit
cb5bde99da
|
@ -350,12 +350,20 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
cmId: this.module.id,
|
||||
});
|
||||
|
||||
// If no page specified, search first page.
|
||||
if (!this.currentPage && !this.pageTitle) {
|
||||
const firstPage = subwikiPages.find((page) => page.firstpage );
|
||||
if (firstPage) {
|
||||
this.currentPage = firstPage.id;
|
||||
this.pageTitle = firstPage.title;
|
||||
if (!this.currentPage) {
|
||||
if (!this.pageTitle) {
|
||||
// No page specified, search first page.
|
||||
const firstPage = subwikiPages.find((page) => page.firstpage );
|
||||
if (firstPage) {
|
||||
this.currentPage = firstPage.id;
|
||||
this.pageTitle = firstPage.title;
|
||||
}
|
||||
} else {
|
||||
// Got the page title but not its ID. Search the page.
|
||||
const page = subwikiPages.find((page) => page.title === this.pageTitle );
|
||||
if (page) {
|
||||
this.currentPage = page.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Params } from '@angular/router';
|
||||
import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
|
@ -28,6 +29,17 @@ export class AddonModWikiIndexLinkHandlerService extends CoreContentLinksModuleI
|
|||
super('AddonModWiki', 'wiki', 'wid');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
getPageParams(url: string, params: Record<string, string>): Params {
|
||||
return {
|
||||
groupId: params.group || params.group === '0' ? Number(params.group) : undefined,
|
||||
userId: params.uid || params.uid === '0' ? Number(params.uid) : undefined,
|
||||
pageTitle: params.title,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const AddonModWikiIndexLinkHandler = makeSingleton(AddonModWikiIndexLinkHandlerService);
|
||||
|
|
|
@ -335,7 +335,10 @@ export class AddonModWikiProvider {
|
|||
|
||||
const response = await site.read<AddonModWikiGetSubwikisWSResponse>('mod_wiki_get_subwikis', params, preSets);
|
||||
|
||||
return response.subwikis;
|
||||
return response.subwikis.map(subwiki => ({
|
||||
...subwiki,
|
||||
groupid: Number(subwiki.groupid), // Convert groupid to number.
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1112,21 +1115,28 @@ export type AddonModWikiGetSubwikisWSParams = {
|
|||
* Data returned by mod_wiki_get_subwikis WS.
|
||||
*/
|
||||
export type AddonModWikiGetSubwikisWSResponse = {
|
||||
subwikis: AddonModWikiSubwiki[];
|
||||
subwikis: AddonModWikiSubwikiWSData[];
|
||||
warnings?: CoreWSExternalWarning[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Subwiki data returned by mod_wiki_get_subwikis WS.
|
||||
*/
|
||||
export type AddonModWikiSubwiki = {
|
||||
export type AddonModWikiSubwikiWSData = {
|
||||
id: number; // Subwiki ID.
|
||||
wikiid: number; // Wiki ID.
|
||||
groupid: number; // Group ID.
|
||||
groupid: string; // Group ID.
|
||||
userid: number; // User ID.
|
||||
canedit: boolean; // True if user can edit the subwiki.
|
||||
};
|
||||
|
||||
/**
|
||||
* Subwiki data with some calculated data.
|
||||
*/
|
||||
export type AddonModWikiSubwiki = Omit<AddonModWikiSubwikiWSData, 'groupid'> & {
|
||||
groupid: number; // Group ID.
|
||||
};
|
||||
|
||||
/**
|
||||
* Params of mod_wiki_get_wikis_by_courses WS.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue