diff --git a/src/app/core/courses/courses.module.ts b/src/app/core/courses/courses.module.ts index 1c58e67ca..bbc05d612 100644 --- a/src/app/core/courses/courses.module.ts +++ b/src/app/core/courses/courses.module.ts @@ -13,7 +13,8 @@ // limitations under the License. import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; +import { Routes } from '@angular/router'; +import { CoreHomeRoutingModule } from '../mainmenu/pages/home/home-routing.module'; import { CoreHomeDelegate } from '../mainmenu/services/home.delegate'; import { CoreCoursesDashboardHandler } from './services/handlers/dashboard'; import { CoreCoursesDashboardPage } from './pages/dashboard/dashboard.page'; @@ -22,12 +23,14 @@ import { CoreCoursesDashboardPage } from './pages/dashboard/dashboard.page'; const routes: Routes = [ { path: 'dashboard', - component: CoreCoursesDashboardPage, + loadChildren: () => + import('@core/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule), }, ]; @NgModule({ - imports: [RouterModule.forChild(routes)], + imports: [CoreHomeRoutingModule.forChild(routes)], + exports: [CoreHomeRoutingModule], providers: [ CoreCoursesDashboardHandler, ], diff --git a/src/app/core/mainmenu/pages/home/home.html b/src/app/core/mainmenu/pages/home/home.html index d73d9ecaf..71b4ffdad 100644 --- a/src/app/core/mainmenu/pages/home/home.html +++ b/src/app/core/mainmenu/pages/home/home.html @@ -16,12 +16,10 @@ - - + + - -
Home page
-
+
diff --git a/src/app/core/mainmenu/pages/home/home.page.module.ts b/src/app/core/mainmenu/pages/home/home.page.module.ts index 205739270..c0c90ab3f 100644 --- a/src/app/core/mainmenu/pages/home/home.page.module.ts +++ b/src/app/core/mainmenu/pages/home/home.page.module.ts @@ -14,7 +14,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { RouterModule, Routes } from '@angular/router'; import { IonicModule } from '@ionic/angular'; import { TranslateModule } from '@ngx-translate/core'; @@ -22,33 +21,19 @@ import { CoreComponentsModule } from '@components/components.module'; import { CoreDirectivesModule } from '@directives/directives.module'; import { CoreHomePage } from './home.page'; - -const routes: Routes = [ - { - path: '', - component: CoreHomePage, - children: [ - { - path: 'dashboard', // @todo: Add this route dynamically. - loadChildren: () => - import('@core/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule), - }, - ], - }, -]; +import { CoreHomeRoutingModule } from './home-routing.module'; @NgModule({ imports: [ - RouterModule.forChild(routes), CommonModule, IonicModule, TranslateModule.forChild(), CoreComponentsModule, CoreDirectivesModule, + CoreHomeRoutingModule, ], declarations: [ CoreHomePage, ], - exports: [RouterModule], }) export class CoreHomePageModule {} diff --git a/src/app/core/mainmenu/pages/home/home.page.ts b/src/app/core/mainmenu/pages/home/home.page.ts index d0d23aa5f..4a9d1c418 100644 --- a/src/app/core/mainmenu/pages/home/home.page.ts +++ b/src/app/core/mainmenu/pages/home/home.page.ts @@ -55,6 +55,8 @@ export class CoreHomePage implements OnInit { initHandlers(handlers: CoreHomeHandlerToDisplay[]): void { // 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) => { + handler.page = '/home/' + handler.page; + // Check if the handler is already in the tabs list. If so, use it. const tab = this.tabs.find((tab) => tab.title == handler.title); @@ -63,9 +65,10 @@ export class CoreHomePage implements OnInit { // Sort them by priority so new handlers are in the right position. .sort((a, b) => (b.priority || 0) - (a.priority || 0)); - if (typeof this.selectedTab == 'undefined') { + if (typeof this.selectedTab == 'undefined' && newTabs.length > 0) { let maxPriority = 0; let maxIndex = 0; + newTabs.forEach((tab, index) => { if ((tab.selectPriority || 0) > maxPriority) { maxPriority = tab.selectPriority || 0;