commit
b1bd54067c
|
@ -327,8 +327,8 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
|
||||
await this.showLoadingAndFetch(true, false);
|
||||
|
||||
if (this.currentPage) {
|
||||
CoreUtils.ignoreErrors(AddonModWiki.logPageView(this.currentPage, this.wiki!.id, this.wiki!.name));
|
||||
if (this.currentPage && this.wiki) {
|
||||
CoreUtils.ignoreErrors(AddonModWiki.logPageView(this.currentPage, this.wiki.id, this.wiki.name));
|
||||
}
|
||||
}, CoreSites.getCurrentSiteId());
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
|
||||
// If no page specified, search page title in the offline pages.
|
||||
if (!this.currentPage) {
|
||||
const searchTitle = this.pageTitle ? this.pageTitle : this.wiki!.firstpagetitle;
|
||||
const searchTitle = this.pageTitle ? this.pageTitle : this.wiki?.firstpagetitle ?? '';
|
||||
const pageExists = dbPages.some((page) => page.title == searchTitle);
|
||||
|
||||
if (pageExists) {
|
||||
|
@ -482,7 +482,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
`${AddonModWikiModuleHandlerService.PAGE_NAME}/${this.courseId}/${this.module.id}/edit`,
|
||||
{
|
||||
params: {
|
||||
pageTitle: this.wiki!.firstpagetitle,
|
||||
pageTitle: this.wiki?.firstpagetitle ?? '',
|
||||
wikiId: this.currentSubwiki?.wikiid,
|
||||
userId: this.currentSubwiki?.userid,
|
||||
groupId: this.currentSubwiki?.groupid,
|
||||
|
@ -638,17 +638,13 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
* @param subwikiId Subwiki ID.
|
||||
* @param userId User ID of the subwiki.
|
||||
* @param groupId Group ID of the subwiki.
|
||||
* @param canEdit Whether the subwiki can be edited.
|
||||
*/
|
||||
goToSubwiki(subwikiId: number, userId: number, groupId: number, canEdit: boolean): void {
|
||||
// Check if the subwiki is disabled.
|
||||
if (subwikiId <= 0 && !canEdit) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (subwikiId != this.currentSubwiki!.id || userId != this.currentSubwiki!.userid ||
|
||||
groupId != this.currentSubwiki!.groupid) {
|
||||
|
||||
goToSubwiki(subwikiId: number, userId: number, groupId: number): void {
|
||||
if (
|
||||
subwikiId !== this.currentSubwiki?.id ||
|
||||
userId !== this.currentSubwiki?.userid ||
|
||||
groupId !== this.currentSubwiki?.groupid
|
||||
) {
|
||||
this.openPageOrSubwiki({
|
||||
subwikiId: subwikiId,
|
||||
userId: userId,
|
||||
|
@ -716,13 +712,17 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
* @param result Data returned on the sync function.
|
||||
* @return If suceed or not.
|
||||
*/
|
||||
protected hasSyncSucceed(result: AddonModWikiSyncWikiResult): boolean {
|
||||
if (result.updated) {
|
||||
protected hasSyncSucceed(result: AddonModWikiSyncWikiResult | undefined): boolean {
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (result.updated && this.wiki) {
|
||||
// Trigger event.
|
||||
this.ignoreManualSyncEvent = true;
|
||||
CoreEvents.trigger(AddonModWikiSyncProvider.MANUAL_SYNCED, {
|
||||
...result,
|
||||
wikiId: this.wiki!.id,
|
||||
wikiId: this.wiki.id,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -828,7 +828,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
* @param event Event.
|
||||
*/
|
||||
async showSubwikiPicker(event: MouseEvent): Promise<void> {
|
||||
const popoverData = await CoreDomUtils.openPopover<AddonModWikiSubwiki>({
|
||||
const subwiki = await CoreDomUtils.openPopover<AddonModWikiSubwiki>({
|
||||
component: AddonModWikiSubwikiPickerComponent,
|
||||
componentProps: {
|
||||
subwikis: this.subwikiData.subwikis,
|
||||
|
@ -837,8 +837,8 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
event,
|
||||
});
|
||||
|
||||
if (popoverData) {
|
||||
this.goToSubwiki(popoverData.id, popoverData.userid, popoverData.groupid, popoverData.canedit);
|
||||
if (subwiki) {
|
||||
this.goToSubwiki(subwiki.id, subwiki.userid, subwiki.groupid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -847,8 +847,12 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
*
|
||||
* @return Promise resolved when done.
|
||||
*/
|
||||
protected sync(): Promise<AddonModWikiSyncWikiResult> {
|
||||
return AddonModWikiSync.syncWiki(this.wiki!.id, this.courseId, this.wiki!.coursemodule);
|
||||
protected async sync(): Promise<AddonModWikiSyncWikiResult | undefined> {
|
||||
if (!this.wiki) {
|
||||
return;
|
||||
}
|
||||
|
||||
return AddonModWikiSync.syncWiki(this.wiki.id, this.courseId, this.wiki.coursemodule);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1069,14 +1073,16 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp
|
|||
this.subwikiData.subwikis.push({ label: '', subwikis: subwikiList });
|
||||
}
|
||||
|
||||
AddonModWiki.setSubwikiList(
|
||||
this.wiki!.id,
|
||||
this.subwikiData.subwikis,
|
||||
this.subwikiData.count,
|
||||
this.subwikiData.subwikiSelected,
|
||||
this.subwikiData.userSelected,
|
||||
this.subwikiData.groupSelected,
|
||||
);
|
||||
if (this.wiki) {
|
||||
AddonModWiki.setSubwikiList(
|
||||
this.wiki.id,
|
||||
this.subwikiData.subwikis,
|
||||
this.subwikiData.count,
|
||||
this.subwikiData.subwikiSelected,
|
||||
this.subwikiData.userSelected,
|
||||
this.subwikiData.groupSelected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
<h2>{{ group.label }}</h2>
|
||||
</ion-label>
|
||||
</ion-item-divider>
|
||||
<ion-item class="ion-text-wrap" *ngFor="let subwiki of group.subwikis" (click)="openSubwiki(subwiki)"
|
||||
[attr.disabled]="!subwiki.canedit && subwiki.id <= 0" [button]="subwiki.canedit || subwiki.id > 0"
|
||||
<ion-item class="ion-text-wrap" *ngFor="let subwiki of group.subwikis" (click)="openSubwiki(subwiki)" button
|
||||
[attr.aria-current]="isSubwikiSelected(subwiki) ? 'page' : 'false'" detail="false">
|
||||
<ion-label>{{ subwiki.name }}</ion-label>
|
||||
<ion-icon *ngIf="isSubwikiSelected(subwiki)" name="fas-check" slot="end" aria-hidden="true"></ion-icon>
|
||||
|
|
|
@ -49,12 +49,9 @@ export class AddonModWikiSubwikiPickerComponent {
|
|||
* @param subwiki The subwiki to open.
|
||||
*/
|
||||
openSubwiki(subwiki: AddonModWikiSubwiki): void {
|
||||
// Check if the subwiki is disabled.
|
||||
if (subwiki.id > 0 || subwiki.canedit) {
|
||||
// Check if it isn't current subwiki.
|
||||
if (subwiki != this.currentSubwiki) {
|
||||
PopoverController.dismiss(subwiki);
|
||||
}
|
||||
// Check if it isn't current subwiki.
|
||||
if (subwiki !== this.currentSubwiki) {
|
||||
PopoverController.dismiss(subwiki);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave {
|
|||
this.userId = CoreNavigator.getRouteNumberParam('userId');
|
||||
|
||||
let pageTitle = CoreNavigator.getRouteParam<string>('pageTitle');
|
||||
pageTitle = pageTitle ? pageTitle.replace(/\+/g, ' ') : '';
|
||||
pageTitle = pageTitle ? CoreTextUtils.cleanTags(pageTitle.replace(/\+/g, ' '), true) : '';
|
||||
|
||||
this.canEditTitle = !pageTitle;
|
||||
this.title = pageTitle ?
|
||||
|
|
|
@ -958,18 +958,12 @@ export class CoreSite {
|
|||
// Call the WS.
|
||||
const initialToken = this.token ?? '';
|
||||
|
||||
// Call the WS.
|
||||
if (method !== 'core_webservice_get_site_info') {
|
||||
// Send the language to use. Do it after checking cache to prevent losing offline data when changing language.
|
||||
// Don't send it to core_webservice_get_site_info, that WS is used to check if Moodle version is supported.
|
||||
data = {
|
||||
...data,
|
||||
moodlewssettinglang: preSets.lang ?? await CoreLang.getCurrentLanguage(),
|
||||
};
|
||||
// Moodle uses underscore instead of dash.
|
||||
data.moodlewssettinglang = data.moodlewssettinglang.replace('-', '_');
|
||||
|
||||
}
|
||||
// Send the language to use. Do it after checking cache to prevent losing offline data when changing language.
|
||||
// Moodle uses underscore instead of dash.
|
||||
data = {
|
||||
...data,
|
||||
moodlewssettinglang: (preSets.lang ?? await CoreLang.getCurrentLanguage()).replace('-', '_'),
|
||||
};
|
||||
|
||||
try {
|
||||
return await this.callOrEnqueueRequest<T>(method, data, preSets, wsPreSets);
|
||||
|
@ -988,6 +982,14 @@ export class CoreSite {
|
|||
}
|
||||
}
|
||||
|
||||
if (error?.errorcode === 'invalidparameter' && method === 'core_webservice_get_site_info') {
|
||||
// Retry without passing the lang, this parameter isn't supported in 3.4 or older sites
|
||||
// and we need this WS call to be able to determine if the site is supported or not.
|
||||
delete data.moodlewssettinglang;
|
||||
|
||||
return await this.callOrEnqueueRequest<T>(method, data, preSets, wsPreSets);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue