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
parent
689a36ac12
commit
c1afc4b614
|
@ -15,7 +15,10 @@
|
||||||
import { CoreConstants, ModPurpose } from '@/core/constants';
|
import { CoreConstants, ModPurpose } from '@/core/constants';
|
||||||
import { Injectable, Type } from '@angular/core';
|
import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
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 { makeSingleton } from '@singletons';
|
||||||
import { AddonModFolderIndexComponent } from '../../components/index';
|
import { AddonModFolderIndexComponent } from '../../components/index';
|
||||||
|
|
||||||
|
@ -44,6 +47,41 @@ export class AddonModFolderModuleHandlerService extends CoreModuleHandlerBase im
|
||||||
[CoreConstants.FEATURE_MOD_PURPOSE]: ModPurpose.MOD_PURPOSE_CONTENT,
|
[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
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
</core-format-text>
|
</core-format-text>
|
||||||
</h1>
|
</h1>
|
||||||
</ion-label>
|
</ion-label>
|
||||||
<ion-button fill="clear" *ngIf="displayOptions.displayOpenInBrowser" [href]="externalUrl" core-link [showBrowserWarning]="false"
|
<ion-button fill="clear" *ngIf="displayOptions.displayOpenInBrowser && externalUrl" [href]="externalUrl" core-link
|
||||||
[attr.aria-label]="'core.openinbrowser' | translate" slot="end">
|
[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-icon name="fas-external-link-alt" slot="icon-only" aria-hidden="true"></ion-icon>
|
||||||
</ion-button>
|
</ion-button>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
Loading…
Reference in New Issue