MOBILE-4084 folder: Restore access to inline folders

Add temporary fix to restore access to inline folders.
Change module description to exclude inline folder data.
main
Anastasios Bithas 2022-06-13 20:58:00 +03:00 committed by Pau Ferrer Ocaña
parent 689a36ac12
commit c1afc4b614
2 changed files with 41 additions and 3 deletions

View File

@ -15,7 +15,10 @@
import { CoreConstants, ModPurpose } from '@/core/constants';
import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { CoreCourseModuleData } from '@features/course/services/course-helper';
import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate';
import { CoreNavigator } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons';
import { AddonModFolderIndexComponent } from '../../components/index';
@ -44,6 +47,41 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im
[CoreConstants.FEATURE_MOD_PURPOSE]: ModPurpose.MOD_PURPOSE_CONTENT,
};
/**
* @inheritdoc
*/
async getData(
module: CoreCourseModuleData,
courseId: number,
sectionId?: number,
forCoursePage?: boolean,
): Promise<CoreCourseModuleHandlerData> {
const data = await super.getData(module, courseId, sectionId, forCoursePage);
if (module.description) {
// Module description can contain the folder contents if it's inline, remove it.
const descriptionElement = CoreDomUtils.convertToElement(module.description);
Array.from(descriptionElement.querySelectorAll('.foldertree, .folderbuttons, .tertiary-navigation'))
.forEach(element => element.remove());
module.description = descriptionElement.innerHTML;
}
// @todo: Temporary fix to open inline folders. We should use a more generic solution.
data.action = async (event, module, courseId, options): Promise<void> => {
options = options || {};
options.params = options.params || {};
Object.assign(options.params, { module });
const routeParams = '/' + courseId + '/' + module.id;
await CoreNavigator.navigateToSitePath(this.pageName + routeParams, options);
};
return data;
}
/**
* @inheritdoc
*/

View File

@ -24,8 +24,8 @@
</core-format-text>
</h1>
</ion-label>
<ion-button fill="clear" *ngIf="displayOptions.displayOpenInBrowser" [href]="externalUrl" core-link [showBrowserWarning]="false"
[attr.aria-label]="'core.openinbrowser' | translate" slot="end">
<ion-button fill="clear" *ngIf="displayOptions.displayOpenInBrowser && externalUrl" [href]="externalUrl" core-link
[showBrowserWarning]="false" [attr.aria-label]="'core.openinbrowser' | translate" slot="end">
<ion-icon name="fas-external-link-alt" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</ion-item>