MOBILE-4081 wiki: Allow viewing empty subwikis

main
Dani Palou 2022-11-24 13:09:06 +01:00
parent 2ad9d2645c
commit 32d1e0761b
3 changed files with 8 additions and 18 deletions

View File

@ -638,14 +638,8 @@ 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;
}
goToSubwiki(subwikiId: number, userId: number, groupId: number): void {
if (subwikiId != this.currentSubwiki!.id || userId != this.currentSubwiki!.userid ||
groupId != this.currentSubwiki!.groupid) {
@ -828,7 +822,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 +831,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);
}
}

View File

@ -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>

View File

@ -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);
}
}