diff --git a/src/addons/mod/folder/services/handlers/module.ts b/src/addons/mod/folder/services/handlers/module.ts index 63dbc0df4..df0e666d7 100644 --- a/src/addons/mod/folder/services/handlers/module.ts +++ b/src/addons/mod/folder/services/handlers/module.ts @@ -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 { + 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 => { + 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 */ diff --git a/src/core/features/course/components/module-summary/module-summary.html b/src/core/features/course/components/module-summary/module-summary.html index 8bd270c5e..8c765e04e 100644 --- a/src/core/features/course/components/module-summary/module-summary.html +++ b/src/core/features/course/components/module-summary/module-summary.html @@ -24,8 +24,8 @@ - +