Skip to content

Commit

Permalink
MOBILE-4759 chore: Remove basic lazy modules without provide: ROUTES
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Feb 4, 2025
1 parent 3e4edf9 commit 8a63495
Show file tree
Hide file tree
Showing 30 changed files with 572 additions and 1,022 deletions.
58 changes: 0 additions & 58 deletions src/addons/badges/badges-lazy.module.ts

This file was deleted.

36 changes: 35 additions & 1 deletion src/addons/badges/badges.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -40,6 +42,38 @@ export async function getBadgesServices(): Promise<Type<unknown>[]> {
];
}

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',
Expand All @@ -48,7 +82,7 @@ const mainMenuRoutes: Routes = [
},
{
path: 'badges',
loadChildren: () => import('./badges-lazy.module'),
children: routes,
},
{
path: 'badgeclass/:badgeId',
Expand Down
60 changes: 0 additions & 60 deletions src/addons/competency/competency-course-details-lazy.module.ts

This file was deleted.

75 changes: 0 additions & 75 deletions src/addons/competency/competency-learning-plans-lazy.module.ts

This file was deleted.

109 changes: 105 additions & 4 deletions src/addons/competency/competency.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -46,18 +52,113 @@ export async function getCompetencyServices(): Promise<Type<unknown>[]> {
];
}

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

Expand Down
Loading

0 comments on commit 8a63495

Please sign in to comment.