Merge pull request #3371 from alfonso-salces/MOBILE-4081

MOBILE-4081 course: Load 'course-summary.module' from service
main
Dani Palou 2022-09-05 09:11:17 +02:00 committed by GitHub
commit 9249fab7ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 13 deletions

View File

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

View File

@ -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<void>({
component: CoreCourseSummaryPage,
componentProps: {
courseId: this.course.id,
course: this.course,
},
});
}
/**

View File

@ -71,6 +71,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.
@ -2034,6 +2036,30 @@ export class CoreCourseHelperProvider {
}
}
/**
* Retrieves course summary page module.
*
* @returns Course summary page module.
*/
async getCourseSummaryRouteModule(): Promise<unknown> {
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<void>({
component: CoreCourseSummaryPage,
componentProps: {
courseId: course.id,
course: course,
},
});
}
}
export const CoreCourseHelper = makeSingleton(CoreCourseHelperProvider);