From 8a63495af30d5c174770b89b1409546577f5f5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 4 Feb 2025 13:24:00 +0100 Subject: [PATCH] MOBILE-4759 chore: Remove basic lazy modules without provide: ROUTES --- src/addons/badges/badges-lazy.module.ts | 58 ---------- src/addons/badges/badges.module.ts | 36 +++++- .../competency-course-details-lazy.module.ts | 60 ---------- .../competency-learning-plans-lazy.module.ts | 75 ------------ src/addons/competency/competency.module.ts | 109 +++++++++++++++++- src/addons/mod/assign/assign-lazy.module.ts | 71 ------------ src/addons/mod/assign/assign.module.ts | 48 +++++++- src/addons/mod/chat/chat-lazy.module.ts | 69 ----------- src/addons/mod/chat/chat.module.ts | 46 +++++++- .../mod/feedback/feedback-lazy.module.ts | 73 ------------ src/addons/mod/feedback/feedback.module.ts | 50 +++++++- .../mod/forum/forum-discussion-lazy.module.ts | 31 ----- src/addons/mod/forum/forum-lazy.module.ts | 68 ----------- .../forum/forum-new-discussion-lazy.module.ts | 30 ----- src/addons/mod/forum/forum.module.ts | 65 +++++++++-- .../mod/glossary/glossary-edit-lazy.module.ts | 30 ----- .../mod/glossary/glossary-lazy.module.ts | 63 ---------- src/addons/mod/glossary/glossary.module.ts | 49 +++++++- .../grades-course-participants-lazy.module.ts | 40 ------- .../grades/grades-courses-lazy.module.ts | 55 --------- src/core/features/grades/grades.module.ts | 38 +++++- src/core/features/login/login-lazy.module.ts | 63 ---------- src/core/features/login/login.module.ts | 38 +++++- .../features/settings/settings-lazy.module.ts | 95 --------------- src/core/features/settings/settings.module.ts | 76 +++++++++++- .../sharedfiles/sharedfiles-lazy.module.ts | 34 ------ .../sharedfiles/sharedfiles.module.ts | 20 +++- .../features/user/user-course-lazy.module.ts | 40 ------- src/core/features/user/user-lazy.module.ts | 39 ------- src/core/features/user/user.module.ts | 25 +++- 30 files changed, 572 insertions(+), 1022 deletions(-) delete mode 100644 src/addons/badges/badges-lazy.module.ts delete mode 100644 src/addons/competency/competency-course-details-lazy.module.ts delete mode 100644 src/addons/competency/competency-learning-plans-lazy.module.ts delete mode 100644 src/addons/mod/assign/assign-lazy.module.ts delete mode 100644 src/addons/mod/chat/chat-lazy.module.ts delete mode 100644 src/addons/mod/feedback/feedback-lazy.module.ts delete mode 100644 src/addons/mod/forum/forum-discussion-lazy.module.ts delete mode 100644 src/addons/mod/forum/forum-lazy.module.ts delete mode 100644 src/addons/mod/forum/forum-new-discussion-lazy.module.ts delete mode 100644 src/addons/mod/glossary/glossary-edit-lazy.module.ts delete mode 100644 src/addons/mod/glossary/glossary-lazy.module.ts delete mode 100644 src/core/features/grades/grades-course-participants-lazy.module.ts delete mode 100644 src/core/features/grades/grades-courses-lazy.module.ts delete mode 100644 src/core/features/login/login-lazy.module.ts delete mode 100644 src/core/features/settings/settings-lazy.module.ts delete mode 100644 src/core/features/sharedfiles/sharedfiles-lazy.module.ts delete mode 100644 src/core/features/user/user-course-lazy.module.ts delete mode 100644 src/core/features/user/user-lazy.module.ts diff --git a/src/addons/badges/badges-lazy.module.ts b/src/addons/badges/badges-lazy.module.ts deleted file mode 100644 index a20822d13c1..00000000000 --- a/src/addons/badges/badges-lazy.module.ts +++ /dev/null @@ -1,58 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -const mobileRoutes: Routes = [ - { - path: '', - pathMatch: 'full', - loadComponent: () => import('./pages/user-badges/user-badges'), - }, - { - path: ':badgeHash', - loadComponent: () => import('./pages/issued-badge/issued-badge'), - data: { usesSwipeNavigation: true }, - }, -]; - -const tabletRoutes: Routes = [ - { - path: '', - loadComponent: () => import('./pages/user-badges/user-badges'), - children: [ - { - path: ':badgeHash', - loadComponent: () => import('./pages/issued-badge/issued-badge'), - data: { usesSwipeNavigation: true }, - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonBadgesLazyModule {} diff --git a/src/addons/badges/badges.module.ts b/src/addons/badges/badges.module.ts index 0394a88bf2b..a4749438613 100644 --- a/src/addons/badges/badges.module.ts +++ b/src/addons/badges/badges.module.ts @@ -26,6 +26,8 @@ import { CorePushNotificationsDelegate } from '@features/pushnotifications/servi import { AddonBadgesPushClickHandler } from './services/handlers/push-click'; import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate'; import { AddonBadgesTagAreaHandler } from './services/handlers/tag-area'; +import { conditionalRoutes } from '@/app/app-routing.module'; +import { CoreScreen } from '@services/screen'; /** * Get badges services. @@ -40,6 +42,38 @@ export async function getBadgesServices(): Promise[]> { ]; } +const mobileRoutes: Routes = [ + { + path: '', + pathMatch: 'full', + loadComponent: () => import('./pages/user-badges/user-badges'), + }, + { + path: ':badgeHash', + loadComponent: () => import('./pages/issued-badge/issued-badge'), + data: { usesSwipeNavigation: true }, + }, +]; + +const tabletRoutes: Routes = [ + { + path: '', + loadComponent: () => import('./pages/user-badges/user-badges'), + children: [ + { + path: ':badgeHash', + loadComponent: () => import('./pages/issued-badge/issued-badge'), + data: { usesSwipeNavigation: true }, + }, + ], + }, +]; + +const routes: Routes = [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), +]; + const mainMenuRoutes: Routes = [ { path: 'badge/:badgeHash', @@ -48,7 +82,7 @@ const mainMenuRoutes: Routes = [ }, { path: 'badges', - loadChildren: () => import('./badges-lazy.module'), + children: routes, }, { path: 'badgeclass/:badgeId', diff --git a/src/addons/competency/competency-course-details-lazy.module.ts b/src/addons/competency/competency-course-details-lazy.module.ts deleted file mode 100644 index fc207aa7ea0..00000000000 --- a/src/addons/competency/competency-course-details-lazy.module.ts +++ /dev/null @@ -1,60 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { ADDON_COMPETENCY_SUMMARY_PAGE } from './constants'; -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -const mobileRoutes: Routes = [ - { - path: '', - loadComponent: () => import('./pages/coursecompetencies/coursecompetencies'), - }, - { - path: ':competencyId', - loadComponent: () => import('./pages/competency/competency'), - }, -]; - -const tabletRoutes: Routes = [ - { - path: '', - loadComponent: () => import('./pages/competencies/competencies'), - children: [ - { - path: ':competencyId', - loadComponent: () => import('./pages/competency/competency'), - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), - { - path: `:competencyId/${ADDON_COMPETENCY_SUMMARY_PAGE}`, - loadComponent: () => import('./pages/competencysummary/competencysummary'), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonCompetencyCourseDetailsLazyModule {} diff --git a/src/addons/competency/competency-learning-plans-lazy.module.ts b/src/addons/competency/competency-learning-plans-lazy.module.ts deleted file mode 100644 index 04e381ae8cb..00000000000 --- a/src/addons/competency/competency-learning-plans-lazy.module.ts +++ /dev/null @@ -1,75 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; -import { ADDON_COMPETENCY_COMPETENCIES_PAGE, ADDON_COMPETENCY_SUMMARY_PAGE } from './constants'; - -const mobileRoutes: Routes = [ - { - path: '', - pathMatch: 'full', - loadComponent: () => import('./pages/planlist/planlist'), - }, - { - path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, - loadComponent: () => import('./pages/plan/plan'), - }, - { - path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/:competencyId`, - loadComponent: () => import('./pages/competency/competency'), - }, -]; - -const tabletRoutes: Routes = [ - { - path: '', - loadComponent: () => import('./pages/planlist/planlist'), - children: [ - { - path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, - loadComponent: () => import('./pages/plan/plan'), - }, - ], - }, - { - path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, - loadComponent: () => import('./pages/competencies/competencies'), - children: [ - { - path: ':competencyId', - loadComponent: () => import('./pages/competency/competency'), - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), - { - path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/:competencyId/${ADDON_COMPETENCY_SUMMARY_PAGE}`, - loadComponent: () => import('./pages/competencysummary/competencysummary'), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonCompetencyLearningPlansLazyModule {} diff --git a/src/addons/competency/competency.module.ts b/src/addons/competency/competency.module.ts index 223601edbf3..a646e85e48e 100644 --- a/src/addons/competency/competency.module.ts +++ b/src/addons/competency/competency.module.ts @@ -29,7 +29,13 @@ import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-ro import { CoreCourseIndexRoutingModule } from '@features/course/course-routing.module'; import { PARTICIPANTS_PAGE_NAME } from '@features/user/constants'; import { CORE_COURSE_PAGE_NAME } from '@features/course/constants'; -import { ADDON_COMPETENCY_LEARNING_PLANS_PAGE, ADDON_COMPETENCY_COMPETENCIES_PAGE } from './constants'; +import { + ADDON_COMPETENCY_LEARNING_PLANS_PAGE, + ADDON_COMPETENCY_COMPETENCIES_PAGE, + ADDON_COMPETENCY_SUMMARY_PAGE, +} from './constants'; +import { conditionalRoutes } from '@/app/app-routing.module'; +import { CoreScreen } from '@services/screen'; /** * Get competency services. @@ -46,18 +52,113 @@ export async function getCompetencyServices(): Promise[]> { ]; } +/** + * Routes for competency learning plans. + * + * @returns Routes. + */ +function getCompetencyLearningPlansRoutes(): Routes { + const mobileRoutes: Routes = [ + { + path: '', + pathMatch: 'full', + loadComponent: () => import('./pages/planlist/planlist'), + }, + { + path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, + loadComponent: () => import('./pages/plan/plan'), + }, + { + path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/:competencyId`, + loadComponent: () => import('./pages/competency/competency'), + }, + ]; + + const tabletRoutes: Routes = [ + { + path: '', + loadComponent: () => import('./pages/planlist/planlist'), + children: [ + { + path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, + loadComponent: () => import('./pages/plan/plan'), + }, + ], + }, + { + path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, + loadComponent: () => import('./pages/competencies/competencies'), + children: [ + { + path: ':competencyId', + loadComponent: () => import('./pages/competency/competency'), + }, + ], + }, + ]; + + return [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + { + path: `:planId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}/:competencyId/${ADDON_COMPETENCY_SUMMARY_PAGE}`, + loadComponent: () => import('./pages/competencysummary/competencysummary'), + }, + ]; +} + +/** + * Routes for competency course details. + * + * @returns Routes. + */ +function getCompetencyCourseDetailsRoutes(): Routes { + const mobileRoutes: Routes = [ + { + path: '', + loadComponent: () => import('./pages/coursecompetencies/coursecompetencies'), + }, + { + path: ':competencyId', + loadComponent: () => import('./pages/competency/competency'), + }, + ]; + + const tabletRoutes: Routes = [ + { + path: '', + loadComponent: () => import('./pages/competencies/competencies'), + children: [ + { + path: ':competencyId', + loadComponent: () => import('./pages/competency/competency'), + }, + ], + }, + ]; + + return [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + { + path: `:competencyId/${ADDON_COMPETENCY_SUMMARY_PAGE}`, + loadComponent: () => import('./pages/competencysummary/competencysummary'), + }, + ]; +} + const mainMenuChildrenRoutes: Routes = [ { path: ADDON_COMPETENCY_LEARNING_PLANS_PAGE, - loadChildren: () => import('./competency-learning-plans-lazy.module'), + children: getCompetencyLearningPlansRoutes(), }, { path: `${CORE_COURSE_PAGE_NAME}/:courseId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, - loadChildren: () => import('./competency-course-details-lazy.module'), + children: getCompetencyCourseDetailsRoutes(), }, { path: `${CORE_COURSE_PAGE_NAME}/:courseId/${PARTICIPANTS_PAGE_NAME}/:userId/${ADDON_COMPETENCY_COMPETENCIES_PAGE}`, - loadChildren: () => import('./competency-course-details-lazy.module'), + children: getCompetencyCourseDetailsRoutes(), }, ]; diff --git a/src/addons/mod/assign/assign-lazy.module.ts b/src/addons/mod/assign/assign-lazy.module.ts deleted file mode 100644 index a37edba70eb..00000000000 --- a/src/addons/mod/assign/assign-lazy.module.ts +++ /dev/null @@ -1,71 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { canLeaveGuard } from '@guards/can-leave'; -import { CoreScreen } from '@services/screen'; - -const commonRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index'), - }, - { - path: ':courseId/:cmId/edit', - loadComponent: () => import('./pages/edit/edit'), - canDeactivate: [canLeaveGuard], - }, -]; - -const mobileRoutes: Routes = [ - ...commonRoutes, - { - path: ':courseId/:cmId/submission', - loadComponent: () => import('./pages/submission-list/submission-list'), - }, - { - path: ':courseId/:cmId/submission/:submitId', - loadComponent: () => import('./pages/submission-review/submission-review'), - canDeactivate: [canLeaveGuard], - }, -]; - -const tabletRoutes: Routes = [ - ...commonRoutes, - { - path: ':courseId/:cmId/submission', - loadComponent: () => import('./pages/submission-list/submission-list'), - children: [ - { - path: ':submitId', - loadComponent: () => import('./pages/submission-review/submission-review'), - canDeactivate: [canLeaveGuard], - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModAssignLazyModule {} diff --git a/src/addons/mod/assign/assign.module.ts b/src/addons/mod/assign/assign.module.ts index 18f30a01c3a..af94abcefbc 100644 --- a/src/addons/mod/assign/assign.module.ts +++ b/src/addons/mod/assign/assign.module.ts @@ -32,6 +32,9 @@ import { AddonModAssignPushClickHandler } from './services/handlers/push-click'; import { AddonModAssignSyncCronHandler } from './services/handlers/sync-cron'; import { AddonModAssignSubmissionModule } from './submission/submission.module'; import { ADDON_MOD_ASSIGN_COMPONENT, ADDON_MOD_ASSIGN_PAGE_NAME } from './constants'; +import { conditionalRoutes } from '@/app/app-routing.module'; +import { canLeaveGuard } from '@guards/can-leave'; +import { CoreScreen } from '@services/screen'; /** * Get mod assign services. @@ -73,10 +76,53 @@ export async function getModAssignComponentModules(): Promise[]> { ]; } +const commonRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index'), + }, + { + path: ':courseId/:cmId/edit', + loadComponent: () => import('./pages/edit/edit'), + canDeactivate: [canLeaveGuard], + }, +]; + +const mobileRoutes: Routes = [ + ...commonRoutes, + { + path: ':courseId/:cmId/submission', + loadComponent: () => import('./pages/submission-list/submission-list'), + }, + { + path: ':courseId/:cmId/submission/:submitId', + loadComponent: () => import('./pages/submission-review/submission-review'), + canDeactivate: [canLeaveGuard], + }, +]; + +const tabletRoutes: Routes = [ + ...commonRoutes, + { + path: ':courseId/:cmId/submission', + loadComponent: () => import('./pages/submission-list/submission-list'), + children: [ + { + path: ':submitId', + loadComponent: () => import('./pages/submission-review/submission-review'), + canDeactivate: [canLeaveGuard], + }, + ], + }, +]; + const routes: Routes = [ { path: ADDON_MOD_ASSIGN_PAGE_NAME, - loadChildren: () => import('./assign-lazy.module'), + children: [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + ], }, ]; diff --git a/src/addons/mod/chat/chat-lazy.module.ts b/src/addons/mod/chat/chat-lazy.module.ts deleted file mode 100644 index da15c407771..00000000000 --- a/src/addons/mod/chat/chat-lazy.module.ts +++ /dev/null @@ -1,69 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { CoreScreen } from '@services/screen'; -import { conditionalRoutes } from '@/app/app-routing.module'; -import { canLeaveGuard } from '@guards/can-leave'; - -const commonRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index/index'), - }, - { - path: ':courseId/:cmId/chat', - loadComponent: () => import('./pages/chat/chat'), - canDeactivate: [canLeaveGuard], - }, -]; - -const mobileRoutes: Routes = [ - ...commonRoutes, - { - path: ':courseId/:cmId/sessions', - loadComponent: () => import('./pages/sessions/sessions'), - }, - { - path: ':courseId/:cmId/sessions/:sessionStart/:sessionEnd', - loadComponent: () => import('./pages/session-messages/session-messages'), - }, -]; - -const tabletRoutes: Routes = [ - ...commonRoutes, - { - path: ':courseId/:cmId/sessions', - loadComponent: () => import('./pages/sessions/sessions'), - children: [ - { - path: ':sessionStart/:sessionEnd', - loadComponent: () => import('./pages/session-messages/session-messages'), - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModChatLazyModule {} diff --git a/src/addons/mod/chat/chat.module.ts b/src/addons/mod/chat/chat.module.ts index 304dbd40922..74d42a67d56 100644 --- a/src/addons/mod/chat/chat.module.ts +++ b/src/addons/mod/chat/chat.module.ts @@ -24,11 +24,55 @@ import { AddonModChatListLinkHandler } from './services/handlers/list-link'; import { AddonModChatModuleHandler } from './services/handlers/module'; import { getPrefetchHandlerInstance } from './services/handlers/prefetch'; import { ADDON_MOD_CHAT_COMPONENT, ADDON_MOD_CHAT_PAGE_NAME } from './constants'; +import { conditionalRoutes } from '@/app/app-routing.module'; +import { canLeaveGuard } from '@guards/can-leave'; +import { CoreScreen } from '@services/screen'; + +const commonRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index/index'), + }, + { + path: ':courseId/:cmId/chat', + loadComponent: () => import('./pages/chat/chat'), + canDeactivate: [canLeaveGuard], + }, +]; + +const mobileRoutes: Routes = [ + ...commonRoutes, + { + path: ':courseId/:cmId/sessions', + loadComponent: () => import('./pages/sessions/sessions'), + }, + { + path: ':courseId/:cmId/sessions/:sessionStart/:sessionEnd', + loadComponent: () => import('./pages/session-messages/session-messages'), + }, +]; + +const tabletRoutes: Routes = [ + ...commonRoutes, + { + path: ':courseId/:cmId/sessions', + loadComponent: () => import('./pages/sessions/sessions'), + children: [ + { + path: ':sessionStart/:sessionEnd', + loadComponent: () => import('./pages/session-messages/session-messages'), + }, + ], + }, +]; const routes: Routes = [ { path: ADDON_MOD_CHAT_PAGE_NAME, - loadChildren: () => import('./chat-lazy.module'), + children: [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + ], }, ]; diff --git a/src/addons/mod/feedback/feedback-lazy.module.ts b/src/addons/mod/feedback/feedback-lazy.module.ts deleted file mode 100644 index 9477938a33f..00000000000 --- a/src/addons/mod/feedback/feedback-lazy.module.ts +++ /dev/null @@ -1,73 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; -import { canLeaveGuard } from '@guards/can-leave'; - -const commonRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index/index'), - }, - { - path: ':courseId/:cmId/form', - loadComponent: () => import('./pages/form/form'), - canDeactivate: [canLeaveGuard], - }, - { - path: ':courseId/:cmId/nonrespondents', - loadComponent: () => import('./pages/nonrespondents/nonrespondents'), - }, -]; - -const mobileRoutes: Routes = [ - ...commonRoutes, - { - path: ':courseId/:cmId/attempts', - loadComponent: () => import('./pages/attempts/attempts'), - }, - { - path: ':courseId/:cmId/attempts/:attemptId', - loadComponent: () => import('./pages/attempt/attempt'), - }, -]; - -const tabletRoutes: Routes = [ - ...commonRoutes, - { - path: ':courseId/:cmId/attempts', - loadComponent: () => import('./pages/attempts/attempts'), - children: [ - { - path: ':attemptId', - loadComponent: () => import('./pages/attempt/attempt'), - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModFeedbackLazyModule {} diff --git a/src/addons/mod/feedback/feedback.module.ts b/src/addons/mod/feedback/feedback.module.ts index 1f2876a12a8..e8a00c46d13 100644 --- a/src/addons/mod/feedback/feedback.module.ts +++ b/src/addons/mod/feedback/feedback.module.ts @@ -35,11 +35,59 @@ import { AddonModFeedbackShowEntriesLinkHandler } from './services/handlers/show import { AddonModFeedbackShowNonRespondentsLinkHandler } from './services/handlers/show-non-respondents-link'; import { AddonModFeedbackSyncCronHandler } from './services/handlers/sync-cron'; import { ADDON_MOD_FEEDBACK_COMPONENT, ADDON_MOD_FEEDBACK_PAGE_NAME } from './constants'; +import { conditionalRoutes } from '@/app/app-routing.module'; +import { canLeaveGuard } from '@guards/can-leave'; +import { CoreScreen } from '@services/screen'; + +const commonRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index/index'), + }, + { + path: ':courseId/:cmId/form', + loadComponent: () => import('./pages/form/form'), + canDeactivate: [canLeaveGuard], + }, + { + path: ':courseId/:cmId/nonrespondents', + loadComponent: () => import('./pages/nonrespondents/nonrespondents'), + }, +]; + +const mobileRoutes: Routes = [ + ...commonRoutes, + { + path: ':courseId/:cmId/attempts', + loadComponent: () => import('./pages/attempts/attempts'), + }, + { + path: ':courseId/:cmId/attempts/:attemptId', + loadComponent: () => import('./pages/attempt/attempt'), + }, +]; + +const tabletRoutes: Routes = [ + ...commonRoutes, + { + path: ':courseId/:cmId/attempts', + loadComponent: () => import('./pages/attempts/attempts'), + children: [ + { + path: ':attemptId', + loadComponent: () => import('./pages/attempt/attempt'), + }, + ], + }, +]; const routes: Routes = [ { path: ADDON_MOD_FEEDBACK_PAGE_NAME, - loadChildren: () => import('./feedback-lazy.module'), + children: [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + ], }, ]; diff --git a/src/addons/mod/forum/forum-discussion-lazy.module.ts b/src/addons/mod/forum/forum-discussion-lazy.module.ts deleted file mode 100644 index 2efb0fb769c..00000000000 --- a/src/addons/mod/forum/forum-discussion-lazy.module.ts +++ /dev/null @@ -1,31 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { canLeaveGuard } from '@guards/can-leave'; - -const routes: Routes = [{ - path: '', - loadComponent: () => import('./pages/discussion/discussion'), - canDeactivate: [canLeaveGuard], -}]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModForumDiscussionLazyModule {} diff --git a/src/addons/mod/forum/forum-lazy.module.ts b/src/addons/mod/forum/forum-lazy.module.ts deleted file mode 100644 index de2c99748b7..00000000000 --- a/src/addons/mod/forum/forum-lazy.module.ts +++ /dev/null @@ -1,68 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -const mobileRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index/index'), - }, - { - path: ':courseId/:cmId/new/:timeCreated', - loadChildren: () => import('./forum-new-discussion-lazy.module'), - }, - { - path: ':courseId/:cmId/:discussionId', - loadChildren: () => import('./forum-discussion-lazy.module'), - - }, - { - path: 'discussion/:discussionId', // Only for discussion link handling. - loadChildren: () => import('./forum-discussion-lazy.module'), - }, -]; - -const tabletRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index/index'), - children: [ - { - path: 'new/:timeCreated', - loadChildren: () => import('./forum-new-discussion-lazy.module'), - }, - { - path: ':discussionId', - loadChildren: () => import('./forum-discussion-lazy.module'), - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModForumLazyModule {} diff --git a/src/addons/mod/forum/forum-new-discussion-lazy.module.ts b/src/addons/mod/forum/forum-new-discussion-lazy.module.ts deleted file mode 100644 index f5148360c75..00000000000 --- a/src/addons/mod/forum/forum-new-discussion-lazy.module.ts +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { canLeaveGuard } from '@guards/can-leave'; - -const routes: Routes = [{ - path: '', - loadComponent: () => import('./pages/new-discussion/new-discussion'), - canDeactivate: [canLeaveGuard], -}]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModForumNewDiscussionLazyModule {} diff --git a/src/addons/mod/forum/forum.module.ts b/src/addons/mod/forum/forum.module.ts index 0eded424fcb..02cc06aa5d7 100644 --- a/src/addons/mod/forum/forum.module.ts +++ b/src/addons/mod/forum/forum.module.ts @@ -13,7 +13,7 @@ // limitations under the License. import { APP_INITIALIZER, NgModule } from '@angular/core'; -import { Routes } from '@angular/router'; +import { Route, Routes } from '@angular/router'; import { conditionalRoutes } from '@/app/app-routing.module'; import { CORE_SITE_SCHEMAS } from '@services/sites'; @@ -40,6 +40,54 @@ import { AddonModForumPushClickHandler } from './services/handlers/push-click'; import { CORE_COURSE_CONTENTS_PATH } from '@features/course/constants'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { ADDON_MOD_FORUM_COMPONENT, ADDON_MOD_FORUM_PAGE_NAME, ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants'; +import { canLeaveGuard } from '@guards/can-leave'; + +const newDiscussionRoute: Route = { + loadComponent: () => import('./pages/new-discussion/new-discussion'), + canDeactivate: [canLeaveGuard], +}; + +const discussionRoute: Route = { + loadComponent: () => import('./pages/discussion/discussion'), + canDeactivate: [canLeaveGuard], +}; + +const mobileRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index/index'), + }, + { + path: ':courseId/:cmId/new/:timeCreated', + ...newDiscussionRoute, + }, + { + path: ':courseId/:cmId/:discussionId', + ...discussionRoute, + + }, + { + path: 'discussion/:discussionId', // Only for discussion link handling. + ...discussionRoute, + }, +]; + +const tabletRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index/index'), + children: [ + { + path: 'new/:timeCreated', + ...newDiscussionRoute, + }, + { + path: ':discussionId', + ...discussionRoute, + }, + ], + }, +]; const mainMenuRoutes: Routes = [ { @@ -48,24 +96,27 @@ const mainMenuRoutes: Routes = [ }, { path: `${ADDON_MOD_FORUM_PAGE_NAME}/discussion/:discussionId`, - loadChildren: () => import('./forum-discussion-lazy.module'), data: { swipeEnabled: false }, + ...discussionRoute, }, { path: ADDON_MOD_FORUM_PAGE_NAME, - loadChildren: () => import('./forum-lazy.module'), + children: [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + ], }, ...conditionalRoutes( [ { path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`, - loadChildren: () => import('./forum-new-discussion-lazy.module'), data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, + ...newDiscussionRoute, }, { path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`, - loadChildren: () => import('./forum-discussion-lazy.module'), data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, + ...discussionRoute, }, ], () => CoreScreen.isMobile, @@ -77,13 +128,13 @@ const courseContentsRoutes: Routes = conditionalRoutes( [ { path: `${ADDON_MOD_FORUM_PAGE_NAME}/new/:timeCreated`, - loadChildren: () => import('./forum-new-discussion-lazy.module'), + ...newDiscussionRoute, data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, }, { path: `${ADDON_MOD_FORUM_PAGE_NAME}/:discussionId`, - loadChildren: () => import('./forum-discussion-lazy.module'), data: { discussionsPathPrefix: `${ADDON_MOD_FORUM_PAGE_NAME}/` }, + ...discussionRoute, }, ], () => CoreScreen.isTablet, diff --git a/src/addons/mod/glossary/glossary-edit-lazy.module.ts b/src/addons/mod/glossary/glossary-edit-lazy.module.ts deleted file mode 100644 index 2c2d441265d..00000000000 --- a/src/addons/mod/glossary/glossary-edit-lazy.module.ts +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { canLeaveGuard } from '@guards/can-leave'; - -const routes: Routes = [{ - path: '', - loadComponent: () => import('./pages/edit/edit'), - canDeactivate: [canLeaveGuard], -}]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModGlossaryEditLazyModule {} diff --git a/src/addons/mod/glossary/glossary-lazy.module.ts b/src/addons/mod/glossary/glossary-lazy.module.ts deleted file mode 100644 index 38a512d6fc1..00000000000 --- a/src/addons/mod/glossary/glossary-lazy.module.ts +++ /dev/null @@ -1,63 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -const mobileRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index/index'), - }, - { - path: ':courseId/:cmId/entry/:entrySlug', - loadComponent: () => import('./pages/entry/entry'), - }, -]; - -const tabletRoutes: Routes = [ - { - path: ':courseId/:cmId', - loadComponent: () => import('./pages/index/index'), - children: [ - { - path: 'entry/:entrySlug', - loadComponent: () => import('./pages/entry/entry'), - }, - ], - }, -]; - -const routes: Routes = [ - { - path: ':courseId/:cmId/entry/new', - loadChildren: () => import('./glossary-edit-lazy.module'), - }, - { - path: ':courseId/:cmId/entry/:entrySlug/edit', - loadChildren: () => import('./glossary-edit-lazy.module'), - }, - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class AddonModGlossaryLazyModule {} diff --git a/src/addons/mod/glossary/glossary.module.ts b/src/addons/mod/glossary/glossary.module.ts index 26cec3d285e..a70cf6adac7 100644 --- a/src/addons/mod/glossary/glossary.module.ts +++ b/src/addons/mod/glossary/glossary.module.ts @@ -14,7 +14,7 @@ import { conditionalRoutes } from '@/app/app-routing.module'; import { APP_INITIALIZER, NgModule } from '@angular/core'; -import { Routes } from '@angular/router'; +import { Route, Routes } from '@angular/router'; import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; import { CORE_COURSE_CONTENTS_PATH } from '@features/course/constants'; import { CoreCourseContentsRoutingModule } from '@features/course/course-contents-routing.module'; @@ -36,6 +36,36 @@ import { AddonModGlossaryPrefetchHandler } from './services/handlers/prefetch'; import { AddonModGlossarySyncCronHandler } from './services/handlers/sync-cron'; import { AddonModGlossaryTagAreaHandler } from './services/handlers/tag-area'; import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_PAGE_NAME } from './constants'; +import { canLeaveGuard } from '@guards/can-leave'; + +const mobileRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index/index'), + }, + { + path: ':courseId/:cmId/entry/:entrySlug', + loadComponent: () => import('./pages/entry/entry'), + }, +]; + +const tabletRoutes: Routes = [ + { + path: ':courseId/:cmId', + loadComponent: () => import('./pages/index/index'), + children: [ + { + path: 'entry/:entrySlug', + loadComponent: () => import('./pages/entry/entry'), + }, + ], + }, +]; + +const editRoute: Route = { + loadComponent: () => import('./pages/edit/edit'), + canDeactivate: [canLeaveGuard], +}; const mainMenuRoutes: Routes = [ // Link handlers navigation. @@ -47,19 +77,30 @@ const mainMenuRoutes: Routes = [ // Course activity navigation. { path: ADDON_MOD_GLOSSARY_PAGE_NAME, - loadChildren: () => import('./glossary-lazy.module'), + children: [ + { + path: ':courseId/:cmId/entry/new', + ...editRoute, + }, + { + path: ':courseId/:cmId/entry/:entrySlug/edit', + ...editRoute, + }, + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + ], }, // Single Activity format navigation. { path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/new`, - loadChildren: () => import('./glossary-edit-lazy.module'), data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` }, + ...editRoute, }, { path: `${CORE_COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug/edit`, - loadChildren: () => import('./glossary-edit-lazy.module'), data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` }, + ...editRoute, }, ...conditionalRoutes( [{ diff --git a/src/core/features/grades/grades-course-participants-lazy.module.ts b/src/core/features/grades/grades-course-participants-lazy.module.ts deleted file mode 100644 index 859b2acf49a..00000000000 --- a/src/core/features/grades/grades-course-participants-lazy.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { CoreScreen } from '@services/screen'; - -const routes: Routes = [ - { - path: '', - loadComponent: () => import('@features/user/pages/participants/participants'), - children: conditionalRoutes([ - { - path: ':userId', - loadComponent: () => import('@features/grades/pages/course/course'), - data: { swipeManagerSource: 'participants' }, - }, - ], () => CoreScreen.isTablet), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreGradesCourseParticipantsLazyModule {} diff --git a/src/core/features/grades/grades-courses-lazy.module.ts b/src/core/features/grades/grades-courses-lazy.module.ts deleted file mode 100644 index 9c3d041f54b..00000000000 --- a/src/core/features/grades/grades-courses-lazy.module.ts +++ /dev/null @@ -1,55 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -const mobileRoutes: Routes = [ - { - path: '', - loadComponent: () => import('@features/grades/pages/courses/courses'), - }, - { - path: ':courseId', - loadComponent: () => import('@features/grades/pages/course/course'), - }, -]; - -const tabletRoutes: Routes = [ - { - path: '', - loadComponent: () => import('@features/grades/pages/courses/courses'), - children: [ - { - path: ':courseId', - loadComponent: () => import('@features/grades/pages/course/course'), - }, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreGradesCoursesLazyModule {} diff --git a/src/core/features/grades/grades.module.ts b/src/core/features/grades/grades.module.ts index 5634fbd1d39..e2aaf7c6d00 100644 --- a/src/core/features/grades/grades.module.ts +++ b/src/core/features/grades/grades.module.ts @@ -46,10 +46,37 @@ export async function getGradesServices(): Promise[]> { ]; } +const mobileRoutes: Routes = [ + { + path: '', + loadComponent: () => import('@features/grades/pages/courses/courses'), + }, + { + path: ':courseId', + loadComponent: () => import('@features/grades/pages/course/course'), + }, +]; + +const tabletRoutes: Routes = [ + { + path: '', + loadComponent: () => import('@features/grades/pages/courses/courses'), + children: [ + { + path: ':courseId', + loadComponent: () => import('@features/grades/pages/course/course'), + }, + ], + }, +]; + const mainMenuChildrenRoutes: Routes = [ { path: GRADES_PAGE_NAME, - loadChildren: () => import('./grades-courses-lazy.module'), + children: [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + ], data: { swipeManagerSource: 'courses' }, }, { @@ -72,7 +99,14 @@ const courseIndexRoutes: Routes = [ }, { path: GRADES_PARTICIPANTS_PAGE_NAME, - loadChildren: () => import('./grades-course-participants-lazy.module'), + loadComponent: () => import('@features/user/pages/participants/participants'), + children: conditionalRoutes([ + { + path: ':userId', + loadComponent: () => import('@features/grades/pages/course/course'), + data: { swipeManagerSource: 'participants' }, + }, + ], () => CoreScreen.isTablet), }, ]; diff --git a/src/core/features/login/login-lazy.module.ts b/src/core/features/login/login-lazy.module.ts deleted file mode 100644 index 9fefe48eb10..00000000000 --- a/src/core/features/login/login-lazy.module.ts +++ /dev/null @@ -1,63 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { hasSitesGuard } from './guards/has-sites'; -import { CoreLoginHelper } from './services/login-helper'; - -const routes: Routes = [ - { - path: '', - pathMatch: 'full', - redirectTo: 'sites', - }, - { - path: 'site', - loadComponent: () => import('@features/login/pages/site/site'), - }, - { - path: 'credentials', - loadChildren: () => CoreLoginHelper.getCredentialsRouteModule(), - }, - { - path: 'sites', - loadComponent: () => import('@features/login/pages/sites/sites'), - canActivate: [hasSitesGuard], - }, - { - path: 'forgottenpassword', - loadComponent: () => import('@features/login/pages/forgotten-password/forgotten-password'), - }, - { - path: 'changepassword', - loadComponent: () => import('@features/login/pages/change-password/change-password'), - }, - { - path: 'emailsignup', - loadComponent: () => import('@features/login/pages/email-signup/email-signup'), - }, - { - path: 'reconnect', - loadChildren: () => CoreLoginHelper.getReconnectRouteModule(), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreLoginLazyModule {} diff --git a/src/core/features/login/login.module.ts b/src/core/features/login/login.module.ts index 8030f6411d2..a6a2f95e7df 100644 --- a/src/core/features/login/login.module.ts +++ b/src/core/features/login/login.module.ts @@ -21,6 +21,7 @@ import { redirectGuard } from '@guards/redirect'; import { CoreLoginCronHandler } from './services/handlers/cron'; import { CoreCronDelegate } from '@services/cron'; import { CoreEvents } from '@singletons/events'; +import { hasSitesGuard } from './guards/has-sites'; /** * Get login services. @@ -38,7 +39,42 @@ export async function getLoginServices(): Promise[]> { const appRoutes: Routes = [ { path: 'login', - loadChildren: () => import('./login-lazy.module'), + children: [ + { + path: '', + pathMatch: 'full', + redirectTo: 'sites', + }, + { + path: 'site', + loadComponent: () => import('@features/login/pages/site/site'), + }, + { + path: 'credentials', + loadChildren: () => CoreLoginHelper.getCredentialsRouteModule(), + }, + { + path: 'sites', + loadComponent: () => import('@features/login/pages/sites/sites'), + canActivate: [hasSitesGuard], + }, + { + path: 'forgottenpassword', + loadComponent: () => import('@features/login/pages/forgotten-password/forgotten-password'), + }, + { + path: 'changepassword', + loadComponent: () => import('@features/login/pages/change-password/change-password'), + }, + { + path: 'emailsignup', + loadComponent: () => import('@features/login/pages/email-signup/email-signup'), + }, + { + path: 'reconnect', + loadChildren: () => CoreLoginHelper.getReconnectRouteModule(), + }, + ], canActivate: [redirectGuard], }, { diff --git a/src/core/features/settings/settings-lazy.module.ts b/src/core/features/settings/settings-lazy.module.ts deleted file mode 100644 index 6c7e0e531ab..00000000000 --- a/src/core/features/settings/settings-lazy.module.ts +++ /dev/null @@ -1,95 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -import { SHAREDFILES_PAGE_NAME } from '@features/sharedfiles/constants'; - -const sectionRoutes: Routes = [ - { - path: 'general', - loadComponent: () => import('@features/settings/pages/general/general'), - }, - { - path: 'spaceusage', - loadComponent: () => import('@features/settings/pages/space-usage/space-usage'), - }, - { - path: 'sync', - loadComponent: () => import('@features/settings/pages/synchronization/synchronization'), - }, - { - path: SHAREDFILES_PAGE_NAME, - loadChildren: () => import('@features/sharedfiles/sharedfiles-lazy.module'), - }, - { - path: 'about', - loadComponent: () => import('@features/settings/pages/about/about'), - }, -]; - -const mobileRoutes: Routes = [ - { - path: '', - loadComponent: () => import('@features/settings/pages/index/index'), - }, - ...sectionRoutes, -]; - -const tabletRoutes: Routes = [ - { - path: '', - loadComponent: () => import('@features/settings/pages/index/index'), - children: [ - { - path: '', - pathMatch: 'full', - redirectTo: 'general', - }, - ...sectionRoutes, - ], - }, -]; - -const routes: Routes = [ - ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), - ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), - { - path: 'about/deviceinfo', - loadComponent: () => import('@features/settings/pages/deviceinfo/deviceinfo'), - }, - { - path: 'about/deviceinfo/dev', - loadComponent: () => import('@features/settings/pages/dev/dev'), - }, - { - path: 'about/deviceinfo/dev/error-log', - loadComponent: () => import('@features/settings/pages/error-log/error-log'), - }, - { - path: 'about/licenses', - loadComponent: () => import('@features/settings/pages/licenses/licenses'), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreSettingsLazyModule {} diff --git a/src/core/features/settings/settings.module.ts b/src/core/features/settings/settings.module.ts index 72a98a2d846..800bcedf9d0 100644 --- a/src/core/features/settings/settings.module.ts +++ b/src/core/features/settings/settings.module.ts @@ -15,9 +15,12 @@ import { APP_INITIALIZER, NgModule, Type } from '@angular/core'; import { Routes } from '@angular/router'; -import { AppRoutingModule } from '@/app/app-routing.module'; +import { AppRoutingModule, conditionalRoutes } from '@/app/app-routing.module'; import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-routing.module'; import { CoreSettingsHelper } from './services/settings-helper'; +import { SHAREDFILES_PAGE_NAME } from '@features/sharedfiles/constants'; +import { getSharedFilesRoutes } from '@features/sharedfiles/sharedfiles.module'; +import { CoreScreen } from '@services/screen'; /** * Get settings services. @@ -34,17 +37,84 @@ export async function getSettingsServices(): Promise[]> { ]; } +const sectionRoutes: Routes = [ + { + path: 'general', + loadComponent: () => import('@features/settings/pages/general/general'), + }, + { + path: 'spaceusage', + loadComponent: () => import('@features/settings/pages/space-usage/space-usage'), + }, + { + path: 'sync', + loadComponent: () => import('@features/settings/pages/synchronization/synchronization'), + }, + { + path: SHAREDFILES_PAGE_NAME, + children: getSharedFilesRoutes(), + }, + { + path: 'about', + loadComponent: () => import('@features/settings/pages/about/about'), + }, +]; + +const mobileRoutes: Routes = [ + { + path: '', + loadComponent: () => import('@features/settings/pages/index/index'), + }, + ...sectionRoutes, +]; + +const tabletRoutes: Routes = [ + { + path: '', + loadComponent: () => import('@features/settings/pages/index/index'), + children: [ + { + path: '', + pathMatch: 'full', + redirectTo: 'general', + }, + ...sectionRoutes, + ], + }, +]; + +const settingsRoutes: Routes = [ + ...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile), + ...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet), + { + path: 'about/deviceinfo', + loadComponent: () => import('@features/settings/pages/deviceinfo/deviceinfo'), + }, + { + path: 'about/deviceinfo/dev', + loadComponent: () => import('@features/settings/pages/dev/dev'), + }, + { + path: 'about/deviceinfo/dev/error-log', + loadComponent: () => import('@features/settings/pages/error-log/error-log'), + }, + { + path: 'about/licenses', + loadComponent: () => import('@features/settings/pages/licenses/licenses'), + }, +]; + const appRoutes: Routes = [ { path: 'settings', - loadChildren: () => import('./settings-lazy.module'), + children: settingsRoutes, }, ]; const mainMenuMoreRoutes: Routes = [ { path: 'settings', - loadChildren: () => import('./settings-lazy.module'), + children: settingsRoutes, }, { path: 'preferences', diff --git a/src/core/features/sharedfiles/sharedfiles-lazy.module.ts b/src/core/features/sharedfiles/sharedfiles-lazy.module.ts deleted file mode 100644 index a2a43d6cf4a..00000000000 --- a/src/core/features/sharedfiles/sharedfiles-lazy.module.ts +++ /dev/null @@ -1,34 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -const routes: Routes = [ - { - path: 'choosesite', - loadComponent: () => import('@features/sharedfiles/pages/choose-site/choose-site'), - }, - { - path: 'list/:hash', - loadComponent: () => import('@features/sharedfiles/pages/list/list'), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreSharedFilesLazyModule {} diff --git a/src/core/features/sharedfiles/sharedfiles.module.ts b/src/core/features/sharedfiles/sharedfiles.module.ts index b7a543a2dab..a6271df64f9 100644 --- a/src/core/features/sharedfiles/sharedfiles.module.ts +++ b/src/core/features/sharedfiles/sharedfiles.module.ts @@ -41,10 +41,28 @@ export async function getSharedFilesServices(): Promise[]> { ]; } +/** + * Get the shared files routes. + * + * @returns Shared files routes. + */ +export function getSharedFilesRoutes(): Routes { + return [ + { + path: 'choosesite', + loadComponent: () => import('@features/sharedfiles/pages/choose-site/choose-site'), + }, + { + path: 'list/:hash', + loadComponent: () => import('@features/sharedfiles/pages/list/list'), + }, + ]; +} + const routes: Routes = [ { path: SHAREDFILES_PAGE_NAME, - loadChildren: () => import('./sharedfiles-lazy.module'), + children: getSharedFilesRoutes(), }, ]; diff --git a/src/core/features/user/user-course-lazy.module.ts b/src/core/features/user/user-course-lazy.module.ts deleted file mode 100644 index 82b7bd1f62d..00000000000 --- a/src/core/features/user/user-course-lazy.module.ts +++ /dev/null @@ -1,40 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -import { conditionalRoutes } from '@/app/app-routing.module'; -import { CoreScreen } from '@services/screen'; - -const routes: Routes = [ - { - path: '', - loadComponent: () => import('@features/user/pages/participants/participants'), - children: conditionalRoutes([ - { - path: ':userId', - loadComponent: () => import('@features/user/pages/profile/profile'), - data: { swipeManagerSource: 'participants' }, - }, - ], () => CoreScreen.isTablet), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreUserCourseLazyModule {} diff --git a/src/core/features/user/user-lazy.module.ts b/src/core/features/user/user-lazy.module.ts deleted file mode 100644 index 9f598229fe2..00000000000 --- a/src/core/features/user/user-lazy.module.ts +++ /dev/null @@ -1,39 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; - -const routes: Routes = [ - { - path: '', - redirectTo: 'profile', - pathMatch: 'full', - }, - { - path: 'profile', - loadComponent: () => import('@features/user/pages/profile/profile'), - }, - { - path: 'about', - loadComponent: () => import('@features/user/pages/about/about'), - }, -]; - -@NgModule({ - imports: [ - RouterModule.forChild(routes), - ], -}) -export default class CoreUserLazyModule {} diff --git a/src/core/features/user/user.module.ts b/src/core/features/user/user.module.ts index 5ee7c7fae9c..14c63720acf 100644 --- a/src/core/features/user/user.module.ts +++ b/src/core/features/user/user.module.ts @@ -69,7 +69,21 @@ const appRoutes: Routes = [ const routes: Routes = [ { path: 'user', - loadChildren: () => import('@features/user/user-lazy.module'), + children: [ + { + path: '', + redirectTo: 'profile', + pathMatch: 'full', + }, + { + path: 'profile', + loadComponent: () => import('@features/user/pages/profile/profile'), + }, + { + path: 'about', + loadComponent: () => import('@features/user/pages/about/about'), + }, + ], }, ...conditionalRoutes([ { @@ -85,7 +99,14 @@ const routes: Routes = [ const courseIndexRoutes: Routes = [ { path: PARTICIPANTS_PAGE_NAME, - loadChildren: () => import('@features/user/user-course-lazy.module'), + loadComponent: () => import('@features/user/pages/participants/participants'), + children: conditionalRoutes([ + { + path: ':userId', + loadComponent: () => import('@features/user/pages/profile/profile'), + data: { swipeManagerSource: 'participants' }, + }, + ], () => CoreScreen.isTablet), }, ];