From ed35b5fe56fa32ccd98f8a0811c233afd28cd8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Sch=C3=B6nb=C3=A4chler?= Date: Fri, 9 Feb 2024 19:04:40 +0100 Subject: [PATCH] fix: routing and remaining imports only layout pages should have the prefix "layout". "Module" routes are now loaded from main.ts --- .../business-detail-text.component.ts | 3 ++- src/app/business/routes.ts | 12 --------- src/app/council-member/routes.ts | 12 --------- src/app/layout/routes.ts | 26 +++++++++---------- .../vote-detail/vote-detail.page.ts | 3 ++- src/app/votes/routes.ts | 12 --------- src/main.ts | 9 ++----- src/routes.ts | 25 ++++++++++++++++++ 8 files changed, 44 insertions(+), 58 deletions(-) create mode 100644 src/routes.ts diff --git a/src/app/business/components/business-detail-text/business-detail-text.component.ts b/src/app/business/components/business-detail-text/business-detail-text.component.ts index c90b885..a9dc780 100644 --- a/src/app/business/components/business-detail-text/business-detail-text.component.ts +++ b/src/app/business/components/business-detail-text/business-detail-text.component.ts @@ -3,13 +3,14 @@ import { Browser } from '@capacitor/browser'; import { Business } from 'swissparl'; import { TextCardComponent } from '../../../shared/components/text-card/text-card.component'; import { IonicModule } from '@ionic/angular'; +import { NgIf } from '@angular/common'; @Component({ selector: 'app-business-detail-text', templateUrl: './business-detail-text.component.html', styleUrls: ['./business-detail-text.component.scss'], standalone: true, - imports: [IonicModule, TextCardComponent] + imports: [NgIf, IonicModule, TextCardComponent] }) export class BusinessDetailTextComponent { @Input() business: Business; diff --git a/src/app/business/routes.ts b/src/app/business/routes.ts index 085186b..c275e7a 100644 --- a/src/app/business/routes.ts +++ b/src/app/business/routes.ts @@ -1,23 +1,11 @@ import { Route } from '@angular/router'; export const BUSINESS_ROUTES: Route[] = [ - { - path: 'list', - loadComponent: () => - import('./containers/business-list/business-list.page').then( - (m) => m.BusinessListPage - ) - }, { path: 'detail/:id', loadComponent: () => import('./containers/business-detail/business-detail.page').then( (m) => m.BusinessDetailPage ) - }, - { - path: '', - redirectTo: 'list', - pathMatch: 'full' } ]; diff --git a/src/app/council-member/routes.ts b/src/app/council-member/routes.ts index 8e033fa..316fdfe 100644 --- a/src/app/council-member/routes.ts +++ b/src/app/council-member/routes.ts @@ -1,23 +1,11 @@ import { Route } from '@angular/router'; export const COUNCIL_MEMBER_ROUTES: Route[] = [ - { - path: 'list', - loadComponent: () => - import('./containers/member-list/member-list.page').then( - (m) => m.MemberListPage - ) - }, { path: 'detail/:id', loadComponent: () => import('./containers/member-detail/member-detail.page').then( (m) => m.MemberDetailPage ) - }, - { - path: '', - redirectTo: 'list', - pathMatch: 'full' } ]; diff --git a/src/app/layout/routes.ts b/src/app/layout/routes.ts index dff53bd..546db31 100644 --- a/src/app/layout/routes.ts +++ b/src/app/layout/routes.ts @@ -10,32 +10,32 @@ export const TAB_ROUTES: Routes = [ children: [ { path: 'votes', - loadChildren: () => - import('../votes/routes').then((mod) => mod.VOTE_ROUTES) + loadComponent: () => + import('../votes/containers/vote-list/vote-list.page').then( + (m) => m.VoteListPage + ) }, { path: 'council-member', - loadChildren: () => - import('../council-member/routes').then( - (mod) => mod.COUNCIL_MEMBER_ROUTES - ) + loadComponent: () => + import( + '../council-member/containers/member-list/member-list.page' + ).then((m) => m.MemberListPage) }, { path: 'business', - loadChildren: () => - import('../business/routes').then((mod) => mod.BUSINESS_ROUTES) + loadComponent: () => + import( + '../business/containers/business-list/business-list.page' + ).then((m) => m.BusinessListPage) }, + { path: 'settings', loadComponent: () => import( '../settings/containers/settings-overview/settings-overview.page' ).then((mod) => mod.SettingsOverviewPage) - }, - { - path: '', - redirectTo: '/layout/votes/list', - pathMatch: 'full' } ] }, diff --git a/src/app/votes/containers/vote-detail/vote-detail.page.ts b/src/app/votes/containers/vote-detail/vote-detail.page.ts index 2080c19..fe3c56e 100644 --- a/src/app/votes/containers/vote-detail/vote-detail.page.ts +++ b/src/app/votes/containers/vote-detail/vote-detail.page.ts @@ -11,7 +11,7 @@ import { VoteCardComponent } from '../../components/vote-card/vote-card.componen import { TextCardComponent } from '../../../shared/components/text-card/text-card.component'; import { LoadingScreenComponent } from '../../../shared/components/loading-screen/loading-screen.component'; import { ErrorScreenComponent } from '../../../shared/components/error-screen/error-screen.component'; -import { NgIf } from '@angular/common'; +import { NgFor, NgIf } from '@angular/common'; @UntilDestroy() @Component({ @@ -21,6 +21,7 @@ import { NgIf } from '@angular/common'; standalone: true, imports: [ NgIf, + NgFor, RouterLink, ReactiveFormsModule, IonicModule, diff --git a/src/app/votes/routes.ts b/src/app/votes/routes.ts index 0c7f35e..dec4a65 100644 --- a/src/app/votes/routes.ts +++ b/src/app/votes/routes.ts @@ -1,23 +1,11 @@ import { Route } from '@angular/router'; export const VOTE_ROUTES: Route[] = [ - { - path: 'list', - loadComponent: () => - import('./containers/vote-list/vote-list.page').then( - (m) => m.VoteListPage - ) - }, { path: 'detail/:id', loadComponent: () => import('./containers/vote-detail/vote-detail.page').then( (m) => m.VoteDetailPage ) - }, - { - path: '', - redirectTo: 'list', - pathMatch: 'full' } ]; diff --git a/src/main.ts b/src/main.ts index f6ffff2..2c61fec 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import { bootstrapApplication } from '@angular/platform-browser'; import { AppComponent } from './app/app.component'; import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; import { IonicStorageModule } from '@ionic/storage-angular'; +import { APP_ROUTES } from './routes'; if (environment.production) { enableProdMode(); @@ -15,12 +16,6 @@ bootstrapApplication(AppComponent, { providers: [ { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, importProvidersFrom(IonicModule.forRoot(), IonicStorageModule.forRoot()), - provideRouter([ - { - path: '', - loadChildren: () => - import('./app/layout/routes').then((m) => m.TAB_ROUTES) - } - ]) + provideRouter(APP_ROUTES) ] }).then(() => console.log('Application started')); diff --git a/src/routes.ts b/src/routes.ts new file mode 100644 index 0000000..a3d5bb9 --- /dev/null +++ b/src/routes.ts @@ -0,0 +1,25 @@ +import { Route } from '@angular/router'; + +export const APP_ROUTES: Route[] = [ + { + path: 'business', + loadChildren: () => + import('./app/business/routes').then((mod) => mod.BUSINESS_ROUTES) + }, + { + path: 'council-member', + loadChildren: () => + import('./app/council-member/routes').then( + (mod) => mod.COUNCIL_MEMBER_ROUTES + ) + }, + { + path: 'votes', + loadChildren: () => + import('./app/votes/routes').then((mod) => mod.VOTE_ROUTES) + }, + { + path: '', + loadChildren: () => import('./app/layout/routes').then((m) => m.TAB_ROUTES) + } +];