Merge pull request #2638 from NoelDeMartin/MOBILE-3320

MOBILE-3320: Refactor lazy modules and configure Github Actions
main
Dani Palou 2020-12-01 12:06:09 +01:00 committed by GitHub
commit 15de34a31a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 529 additions and 393 deletions

19
.github/workflows/testing.yml vendored 100644
View File

@ -0,0 +1,19 @@
name: Testing
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm ci
- run: npm run lint
- run: npm run test:ci
- run: npm run build:prod

View File

@ -14,11 +14,11 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { AddonPrivateFilesInitModule } from './privatefiles/privatefiles-init.module'; import { AddonPrivateFilesModule } from './privatefiles/privatefiles.module';
@NgModule({ @NgModule({
imports: [ imports: [
AddonPrivateFilesInitModule, AddonPrivateFilesModule,
], ],
}) })
export class AddonsModule {} export class AddonsModule {}

View File

@ -1,45 +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 { Routes } from '@angular/router';
import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
import { AddonPrivateFilesMainMenuHandler } from './services/handlers/mainmenu';
const routes: Routes = [
{
path: 'addon-privatefiles',
loadChildren: () => import('@/addons/privatefiles/privatefiles.module').then(m => m.AddonPrivateFilesModule),
},
];
@NgModule({
imports: [CoreMainMenuRoutingModule.forChild(routes)],
exports: [CoreMainMenuRoutingModule],
providers: [
AddonPrivateFilesMainMenuHandler,
],
})
export class AddonPrivateFilesInitModule {
constructor(
mainMenuDelegate: CoreMainMenuDelegate,
mainMenuHandler: AddonPrivateFilesMainMenuHandler,
) {
mainMenuDelegate.registerHandler(mainMenuHandler);
}
}

View File

@ -31,4 +31,4 @@ const routes: Routes = [
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule], exports: [RouterModule],
}) })
export class AddonPrivateFilesRoutingModule {} export class AddonPrivateFilesLazyModule {}

View File

@ -13,13 +13,33 @@
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes } from '@angular/router';
import { AddonPrivateFilesRoutingModule } from './privatefiles-routing.module'; import { CoreMainMenuDelegate } from '@features/mainmenu/services/mainmenu-delegate';
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
import { AddonPrivateFilesMainMenuHandler } from './services/handlers/mainmenu';
const routes: Routes = [
{
path: AddonPrivateFilesMainMenuHandler.PAGE_NAME,
loadChildren: () => import('@/addons/privatefiles/privatefiles-lazy.module').then(m => m.AddonPrivateFilesLazyModule),
},
];
@NgModule({ @NgModule({
imports: [ imports: [CoreMainMenuRoutingModule.forChild({ children: routes })],
AddonPrivateFilesRoutingModule, exports: [CoreMainMenuRoutingModule],
providers: [
AddonPrivateFilesMainMenuHandler,
], ],
declarations: [],
}) })
export class AddonPrivateFilesModule {} export class AddonPrivateFilesModule {
constructor(
mainMenuDelegate: CoreMainMenuDelegate,
mainMenuHandler: AddonPrivateFilesMainMenuHandler,
) {
mainMenuDelegate.registerHandler(mainMenuHandler);
}
}

View File

@ -23,6 +23,8 @@ import { AddonPrivateFiles } from '@/addons/privatefiles/services/privatefiles';
@Injectable() @Injectable()
export class AddonPrivateFilesMainMenuHandler implements CoreMainMenuHandler { export class AddonPrivateFilesMainMenuHandler implements CoreMainMenuHandler {
static readonly PAGE_NAME = 'private';
name = 'AddonPrivateFiles'; name = 'AddonPrivateFiles';
priority = 400; priority = 400;
@ -44,7 +46,7 @@ export class AddonPrivateFilesMainMenuHandler implements CoreMainMenuHandler {
return { return {
icon: 'fas-folder', icon: 'fas-folder',
title: 'addon.privatefiles.files', title: 'addon.privatefiles.files',
page: 'addon-privatefiles', page: AddonPrivateFilesMainMenuHandler.PAGE_NAME,
subPage: 'root', subPage: 'root',
class: 'addon-privatefiles-handler', class: 'addon-privatefiles-handler',
}; };

View File

@ -12,35 +12,49 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; import { PreloadAllModules, RouterModule, ROUTES, Routes } from '@angular/router';
import { AuthGuard } from '@guards/auth'; import { CoreArray } from '@singletons/array';
const routes: Routes = [ function buildAppRoutes(injector: Injector): Routes {
{ return CoreArray.flatten(injector.get<Routes[]>(APP_ROUTES, []));
path: 'login', }
loadChildren: () => import('@features/login/login.module').then( m => m.CoreLoginModule),
}, export type ModuleRoutes = { children: Routes; siblings: Routes };
{
path: 'settings', export function resolveModuleRoutes(injector: Injector, token: InjectionToken<Partial<ModuleRoutes>[]>): ModuleRoutes {
loadChildren: () => import('@features/settings/settings.module').then( m => m.CoreSettingsModule), const routes = injector.get(token, []);
},
{ return {
path: '', children: CoreArray.flatten(routes.map(r => r.children || [])),
loadChildren: () => import('@features/mainmenu/mainmenu.module').then( m => m.CoreMainMenuModule), siblings: CoreArray.flatten(routes.map(r => r.siblings || [])),
canActivate: [AuthGuard], };
canLoad: [AuthGuard], }
},
]; export const APP_ROUTES = new InjectionToken('APP_ROUTES');
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forRoot(routes, { RouterModule.forRoot([], {
preloadingStrategy: PreloadAllModules, preloadingStrategy: PreloadAllModules,
relativeLinkResolution: 'corrected', relativeLinkResolution: 'corrected',
}), }),
], ],
providers: [
{ provide: ROUTES, multi: true, useFactory: buildAppRoutes, deps: [Injector] },
],
exports: [RouterModule], exports: [RouterModule],
}) })
export class AppRoutingModule { } export class AppRoutingModule {
static forChild(routes: Routes): ModuleWithProviders<AppRoutingModule> {
return {
ngModule: AppRoutingModule,
providers: [
{ provide: APP_ROUTES, multi: true, useValue: routes },
],
};
}
}

View File

@ -16,19 +16,13 @@ import { NgModule } from '@angular/core';
import { CORE_SITE_SCHEMAS } from '@services/sites'; import { CORE_SITE_SCHEMAS } from '@services/sites';
import { import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/db/course';
SITE_SCHEMA as COURSE_SITE_SCHEMA,
OFFLINE_SITE_SCHEMA as COURSE_OFFLINE_SITE_SCHEMA,
} from './services/db/course';
@NgModule({ @NgModule({
providers: [ providers: [
{ {
provide: CORE_SITE_SCHEMAS, provide: CORE_SITE_SCHEMAS,
useValue: [ useValue: [SITE_SCHEMA, OFFLINE_SITE_SCHEMA],
COURSE_SITE_SCHEMA,
COURSE_OFFLINE_SITE_SCHEMA,
],
multi: true, multi: true,
}, },
], ],

View File

@ -0,0 +1,64 @@
// (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: 'my',
pathMatch: 'full',
},
{
path: 'categories',
redirectTo: 'categories/root', // Fake "id".
pathMatch: 'full',
},
{
path: 'categories/:id',
loadChildren: () =>
import('./pages/categories/categories.module')
.then(m => m.CoreCoursesCategoriesPageModule),
},
{
path: 'all',
loadChildren: () =>
import('./pages/available-courses/available-courses.module')
.then(m => m.CoreCoursesAvailableCoursesPageModule),
},
{
path: 'search',
loadChildren: () =>
import('./pages/search/search.module')
.then(m => m.CoreCoursesSearchPageModule),
},
{
path: 'my',
loadChildren: () =>
import('./pages/my-courses/my-courses.module')
.then(m => m.CoreCoursesMyCoursesPageModule),
},
{
path: 'preview',
loadChildren: () =>
import('./pages/course-preview/course-preview.module')
.then(m => m.CoreCoursesCoursePreviewPageModule),
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
})
export class CoreCoursesLazyModule {}

View File

@ -13,82 +13,43 @@
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { Routes } from '@angular/router';
import { CoreHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
import { CoreHomeDelegate } from '@features/mainmenu/services/home-delegate'; import { CoreMainMenuHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
import { CoreMainMenuHomeDelegate } from '@features/mainmenu/services/home-delegate';
import { CoreDashboardHomeHandler } from './services/handlers/dashboard-home'; import { CoreDashboardHomeHandler } from './services/handlers/dashboard-home';
import { CoreCoursesMyCoursesHomeHandler } from './services/handlers/my-courses.home'; import { CoreCoursesMyCoursesHomeHandler } from './services/handlers/my-courses.home';
const homeRoutes: Routes = [ const mainMenuHomeChildrenRoutes: Routes = [
{ {
path: 'dashboard', path: '',
loadChildren: () => pathMatch: 'full',
import('@features/courses/pages/dashboard/dashboard.module').then(m => m.CoreCoursesDashboardPageModule), redirectTo: CoreDashboardHomeHandler.PAGE_NAME,
}, },
{ {
path: 'courses/my', path: CoreDashboardHomeHandler.PAGE_NAME,
loadChildren: () => loadChildren: () => import('./pages/dashboard/dashboard.module').then(m => m.CoreCoursesDashboardPageModule),
import('@features/courses/pages/my-courses/my-courses.module') },
.then(m => m.CoreCoursesMyCoursesPageModule), {
path: CoreCoursesMyCoursesHomeHandler.PAGE_NAME,
loadChildren: () => import('./pages/my-courses/my-courses.module').then(m => m.CoreCoursesMyCoursesPageModule),
}, },
]; ];
const routes: Routes = [ const mainMenuHomeSiblingRoutes: Routes = [
{ {
path: 'courses', path: 'courses',
children: [ loadChildren: () => import('./courses-lazy.module').then(m => m.CoreCoursesLazyModule),
{
path: '',
redirectTo: 'my',
pathMatch: 'full',
},
{
path: 'categories',
redirectTo: 'categories/root', // Fake "id".
pathMatch: 'full',
},
{
path: 'categories/:id',
loadChildren: () =>
import('@features/courses/pages/categories/categories.module')
.then(m => m.CoreCoursesCategoriesPageModule),
},
{
path: 'all',
loadChildren: () =>
import('@features/courses/pages/available-courses/available-courses.module')
.then(m => m.CoreCoursesAvailableCoursesPageModule),
},
{
path: 'search',
loadChildren: () =>
import('@features/courses/pages/search/search.module')
.then(m => m.CoreCoursesSearchPageModule),
},
{
path: 'my',
loadChildren: () =>
import('@features/courses/pages/my-courses/my-courses.module')
.then(m => m.CoreCoursesMyCoursesPageModule),
},
{
path: 'preview',
loadChildren: () =>
import('@features/courses/pages/course-preview/course-preview.module')
.then(m => m.CoreCoursesCoursePreviewPageModule),
},
],
}, },
]; ];
@NgModule({ @NgModule({
imports: [ imports: [
CoreHomeRoutingModule.forChild(homeRoutes), CoreMainMenuHomeRoutingModule.forChild({
RouterModule.forChild(routes), children: mainMenuHomeChildrenRoutes,
], siblings: mainMenuHomeSiblingRoutes,
exports: [ }),
CoreHomeRoutingModule,
RouterModule,
], ],
providers: [ providers: [
CoreDashboardHomeHandler, CoreDashboardHomeHandler,
@ -98,7 +59,7 @@ const routes: Routes = [
export class CoreCoursesModule { export class CoreCoursesModule {
constructor( constructor(
homeDelegate: CoreHomeDelegate, homeDelegate: CoreMainMenuHomeDelegate,
coursesDashboardHandler: CoreDashboardHomeHandler, coursesDashboardHandler: CoreDashboardHomeHandler,
coursesMyCoursesHandler: CoreCoursesMyCoursesHomeHandler, coursesMyCoursesHandler: CoreCoursesMyCoursesHomeHandler,
) { ) {

View File

@ -90,7 +90,7 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy {
* Go to search courses. * Go to search courses.
*/ */
openSearch(): void { openSearch(): void {
this.navCtrl.navigateForward(['/courses/search']); this.navCtrl.navigateForward(['/main/home/courses/search']);
} }
/** /**

View File

@ -200,7 +200,7 @@ export class CoreCoursesMyCoursesPage implements OnInit, OnDestroy {
* Go to search courses. * Go to search courses.
*/ */
openSearch(): void { openSearch(): void {
this.navCtrl.navigateForward(['/courses/search']); this.navCtrl.navigateForward(['/main/home/courses/search']);
} }
/** /**

View File

@ -13,13 +13,15 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate'; import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
/** /**
* Handler to add dashboard into home page. * Handler to add dashboard into home page.
*/ */
Injectable(); Injectable();
export class CoreDashboardHomeHandler implements CoreHomeHandler { export class CoreDashboardHomeHandler implements CoreMainMenuHomeHandler {
static readonly PAGE_NAME = 'dashboard';
name = 'CoreCoursesDashboard'; name = 'CoreCoursesDashboard';
priority = 1100; priority = 1100;
@ -50,10 +52,10 @@ export class CoreDashboardHomeHandler implements CoreHomeHandler {
* *
* @return Data needed to render the handler. * @return Data needed to render the handler.
*/ */
getDisplayData(): CoreHomeHandlerToDisplay { getDisplayData(): CoreMainMenuHomeHandlerToDisplay {
return { return {
title: 'core.courses.mymoodle', title: 'core.courses.mymoodle',
page: 'dashboard', page: CoreDashboardHomeHandler.PAGE_NAME,
class: 'core-courses-dashboard-handler', class: 'core-courses-dashboard-handler',
icon: 'fas-tachometer-alt', icon: 'fas-tachometer-alt',
selectPriority: 1000, selectPriority: 1000,

View File

@ -13,13 +13,15 @@
// limitations under the License. // limitations under the License.
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate'; import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
/** /**
* Handler to add my courses into home page. * Handler to add my courses into home page.
*/ */
Injectable(); Injectable();
export class CoreCoursesMyCoursesHomeHandler implements CoreHomeHandler { export class CoreCoursesMyCoursesHomeHandler implements CoreMainMenuHomeHandler {
static readonly PAGE_NAME = 'courses';
name = 'CoreCoursesMyCourses'; name = 'CoreCoursesMyCourses';
priority = 900; priority = 900;
@ -50,10 +52,10 @@ export class CoreCoursesMyCoursesHomeHandler implements CoreHomeHandler {
* *
* @return Data needed to render the handler. * @return Data needed to render the handler.
*/ */
getDisplayData(): CoreHomeHandlerToDisplay { getDisplayData(): CoreMainMenuHomeHandlerToDisplay {
return { return {
title: 'core.courses.mycourses', title: 'core.courses.mycourses',
page: 'courses/my', page: CoreCoursesMyCoursesHomeHandler.PAGE_NAME,
class: 'core-courses-my-courses-handler', class: 'core-courses-my-courses-handler',
icon: 'fas-graduation-cap', icon: 'fas-graduation-cap',
selectPriority: 900, selectPriority: 900,

View File

@ -17,20 +17,22 @@ import { NgModule } from '@angular/core';
import { CoreCourseModule } from './course/course.module'; import { CoreCourseModule } from './course/course.module';
import { CoreCoursesModule } from './courses/courses.module'; import { CoreCoursesModule } from './courses/courses.module';
import { CoreEmulatorModule } from './emulator/emulator.module'; import { CoreEmulatorModule } from './emulator/emulator.module';
import { CoreFileUploaderInitModule } from './fileuploader/fileuploader-init.module'; import { CoreFileUploaderModule } from './fileuploader/fileuploader.module';
import { CoreLoginModule } from './login/login.module'; import { CoreLoginModule } from './login/login.module';
import { CoreSettingsInitModule } from './settings/settings-init.module'; import { CoreMainMenuModule } from './mainmenu/mainmenu.module';
import { CoreSiteHomeInitModule } from './sitehome/sitehome-init.module'; import { CoreSettingsModule } from './settings/settings.module';
import { CoreSiteHomeModule } from './sitehome/sitehome.module';
@NgModule({ @NgModule({
imports: [ imports: [
CoreEmulatorModule,
CoreLoginModule,
CoreCourseModule, CoreCourseModule,
CoreCoursesModule, CoreCoursesModule,
CoreSettingsInitModule, CoreEmulatorModule,
CoreFileUploaderInitModule, CoreFileUploaderModule,
CoreSiteHomeInitModule, CoreLoginModule,
CoreMainMenuModule,
CoreSettingsModule,
CoreSiteHomeModule,
], ],
}) })
export class CoreFeaturesModule {} export class CoreFeaturesModule {}

View File

@ -33,7 +33,7 @@ import { CoreFileUploaderVideoHandler } from './services/handlers/video';
CoreFileUploaderVideoHandler, CoreFileUploaderVideoHandler,
], ],
}) })
export class CoreFileUploaderInitModule { export class CoreFileUploaderModule {
constructor( constructor(
delegate: CoreFileUploaderDelegate, delegate: CoreFileUploaderDelegate,

View File

@ -14,6 +14,14 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { CommonModule } from '@angular/common';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreLoginSiteHelpComponent } from './components/site-help/site-help';
import { CoreLoginSiteOnboardingComponent } from './components/site-onboarding/site-onboarding';
const routes: Routes = [ const routes: Routes = [
{ {
@ -62,7 +70,17 @@ const routes: Routes = [
]; ];
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [
exports: [RouterModule], CommonModule,
IonicModule,
TranslateModule.forChild(),
CoreComponentsModule,
CoreDirectivesModule,
RouterModule.forChild(routes),
],
declarations: [
CoreLoginSiteHelpComponent,
CoreLoginSiteOnboardingComponent,
],
}) })
export class CoreLoginRoutingModule {} export class CoreLoginLazyModule {}

View File

@ -13,32 +13,18 @@
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { Routes } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '@components/components.module'; import { AppRoutingModule } from '@/app/app-routing.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreLoginRoutingModule } from './login-routing.module'; const appRoutes: Routes = [
import { CoreLoginSiteHelpComponent } from './components/site-help/site-help'; {
import { CoreLoginSiteOnboardingComponent } from './components/site-onboarding/site-onboarding'; path: 'login',
loadChildren: () => import('./login-lazy.module').then(m => m.CoreLoginLazyModule),
},
];
@NgModule({ @NgModule({
imports: [ imports: [AppRoutingModule.forChild(appRoutes)],
CoreLoginRoutingModule,
CommonModule,
IonicModule,
TranslateModule.forChild(),
CoreComponentsModule,
CoreDirectivesModule,
],
declarations: [
CoreLoginSiteHelpComponent,
CoreLoginSiteOnboardingComponent,
],
exports: [
CoreLoginSiteHelpComponent,
CoreLoginSiteOnboardingComponent,
],
}) })
export class CoreLoginModule {} export class CoreLoginModule {}

View File

@ -0,0 +1,75 @@
// (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 { CommonModule } from '@angular/common';
import { Injector, NgModule } from '@angular/core';
import { ROUTES, Routes } from '@angular/router';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { CorePipesModule } from '@pipes/pipes.module';
import { resolveModuleRoutes } from '@/app/app-routing.module';
import { MAIN_MENU_ROUTES } from './mainmenu-routing.module';
import { CoreMainMenuPage } from './pages/menu/menu';
import { CoreMainMenuHomeHandler } from './services/handlers/mainmenu';
function buildRoutes(injector: Injector): Routes {
const routes = resolveModuleRoutes(injector, MAIN_MENU_ROUTES);
return [
{
path: '',
component: CoreMainMenuPage,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: CoreMainMenuHomeHandler.PAGE_NAME,
},
{
path: CoreMainMenuHomeHandler.PAGE_NAME,
loadChildren: () => import('./pages/home/home.module').then(m => m.CoreMainMenuHomePageModule),
},
{
path: 'more',
loadChildren: () => import('./pages/more/more.module').then(m => m.CoreMainMenuMorePageModule),
},
...routes.children,
],
},
...routes.siblings,
];
}
@NgModule({
imports: [
CommonModule,
IonicModule,
TranslateModule,
CoreComponentsModule,
CoreDirectivesModule,
CorePipesModule,
],
declarations: [
CoreMainMenuPage,
],
providers: [
CoreMainMenuHomeHandler,
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
],
})
export class CoreMainMenuLazyModule {}

View File

@ -12,54 +12,16 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core'; import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
import { RouterModule, ROUTES, Routes } from '@angular/router';
import { CoreArray } from '@singletons/array'; import { ModuleRoutes } from '@/app/app-routing.module';
import { CoreMainMenuPage } from './pages/menu/menu';
import { CoreMainMenuMorePage } from './pages/more/more';
function buildMainMenuRoutes(injector: Injector): Routes {
const routes = CoreArray.flatten(injector.get<Routes[]>(MAIN_MENU_ROUTES, []));
return [
{
path: '',
component: CoreMainMenuPage,
children: [
{
path: 'home', // @todo: Add this route dynamically.
loadChildren: () => import('./pages/home/home.module').then(m => m.CoreHomePageModule),
},
{
path: 'more',
children: [
{
path: '',
component: CoreMainMenuMorePage,
},
...routes,
],
},
...routes,
// @todo handle 404.
],
},
];
}
export const MAIN_MENU_ROUTES = new InjectionToken('MAIN_MENU_ROUTES'); export const MAIN_MENU_ROUTES = new InjectionToken('MAIN_MENU_ROUTES');
@NgModule({ @NgModule()
providers: [
{ provide: ROUTES, multi: true, useFactory: buildMainMenuRoutes, deps: [Injector] },
],
exports: [RouterModule],
})
export class CoreMainMenuRoutingModule { export class CoreMainMenuRoutingModule {
static forChild(routes: Routes): ModuleWithProviders<CoreMainMenuRoutingModule> { static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuRoutingModule> {
return { return {
ngModule: CoreMainMenuRoutingModule, ngModule: CoreMainMenuRoutingModule,
providers: [ providers: [

View File

@ -13,44 +13,36 @@
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { Routes } from '@angular/router';
import { AuthGuard } from '@guards/auth';
import { IonicModule } from '@ionic/angular'; import { AppRoutingModule } from '@/app/app-routing.module';
import { TranslateModule } from '@ngx-translate/core';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreMainMenuDelegate } from './services/mainmenu-delegate'; import { CoreMainMenuDelegate } from './services/mainmenu-delegate';
import { CoreMainMenuHomeHandler } from './services/handlers/mainmenu';
import { CoreMainMenuRoutingModule } from './mainmenu-routing.module'; const appRoutes: Routes = [
import { CoreMainMenuPage } from './pages/menu/menu'; {
import { CoreMainMenuMorePage } from './pages/more/more'; path: '',
import { CoreHomeMainMenuHandler } from './services/handlers/mainmenu'; pathMatch: 'full',
redirectTo: 'main',
},
{
path: 'main',
loadChildren: () => import('./mainmenu-lazy.module').then(m => m.CoreMainMenuLazyModule),
canActivate: [AuthGuard],
canLoad: [AuthGuard],
},
];
@NgModule({ @NgModule({
imports: [ imports: [AppRoutingModule.forChild(appRoutes)],
CommonModule,
IonicModule,
CoreMainMenuRoutingModule,
TranslateModule.forChild(),
CoreComponentsModule,
CoreDirectivesModule,
],
declarations: [
CoreMainMenuPage,
CoreMainMenuMorePage,
],
providers: [
CoreHomeMainMenuHandler,
],
}) })
export class CoreMainMenuModule { export class CoreMainMenuModule {
constructor( constructor(
mainMenuDelegate: CoreMainMenuDelegate, mainMenuDelegate: CoreMainMenuDelegate,
homeMainMenuHandler: CoreHomeMainMenuHandler, homeMainMenuHandler: CoreMainMenuHomeHandler,
) { ) {
mainMenuDelegate.registerHandler(homeMainMenuHandler); mainMenuDelegate.registerHandler(homeMainMenuHandler);
} }

View File

@ -12,43 +12,20 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { InjectionToken, Injector, ModuleWithProviders, NgModule } from '@angular/core'; import { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
import { RouterModule, ROUTES, Routes } from '@angular/router';
import { CoreArray } from '@singletons/array'; import { ModuleRoutes } from '@/app/app-routing.module';
import { CoreHomePage } from './home'; export const MAIN_MENU_HOME_ROUTES = new InjectionToken('MAIN_MENU_HOME_ROUTES');
function buildHomeRoutes(injector: Injector): Routes { @NgModule()
const routes = CoreArray.flatten(injector.get<Routes[]>(HOME_ROUTES, [])); export class CoreMainMenuHomeRoutingModule {
return [ static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuHomeRoutingModule> {
{
path: '',
component: CoreHomePage,
children: [
...routes,
// @todo handle 404.
],
},
];
}
export const HOME_ROUTES = new InjectionToken('HOME_ROUTES');
@NgModule({
providers: [
{ provide: ROUTES, multi: true, useFactory: buildHomeRoutes, deps: [Injector] },
],
exports: [RouterModule],
})
export class CoreHomeRoutingModule {
static forChild(routes: Routes): ModuleWithProviders<CoreHomeRoutingModule> {
return { return {
ngModule: CoreHomeRoutingModule, ngModule: CoreMainMenuHomeRoutingModule,
providers: [ providers: [
{ provide: HOME_ROUTES, multi: true, useValue: routes }, { provide: MAIN_MENU_HOME_ROUTES, multi: true, useValue: routes },
], ],
}; };
} }

View File

@ -12,16 +12,31 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { Injector, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { RouterModule, ROUTES, Routes } from '@angular/router';
import { IonicModule } from '@ionic/angular'; import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { resolveModuleRoutes } from '@/app/app-routing.module';
import { CoreComponentsModule } from '@components/components.module'; import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module'; import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreHomePage } from './home'; import { CoreMainMenuHomePage } from './home';
import { CoreHomeRoutingModule } from './home-routing.module'; import { MAIN_MENU_HOME_ROUTES } from './home-routing.module';
function buildRoutes(injector: Injector): Routes {
const routes = resolveModuleRoutes(injector, MAIN_MENU_HOME_ROUTES);
return [
{
path: '',
component: CoreMainMenuHomePage,
children: routes.children,
},
...routes.siblings,
];
}
@NgModule({ @NgModule({
imports: [ imports: [
@ -30,10 +45,15 @@ import { CoreHomeRoutingModule } from './home-routing.module';
TranslateModule.forChild(), TranslateModule.forChild(),
CoreComponentsModule, CoreComponentsModule,
CoreDirectivesModule, CoreDirectivesModule,
CoreHomeRoutingModule, ],
providers: [
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
], ],
declarations: [ declarations: [
CoreHomePage, CoreMainMenuHomePage,
],
exports: [
RouterModule,
], ],
}) })
export class CoreHomePageModule {} export class CoreMainMenuHomePageModule {}

View File

@ -18,39 +18,36 @@ import { Subscription } from 'rxjs';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreTabsComponent } from '@components/tabs/tabs'; import { CoreTabsComponent } from '@components/tabs/tabs';
import { CoreHomeDelegate, CoreHomeHandlerToDisplay } from '../../services/home-delegate'; import { CoreMainMenuHomeDelegate, CoreMainMenuHomeHandlerToDisplay } from '../../services/home-delegate';
/** /**
* Page that displays the Home. * Page that displays the Home.
*/ */
@Component({ @Component({
selector: 'page-core-home', selector: 'page-core-mainmenu-home',
templateUrl: 'home.html', templateUrl: 'home.html',
styleUrls: ['home.scss'], styleUrls: ['home.scss'],
}) })
export class CoreHomePage implements OnInit { export class CoreMainMenuHomePage implements OnInit {
@ViewChild(CoreTabsComponent) tabsComponent?: CoreTabsComponent; @ViewChild(CoreTabsComponent) tabsComponent?: CoreTabsComponent;
siteName!: string; siteName!: string;
tabs: CoreHomeHandlerToDisplay[] = []; tabs: CoreMainMenuHomeHandlerToDisplay[] = [];
loaded = false; loaded = false;
selectedTab?: number; selectedTab?: number;
protected subscription?: Subscription; protected subscription?: Subscription;
protected updateSiteObserver?: CoreEventObserver; protected updateSiteObserver?: CoreEventObserver;
constructor( constructor(protected homeDelegate: CoreMainMenuHomeDelegate) {}
protected homeDelegate: CoreHomeDelegate,
) {
this.loadSiteName();
}
/** /**
* Initialize the component. * Initialize the component.
*/ */
ngOnInit(): void { ngOnInit(): void {
this.loadSiteName();
this.subscription = this.homeDelegate.getHandlersObservable().subscribe((handlers) => { this.subscription = this.homeDelegate.getHandlersObservable().subscribe((handlers) => {
handlers && this.initHandlers(handlers); handlers && this.initHandlers(handlers);
}); });
@ -64,10 +61,10 @@ export class CoreHomePage implements OnInit {
/** /**
* Init handlers on change (size or handlers). * Init handlers on change (size or handlers).
*/ */
initHandlers(handlers: CoreHomeHandlerToDisplay[]): void { initHandlers(handlers: CoreMainMenuHomeHandlerToDisplay[]): void {
// Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab. // Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab.
const newTabs: CoreHomeHandlerToDisplay[] = handlers.map((handler) => { const newTabs: CoreMainMenuHomeHandlerToDisplay[] = handlers.map((handler) => {
handler.page = '/home/' + handler.page; handler.page = '/main/home/' + handler.page;
// Check if the handler is already in the tabs list. If so, use it. // Check if the handler is already in the tabs list. If so, use it.
const tab = this.tabs.find((tab) => tab.title == handler.title); const tab = this.tabs.find((tab) => tab.title == handler.title);

View File

@ -0,0 +1,33 @@
// (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 { InjectionToken, ModuleWithProviders, NgModule } from '@angular/core';
import { ModuleRoutes } from '@/app/app-routing.module';
export const MAIN_MENU_MORE_ROUTES = new InjectionToken('MAIN_MENU_MORE_ROUTES');
@NgModule()
export class CoreMainMenuMoreRoutingModule {
static forChild(routes: Partial<ModuleRoutes>): ModuleWithProviders<CoreMainMenuMoreRoutingModule> {
return {
ngModule: CoreMainMenuMoreRoutingModule,
providers: [
{ provide: MAIN_MENU_MORE_ROUTES, multi: true, useValue: routes },
],
};
}
}

View File

@ -0,0 +1,59 @@
// (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 { Injector, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, ROUTES, Routes } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { TranslateModule } from '@ngx-translate/core';
import { resolveModuleRoutes } from '@/app/app-routing.module';
import { CoreComponentsModule } from '@components/components.module';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreMainMenuMorePage } from './more';
import { MAIN_MENU_MORE_ROUTES } from './more-routing.module';
function buildRoutes(injector: Injector): Routes {
const routes = resolveModuleRoutes(injector, MAIN_MENU_MORE_ROUTES);
return [
{
path: '',
component: CoreMainMenuMorePage,
children: routes.children,
},
...routes.siblings,
];
}
@NgModule({
imports: [
CommonModule,
IonicModule,
TranslateModule.forChild(),
CoreComponentsModule,
CoreDirectivesModule,
],
providers: [
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
],
declarations: [
CoreMainMenuMorePage,
],
exports: [
RouterModule,
],
})
export class CoreMainMenuMorePageModule {}

View File

@ -18,10 +18,12 @@ import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../mainmenu-delega
/** /**
* Handler to add Home into main menu. * Handler to add Home into main menu.
*/ */
Injectable(); @Injectable({ providedIn: 'root' })
export class CoreHomeMainMenuHandler implements CoreMainMenuHandler { export class CoreMainMenuHomeHandler implements CoreMainMenuHandler {
name = 'CoreHome'; static readonly PAGE_NAME = 'home';
name = 'CoreMainMenuHome';
priority = 1100; priority = 1100;
/** /**
@ -54,7 +56,7 @@ export class CoreHomeMainMenuHandler implements CoreMainMenuHandler {
return { return {
icon: 'fa-home', icon: 'fa-home',
title: 'core.mainmenu.home', title: 'core.mainmenu.home',
page: 'home', page: CoreMainMenuHomeHandler.PAGE_NAME,
// @todo: subPage? The page can change due to core-tabs. // @todo: subPage? The page can change due to core-tabs.
class: 'core-home-handler', class: 'core-home-handler',
}; };

View File

@ -21,12 +21,12 @@ import { CoreSortedDelegate } from '@classes/delegate-sorted';
/** /**
* Interface that all home handlers must implement. * Interface that all home handlers must implement.
*/ */
export type CoreHomeHandler = CoreDelegateDisplayHandler<CoreHomeHandlerToDisplay>; export type CoreMainMenuHomeHandler = CoreDelegateDisplayHandler<CoreMainMenuHomeHandlerToDisplay>;
/** /**
* Data needed to render a main menu handler. It's returned by the handler. * Data needed to render a main menu handler. It's returned by the handler.
*/ */
export interface CoreHomeHandlerData { export interface CoreMainMenuHomeHandlerData {
/** /**
* Name of the page to load for the handler. * Name of the page to load for the handler.
*/ */
@ -71,7 +71,7 @@ export interface CoreHomeHandlerData {
/** /**
* Data returned by the delegate for each handler. * Data returned by the delegate for each handler.
*/ */
export interface CoreHomeHandlerToDisplay extends CoreDelegateToDisplay, CoreHomeHandlerData { export interface CoreMainMenuHomeHandlerToDisplay extends CoreDelegateToDisplay, CoreMainMenuHomeHandlerData {
/** /**
* Priority to select handler. * Priority to select handler.
*/ */
@ -85,12 +85,12 @@ export interface CoreHomeHandlerToDisplay extends CoreDelegateToDisplay, CoreHom
@Injectable({ @Injectable({
providedIn: 'root', providedIn: 'root',
}) })
export class CoreHomeDelegate extends CoreSortedDelegate<CoreHomeHandlerToDisplay, CoreHomeHandler> { export class CoreMainMenuHomeDelegate extends CoreSortedDelegate<CoreMainMenuHomeHandlerToDisplay, CoreMainMenuHomeHandler> {
protected featurePrefix = 'CoreHomeDelegate_'; protected featurePrefix = 'CoreMainMenuHomeDelegate_';
constructor() { constructor() {
super('CoreHomeDelegate'); super('CoreMainMenuHomeDelegate');
} }
} }

View File

@ -1,48 +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 { Routes } from '@angular/router';
import { CoreMainMenuRoutingModule } from '@features/mainmenu/mainmenu-routing.module';
const routes: Routes = [
{
path: 'settings',
loadChildren: () => import('@features/settings/settings.module').then(m => m.CoreSettingsModule),
},
{
path: 'preferences',
loadChildren: () => import('@features/settings/pages/site/site.module').then(m => m.CoreSitePreferencesPageModule),
},
];
@NgModule({
imports: [
CoreMainMenuRoutingModule.forChild(routes),
],
exports: [
CoreMainMenuRoutingModule,
],
providers: [
],
})
export class CoreSettingsInitModule {
constructor() {
// @todo
// settingsHelper.initDomSettings();
}
}

View File

@ -26,14 +26,12 @@ const routes: Routes = [
}, },
{ {
path: 'spaceusage', path: 'spaceusage',
loadChildren: () => loadChildren: () => import('./pages/space-usage/space-usage.module').then(m => m.CoreSettingsSpaceUsagePageModule),
import('@features/settings/pages/space-usage/space-usage.module')
.then(m => m.CoreSettingsSpaceUsagePageModule),
}, },
{ {
path: 'sync', path: 'sync',
loadChildren: () => loadChildren: () =>
import('@features/settings/pages/synchronization/synchronization.module') import('./pages/synchronization/synchronization.module')
.then(m => m.CoreSettingsSynchronizationPageModule), .then(m => m.CoreSettingsSynchronizationPageModule),
}, },
{ {
@ -44,6 +42,5 @@ const routes: Routes = [
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
}) })
export class CoreSettingsRoutingModule {} export class CoreSettingsLazyModule {}

View File

@ -12,13 +12,44 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import { NgModule } from '@angular/core'; import { APP_INITIALIZER, NgModule } from '@angular/core';
import { Routes } from '@angular/router';
import { CoreSettingsRoutingModule } from './settings-routing.module'; import { AppRoutingModule } from '@/app/app-routing.module';
import { CoreMainMenuMoreRoutingModule } from '@features/mainmenu/pages/more/more-routing.module';
import { CoreSettingsHelperProvider } from './services/settings-helper';
const appRoutes: Routes = [
{
path: 'settings',
loadChildren: () => import('./settings-lazy.module').then(m => m.CoreSettingsLazyModule),
},
];
const mainMenuMoreRoutes: Routes = [
{
path: 'settings',
loadChildren: () => import('./settings-lazy.module').then(m => m.CoreSettingsLazyModule),
},
{
path: 'preferences',
loadChildren: () => import('./pages/site/site.module').then(m => m.CoreSitePreferencesPageModule),
},
];
@NgModule({ @NgModule({
imports: [ imports: [
CoreSettingsRoutingModule, AppRoutingModule.forChild(appRoutes),
CoreMainMenuMoreRoutingModule.forChild({ siblings: mainMenuMoreRoutes }),
],
providers: [
{
provide: APP_INITIALIZER,
multi: true,
deps: [CoreSettingsHelperProvider],
useFactory: (helper: CoreSettingsHelperProvider) => () => helper.initDomSettings(),
},
], ],
}) })
export class CoreSettingsModule {} export class CoreSettingsModule {}

View File

@ -201,7 +201,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy {
* Go to search courses. * Go to search courses.
*/ */
openSearch(): void { openSearch(): void {
this.navCtrl.navigateForward(['/courses/search']); this.navCtrl.navigateForward(['/main/home/courses/search']);
} }
/** /**

View File

@ -14,14 +14,16 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CoreSites } from '@services/sites'; import { CoreSites } from '@services/sites';
import { CoreHomeHandler, CoreHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate'; import { CoreMainMenuHomeHandler, CoreMainMenuHomeHandlerToDisplay } from '@features/mainmenu/services/home-delegate';
import { CoreSiteHome } from '../sitehome'; import { CoreSiteHome } from '../sitehome';
/** /**
* Handler to add site home into home page. * Handler to add site home into home page.
*/ */
Injectable(); Injectable();
export class CoreSiteHomeHomeHandler implements CoreHomeHandler { export class CoreSiteHomeHomeHandler implements CoreMainMenuHomeHandler {
static readonly PAGE_NAME = 'site';
name = 'CoreSiteHomeDashboard'; name = 'CoreSiteHomeDashboard';
priority = 1200; priority = 1200;
@ -50,13 +52,13 @@ export class CoreSiteHomeHomeHandler implements CoreHomeHandler {
* *
* @return Data needed to render the handler. * @return Data needed to render the handler.
*/ */
getDisplayData(): CoreHomeHandlerToDisplay { getDisplayData(): CoreMainMenuHomeHandlerToDisplay {
const site = CoreSites.instance.getCurrentSite(); const site = CoreSites.instance.getCurrentSite();
const displaySiteHome = site?.getInfo() && site?.getInfo()?.userhomepage === 0; const displaySiteHome = site?.getInfo() && site?.getInfo()?.userhomepage === 0;
return { return {
title: 'core.sitehome.sitehome', title: 'core.sitehome.sitehome',
page: 'sitehome', page: CoreSiteHomeHomeHandler.PAGE_NAME,
class: 'core-sitehome-dashboard-handler', class: 'core-sitehome-dashboard-handler',
icon: 'fas-home', icon: 'fas-home',
selectPriority: displaySiteHome ? 1100 : 900, selectPriority: displaySiteHome ? 1100 : 900,

View File

@ -18,36 +18,34 @@ import { Routes } from '@angular/router';
import { CoreSiteHomeIndexLinkHandler } from './services/handlers/index-link'; import { CoreSiteHomeIndexLinkHandler } from './services/handlers/index-link';
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
import { CoreSiteHomeHomeHandler } from './services/handlers/sitehome-home'; import { CoreSiteHomeHomeHandler } from './services/handlers/sitehome-home';
import { CoreHomeDelegate } from '@features/mainmenu/services/home-delegate'; import { CoreMainMenuHomeDelegate } from '@features/mainmenu/services/home-delegate';
import { CoreHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module'; import { CoreMainMenuHomeRoutingModule } from '@features/mainmenu/pages/home/home-routing.module';
const routes: Routes = [ const mainMenuHomeRoutes: Routes = [
{ {
path: 'sitehome', path: CoreSiteHomeHomeHandler.PAGE_NAME,
loadChildren: () => loadChildren: () => import('./pages/index/index.module').then(m => m.CoreSiteHomeIndexPageModule),
import('@features/sitehome/pages/index/index.module').then(m => m.CoreSiteHomeIndexPageModule),
}, },
]; ];
@NgModule({ @NgModule({
imports: [CoreHomeRoutingModule.forChild(routes)], imports: [CoreMainMenuHomeRoutingModule.forChild({ children: mainMenuHomeRoutes })],
exports: [CoreHomeRoutingModule], exports: [CoreMainMenuHomeRoutingModule],
providers: [ providers: [
CoreSiteHomeIndexLinkHandler, CoreSiteHomeIndexLinkHandler,
CoreSiteHomeHomeHandler, CoreSiteHomeHomeHandler,
], ],
}) })
export class CoreSiteHomeInitModule { export class CoreSiteHomeModule {
constructor( constructor(
contentLinksDelegate: CoreContentLinksDelegate, contentLinksDelegate: CoreContentLinksDelegate,
homeDelegate: CoreHomeDelegate, homeDelegate: CoreMainMenuHomeDelegate,
siteHomeIndexLinkHandler: CoreSiteHomeIndexLinkHandler, siteHomeIndexLinkHandler: CoreSiteHomeIndexLinkHandler,
siteHomeDashboardHandler: CoreSiteHomeHomeHandler, siteHomeDashboardHandler: CoreSiteHomeHomeHandler,
) { ) {
contentLinksDelegate.registerHandler(siteHomeIndexLinkHandler); contentLinksDelegate.registerHandler(siteHomeIndexLinkHandler);
homeDelegate.registerHandler(siteHomeDashboardHandler); homeDelegate.registerHandler(siteHomeDashboardHandler);
} }
} }