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