diff --git a/src/core/features/course/course-lazy.module.ts b/src/core/features/course/course-lazy.module.ts index 691b8c05b..f3698f814 100644 --- a/src/core/features/course/course-lazy.module.ts +++ b/src/core/features/course/course-lazy.module.ts @@ -14,6 +14,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { CoreCourseHelper } from './services/course-helper'; export const COURSE_INDEX_PATH = ':courseId'; @@ -33,8 +34,7 @@ const routes: Routes = [ }, { path: ':courseId/summary', - loadChildren: () => - import('./pages/course-summary/course-summary.module').then(m => m.CoreCourseSummaryPageModule), + loadChildren: () => CoreCourseHelper.getCourseSummaryRouteModule(), }, ]; diff --git a/src/core/features/course/pages/index/index.ts b/src/core/features/course/pages/index/index.ts index 462a97c56..b17570ba6 100644 --- a/src/core/features/course/pages/index/index.ts +++ b/src/core/features/course/pages/index/index.ts @@ -26,7 +26,6 @@ import { CoreUtils } from '@services/utils/utils'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CONTENTS_PAGE_NAME } from '@features/course/course.module'; import { CoreDomUtils } from '@services/utils/dom'; -import { CoreCourseSummaryPage } from '../course-summary/course-summary'; import { CoreCoursesHelper, CoreCourseWithImageAndColor } from '@features/courses/services/courses-helper'; import { CoreColors } from '@singletons/colors'; import { CoreText } from '@singletons/text'; @@ -288,17 +287,9 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy { * Open the course summary */ openCourseSummary(): void { - if (!this.course) { - return; + if (this.course) { + CoreCourseHelper.openCourseSummary(this.course); } - - CoreDomUtils.openSideModal({ - component: CoreCourseSummaryPage, - componentProps: { - courseId: this.course.id, - course: this.course, - }, - }); } /** diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index f4f9703cd..a7f5a215a 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -70,6 +70,8 @@ import { CoreSiteHome } from '@features/sitehome/services/sitehome'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreSiteHomeHomeHandlerService } from '@features/sitehome/services/handlers/sitehome-home'; import { CoreStatusWithWarningsWSResponse } from '@services/ws'; +import { CoreCourseWithImageAndColor } from '@features/courses/services/courses-helper'; +import { CoreCourseSummaryPage } from '../pages/course-summary/course-summary'; /** * Prefetch info of a module. @@ -2033,6 +2035,30 @@ export class CoreCourseHelperProvider { } } + /** + * Retrieves course summary page module. + * + * @returns Course summary page module. + */ + async getCourseSummaryRouteModule(): Promise { + return import('../pages/course-summary/course-summary.module').then(m => m.CoreCourseSummaryPageModule); + } + + /** + * Open course summary in side modal. + * + * @param course Course selected + */ + openCourseSummary(course: CoreCourseWithImageAndColor & CoreCourseAnyCourseData): void { + CoreDomUtils.openSideModal({ + component: CoreCourseSummaryPage, + componentProps: { + courseId: course.id, + course: course, + }, + }); + } + } export const CoreCourseHelper = makeSingleton(CoreCourseHelperProvider);