From 863dabc0940e515b659869407ce50c4ef82cfa59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Sch=C3=B6nb=C3=A4chler?= Date: Mon, 5 Feb 2024 16:25:04 +0100 Subject: [PATCH] refactor: standalone architecture transform the entire app into a standalone architecture by removing modules and add lazy loading --- src/app/app-routing.module.ts | 17 ------ src/app/app.component.ts | 5 +- src/app/app.module.ts | 30 ----------- src/app/business/business.module.ts | 35 ------------ .../business-card/business-card.component.ts | 7 ++- .../business-detail-text.component.ts | 6 ++- .../business-detail/business-detail.page.ts | 17 +++++- .../business-list/business-list.page.ts | 30 +++++++++-- src/app/business/routes.ts | 23 ++++++++ .../council-member-card.component.ts | 5 +- .../member-detail/member-detail.component.ts | 18 ++++++- .../member-list/member-list.component.ts | 30 +++++++++-- .../council-member/council-member.module.ts | 33 ------------ src/app/council-member/routes.ts | 23 ++++++++ .../containers/tab-layout/tab-layout.page.ts | 5 +- .../containers/welcome/welcome.component.ts | 6 ++- src/app/layout/layout-routing.module.ts | 54 ------------------- src/app/layout/layout.module.ts | 13 ----- src/app/layout/routes.ts | 54 +++++++++++++++++++ .../settings-overview.component.ts | 5 +- src/app/settings/settings.module.ts | 10 ---- .../error-screen/error-screen.component.ts | 5 +- .../loading-screen.component.ts | 5 +- .../no-content-screen.component.ts | 5 +- .../text-card/text-card.component.ts | 6 ++- .../hide-keyboard-on-enter.directive.ts | 3 +- src/app/shared/pipes/o-data-date-time.pipe.ts | 3 +- src/app/shared/pipes/safe-html.pipe.ts | 3 +- src/app/shared/shared.module.ts | 33 ------------ .../vote-card/vote-card.component.ts | 7 ++- .../container/vote-detail/vote-detail.page.ts | 23 ++++++-- .../container/vote-list/vote-list.page.ts | 21 +++++++- src/app/votes/routes.ts | 23 ++++++++ src/app/votes/votes.module.ts | 29 ---------- src/main.ts | 28 +++++++--- 35 files changed, 330 insertions(+), 290 deletions(-) delete mode 100644 src/app/app-routing.module.ts delete mode 100644 src/app/app.module.ts delete mode 100644 src/app/business/business.module.ts create mode 100644 src/app/business/routes.ts delete mode 100644 src/app/council-member/council-member.module.ts create mode 100644 src/app/council-member/routes.ts delete mode 100644 src/app/layout/layout-routing.module.ts delete mode 100644 src/app/layout/layout.module.ts create mode 100644 src/app/layout/routes.ts delete mode 100644 src/app/settings/settings.module.ts delete mode 100644 src/app/shared/shared.module.ts create mode 100644 src/app/votes/routes.ts delete mode 100644 src/app/votes/votes.module.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts deleted file mode 100644 index e1d5e44..0000000 --- a/src/app/app-routing.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NgModule } from '@angular/core'; -import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; - -const routes: Routes = [ - { - path: '', - loadChildren: () => - import('./layout/layout.module').then((m) => m.TabLayoutModule) - } -]; -@NgModule({ - imports: [ - RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) - ], - exports: [RouterModule] -}) -export class AppRoutingModule {} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 27d9dc1..88abb4f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,9 +1,12 @@ import { Component } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; @Component({ selector: 'app-root', templateUrl: 'app.component.html', - styleUrls: ['app.component.scss'] + styleUrls: ['app.component.scss'], + standalone: true, + imports: [IonicModule] }) export class AppComponent { constructor() {} diff --git a/src/app/app.module.ts b/src/app/app.module.ts deleted file mode 100644 index ef4abbc..0000000 --- a/src/app/app.module.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; -import { RouteReuseStrategy } from '@angular/router'; - -import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; - -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { BusinessModule } from './business/business.module'; -import { VotesModule } from './votes/votes.module'; -import { CouncileMemberModule } from './council-member/council-member.module'; -import { SettingsModule } from './settings/settings.module'; -import { IonicStorageModule } from '@ionic/storage-angular'; - -@NgModule({ - declarations: [AppComponent], - imports: [ - BrowserModule, - IonicModule.forRoot(), - IonicStorageModule.forRoot(), - AppRoutingModule, - BusinessModule, - VotesModule, - CouncileMemberModule, - SettingsModule - ], - providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }], - bootstrap: [AppComponent] -}) -export class AppModule {} diff --git a/src/app/business/business.module.ts b/src/app/business/business.module.ts deleted file mode 100644 index c18e7e0..0000000 --- a/src/app/business/business.module.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { RouterModule, Routes } from '@angular/router'; -import { IonicModule } from '@ionic/angular'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { BusinessListComponent } from './container/business-list/business-list.page'; -import { BusinessDetailPage } from './container/business-detail/business-detail.page'; -import { BusinessCardComponent } from './components/business-card/business-card.component'; -import { BusinessDetailTextComponent } from './components/business-detail-text/business-detail-text.component'; -import { SharedModule } from '../shared/shared.module'; - -const routes: Routes = [ - { - path: 'business/detail/:id', - component: BusinessDetailPage - } -]; - -@NgModule({ - declarations: [ - BusinessListComponent, - BusinessDetailPage, - BusinessCardComponent, - BusinessDetailTextComponent - ], - imports: [ - IonicModule, - CommonModule, - FormsModule, - ReactiveFormsModule, - RouterModule.forChild(routes), - SharedModule - ] -}) -export class BusinessModule {} diff --git a/src/app/business/components/business-card/business-card.component.ts b/src/app/business/components/business-card/business-card.component.ts index ee11264..44c7782 100644 --- a/src/app/business/components/business-card/business-card.component.ts +++ b/src/app/business/components/business-card/business-card.component.ts @@ -1,10 +1,15 @@ import { Component, Input } from '@angular/core'; import { Business } from 'swissparl'; +import { NgFor, NgIf } from '@angular/common'; +import { TextCardComponent } from '../../../shared/components/text-card/text-card.component'; +import { ODataDateTimePipe } from '../../../shared/pipes/o-data-date-time.pipe'; @Component({ selector: 'app-business-card', templateUrl: './business-card.component.html', - styleUrls: ['./business-card.component.scss'] + styleUrls: ['./business-card.component.scss'], + standalone: true, + imports: [NgIf, NgFor, TextCardComponent, ODataDateTimePipe] }) export class BusinessCardComponent { @Input() business: Business; 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 63514be..c90b885 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 @@ -1,11 +1,15 @@ import { Component, Input } from '@angular/core'; import { Browser } from '@capacitor/browser'; import { Business } from 'swissparl'; +import { TextCardComponent } from '../../../shared/components/text-card/text-card.component'; +import { IonicModule } from '@ionic/angular'; @Component({ selector: 'app-business-detail-text', templateUrl: './business-detail-text.component.html', - styleUrls: ['./business-detail-text.component.scss'] + styleUrls: ['./business-detail-text.component.scss'], + standalone: true, + imports: [IonicModule, TextCardComponent] }) export class BusinessDetailTextComponent { @Input() business: Business; diff --git a/src/app/business/container/business-detail/business-detail.page.ts b/src/app/business/container/business-detail/business-detail.page.ts index a1e2c4b..10c66b9 100644 --- a/src/app/business/container/business-detail/business-detail.page.ts +++ b/src/app/business/container/business-detail/business-detail.page.ts @@ -5,12 +5,27 @@ import { BusinessService } from '../../services/business.service'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { catchError, first, switchMap, tap } from 'rxjs/operators'; import { Subject, from, of } from 'rxjs'; +import { IonicModule } from '@ionic/angular'; +import { BusinessCardComponent } from '../../components/business-card/business-card.component'; +import { BusinessDetailTextComponent } from '../../components/business-detail-text/business-detail-text.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'; @UntilDestroy() @Component({ selector: 'app-business-detail', templateUrl: './business-detail.page.html', - styleUrls: ['./business-detail.page.scss'] + styleUrls: ['./business-detail.page.scss'], + standalone: true, + imports: [ + NgIf, + IonicModule, + BusinessCardComponent, + BusinessDetailTextComponent, + LoadingScreenComponent, + ErrorScreenComponent + ] }) export class BusinessDetailPage implements OnInit { business: Business = null; diff --git a/src/app/business/container/business-list/business-list.page.ts b/src/app/business/container/business-list/business-list.page.ts index f552092..7b0f4a0 100644 --- a/src/app/business/container/business-list/business-list.page.ts +++ b/src/app/business/container/business-list/business-list.page.ts @@ -4,17 +4,39 @@ import { BehaviorSubject, Subject, combineLatest, from, of } from 'rxjs'; import { map, first, tap, catchError, switchMap } from 'rxjs/operators'; import { Business, BusinessStatus, BusinessType } from 'swissparl'; import { BusinessService } from '../../services/business.service'; -import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms'; +import { + FormArray, + FormBuilder, + FormControl, + FormGroup, + ReactiveFormsModule +} from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import * as _ from 'lodash'; -import { IonSearchbar, Platform } from '@ionic/angular'; +import { IonicModule, IonSearchbar, Platform } from '@ionic/angular'; import { Keyboard } from '@capacitor/keyboard'; +import { NgFor, NgIf } from '@angular/common'; +import { BusinessCardComponent } from '../../components/business-card/business-card.component'; +import { LoadingScreenComponent } from '../../../shared/components/loading-screen/loading-screen.component'; +import { ErrorScreenComponent } from '../../../shared/components/error-screen/error-screen.component'; +import { NoContentScreenComponent } from '../../../shared/components/no-content-screen/no-content-screen.component'; @UntilDestroy() @Component({ selector: 'app-business-list', templateUrl: './business-list.page.html', - styleUrls: ['./business-list.page.scss'] + styleUrls: ['./business-list.page.scss'], + standalone: true, + imports: [ + NgIf, + NgFor, + IonicModule, + ReactiveFormsModule, + BusinessCardComponent, + LoadingScreenComponent, + ErrorScreenComponent, + NoContentScreenComponent + ] }) export class BusinessListComponent implements OnInit { top = 20; @@ -125,7 +147,7 @@ export class BusinessListComponent implements OnInit { if (businessTypes === null) { return; } - businessTypes.forEach((type) => { + businessTypes.forEach(() => { const control = new FormControl(false); (this.filterForm.controls.businessType as FormArray).push(control); }); diff --git a/src/app/business/routes.ts b/src/app/business/routes.ts new file mode 100644 index 0000000..fa9e202 --- /dev/null +++ b/src/app/business/routes.ts @@ -0,0 +1,23 @@ +import { Route } from '@angular/router'; + +export const BUSINESS_ROUTES: Route[] = [ + { + path: 'list', + loadComponent: () => + import('./container/business-list/business-list.page').then( + (m) => m.BusinessListComponent + ) + }, + { + path: 'detail/:id', + loadComponent: () => + import('./container/business-detail/business-detail.page').then( + (m) => m.BusinessDetailPage + ) + }, + { + path: '', + redirectTo: 'list', + pathMatch: 'full' + } +]; diff --git a/src/app/council-member/components/council-member-card/council-member-card.component.ts b/src/app/council-member/components/council-member-card/council-member-card.component.ts index fe36804..b105e15 100644 --- a/src/app/council-member/components/council-member-card/council-member-card.component.ts +++ b/src/app/council-member/components/council-member-card/council-member-card.component.ts @@ -1,10 +1,13 @@ import { Component, Input } from '@angular/core'; import { MemberCouncil } from 'swissparl'; +import { LowerCasePipe } from '@angular/common'; @Component({ selector: 'app-council-member-card', templateUrl: './council-member-card.component.html', - styleUrls: ['./council-member-card.component.scss'] + styleUrls: ['./council-member-card.component.scss'], + standalone: true, + imports: [LowerCasePipe] }) export class CouncilMemberCardComponent { @Input() councilMember: MemberCouncil; diff --git a/src/app/council-member/containers/member-detail/member-detail.component.ts b/src/app/council-member/containers/member-detail/member-detail.component.ts index 1e54d5d..7487e75 100644 --- a/src/app/council-member/containers/member-detail/member-detail.component.ts +++ b/src/app/council-member/containers/member-detail/member-detail.component.ts @@ -5,12 +5,28 @@ import { CouncilMemberService } from '../../services/council-member.service'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { catchError, first, switchMap, tap } from 'rxjs/operators'; import { Subject, from, of } from 'rxjs'; +import { IonicModule } from '@ionic/angular'; +import { CouncilMemberCardComponent } from '../../components/council-member-card/council-member-card.component'; +import { TextCardComponent } from '../../../shared/components/text-card/text-card.component'; +import { NgFor, NgIf } from '@angular/common'; +import { LoadingScreenComponent } from '../../../shared/components/loading-screen/loading-screen.component'; +import { ErrorScreenComponent } from '../../../shared/components/error-screen/error-screen.component'; @UntilDestroy() @Component({ selector: 'app-member-detail', templateUrl: './member-detail.component.html', - styleUrls: ['./member-detail.component.scss'] + styleUrls: ['./member-detail.component.scss'], + standalone: true, + imports: [ + NgIf, + NgFor, + IonicModule, + CouncilMemberCardComponent, + TextCardComponent, + LoadingScreenComponent, + ErrorScreenComponent + ] }) export class MemberDetailComponent implements OnInit { councilMember: MemberCouncil = null; diff --git a/src/app/council-member/containers/member-list/member-list.component.ts b/src/app/council-member/containers/member-list/member-list.component.ts index 65c7bdb..df299e5 100644 --- a/src/app/council-member/containers/member-list/member-list.component.ts +++ b/src/app/council-member/containers/member-list/member-list.component.ts @@ -4,15 +4,39 @@ import { BehaviorSubject, Subject, combineLatest, of } from 'rxjs'; import { catchError, first, switchMap, tap } from 'rxjs/operators'; import { MemberCouncil } from 'swissparl'; import { CouncilMemberService } from '../../services/council-member.service'; -import { FormArray, FormBuilder, FormControl, FormGroup } from '@angular/forms'; +import { + FormArray, + FormBuilder, + FormControl, + FormGroup, + ReactiveFormsModule +} from '@angular/forms'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { IonSearchbar } from '@ionic/angular'; +import { IonicModule, IonSearchbar } from '@ionic/angular'; +import { NgFor, NgIf } from '@angular/common'; +import { HideKeyboardOnEnterDirective } from '../../../shared/directives/hide-keyboard-on-enter.directive'; +import { CouncilMemberCardComponent } from '../../components/council-member-card/council-member-card.component'; +import { LoadingScreenComponent } from '../../../shared/components/loading-screen/loading-screen.component'; +import { NoContentScreenComponent } from '../../../shared/components/no-content-screen/no-content-screen.component'; +import { ErrorScreenComponent } from '../../../shared/components/error-screen/error-screen.component'; @UntilDestroy() @Component({ selector: 'app-member-list', templateUrl: './member-list.component.html', - styleUrls: ['./member-list.component.scss'] + styleUrls: ['./member-list.component.scss'], + standalone: true, + imports: [ + NgIf, + NgFor, + IonicModule, + ReactiveFormsModule, + CouncilMemberCardComponent, + HideKeyboardOnEnterDirective, + LoadingScreenComponent, + NoContentScreenComponent, + ErrorScreenComponent + ] }) export class MemberListComponent implements OnInit { top = 50; diff --git a/src/app/council-member/council-member.module.ts b/src/app/council-member/council-member.module.ts deleted file mode 100644 index 4f241e1..0000000 --- a/src/app/council-member/council-member.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { RouterModule, Routes } from '@angular/router'; -import { IonicModule } from '@ionic/angular'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { MemberListComponent } from './containers/member-list/member-list.component'; -import { MemberDetailComponent } from './containers/member-detail/member-detail.component'; -import { CouncilMemberCardComponent } from './components/council-member-card/council-member-card.component'; -import { SharedModule } from '../shared/shared.module'; - -const routes: Routes = [ - { - path: 'council-member/detail/:id', - component: MemberDetailComponent - } -]; - -@NgModule({ - declarations: [ - MemberDetailComponent, - MemberListComponent, - CouncilMemberCardComponent - ], - imports: [ - IonicModule, - CommonModule, - FormsModule, - ReactiveFormsModule, - RouterModule.forChild(routes), - SharedModule - ] -}) -export class CouncileMemberModule {} diff --git a/src/app/council-member/routes.ts b/src/app/council-member/routes.ts new file mode 100644 index 0000000..d55aeaa --- /dev/null +++ b/src/app/council-member/routes.ts @@ -0,0 +1,23 @@ +import { Route } from '@angular/router'; + +export const COUNCIL_MEMBER_ROUTES: Route[] = [ + { + path: 'list', + loadComponent: () => + import('./containers/member-list/member-list.component').then( + (m) => m.MemberListComponent + ) + }, + { + path: 'detail/:id', + loadComponent: () => + import('./containers/member-detail/member-detail.component').then( + (m) => m.MemberDetailComponent + ) + }, + { + path: '', + redirectTo: 'list', + pathMatch: 'full' + } +]; diff --git a/src/app/layout/containers/tab-layout/tab-layout.page.ts b/src/app/layout/containers/tab-layout/tab-layout.page.ts index 185895a..c01259c 100644 --- a/src/app/layout/containers/tab-layout/tab-layout.page.ts +++ b/src/app/layout/containers/tab-layout/tab-layout.page.ts @@ -1,9 +1,12 @@ import { Component } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; @Component({ selector: 'app-tab-layout', templateUrl: 'tab-layout.page.html', - styleUrls: ['tab-layout.page.scss'] + styleUrls: ['tab-layout.page.scss'], + standalone: true, + imports: [IonicModule] }) export class TabLayoutPage { constructor() {} diff --git a/src/app/layout/containers/welcome/welcome.component.ts b/src/app/layout/containers/welcome/welcome.component.ts index 4080e9c..61522bf 100644 --- a/src/app/layout/containers/welcome/welcome.component.ts +++ b/src/app/layout/containers/welcome/welcome.component.ts @@ -1,12 +1,14 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { StatusBar, Style } from '@capacitor/status-bar'; -import { Platform } from '@ionic/angular'; +import { IonicModule, Platform } from '@ionic/angular'; @Component({ selector: 'app-welcome', templateUrl: './welcome.component.html', - styleUrls: ['./welcome.component.scss'] + styleUrls: ['./welcome.component.scss'], + standalone: true, + imports: [IonicModule] }) export class WelcomeComponent implements OnInit { constructor( diff --git a/src/app/layout/layout-routing.module.ts b/src/app/layout/layout-routing.module.ts deleted file mode 100644 index 3834cc9..0000000 --- a/src/app/layout/layout-routing.module.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { VoteListComponent } from '../votes/container/vote-list/vote-list.page'; -import { MemberListComponent } from '../council-member/containers/member-list/member-list.component'; -import { BusinessListComponent } from '../business/container/business-list/business-list.page'; -import { SettingsOverviewComponent } from '../settings/containers/settings-overview/settings-overview.component'; -import { TabLayoutPage } from './containers/tab-layout/tab-layout.page'; -import { WelcomeComponent } from './containers/welcome/welcome.component'; -import { firstTimeOpenGuard } from './guard/first-time-open.guard'; - -const routes: Routes = [ - { - path: 'layout', - component: TabLayoutPage, - canActivate: [firstTimeOpenGuard], - children: [ - { - path: 'votes', - component: VoteListComponent - }, - { - path: 'council-member', - component: MemberListComponent - }, - { - path: 'business', - component: BusinessListComponent - }, - { - path: 'settings', - component: SettingsOverviewComponent - }, - { - path: '', - redirectTo: '/layout/votes', - pathMatch: 'full' - } - ] - }, - { - path: 'welcome', - component: WelcomeComponent - }, - { - path: '', - redirectTo: '/layout/votes', - pathMatch: 'full' - } -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)] -}) -export class TabLayoutRoutingModule {} diff --git a/src/app/layout/layout.module.ts b/src/app/layout/layout.module.ts deleted file mode 100644 index 7a97488..0000000 --- a/src/app/layout/layout.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { IonicModule } from '@ionic/angular'; -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { TabLayoutPage } from './containers/tab-layout/tab-layout.page'; -import { TabLayoutRoutingModule } from './layout-routing.module'; -import { WelcomeComponent } from './containers/welcome/welcome.component'; - -@NgModule({ - imports: [IonicModule, CommonModule, FormsModule, TabLayoutRoutingModule], - declarations: [TabLayoutPage, WelcomeComponent] -}) -export class TabLayoutModule {} diff --git a/src/app/layout/routes.ts b/src/app/layout/routes.ts new file mode 100644 index 0000000..851c66c --- /dev/null +++ b/src/app/layout/routes.ts @@ -0,0 +1,54 @@ +import { Routes } from '@angular/router'; +import { TabLayoutPage } from './containers/tab-layout/tab-layout.page'; +import { firstTimeOpenGuard } from './guard/first-time-open.guard'; + +export const TAB_ROUTES: Routes = [ + { + path: 'layout', + component: TabLayoutPage, + canActivate: [firstTimeOpenGuard], + children: [ + { + path: 'votes', + loadChildren: () => + import('../votes/routes').then((mod) => mod.VOTE_ROUTES) + }, + { + path: 'council-member', + loadChildren: () => + import('../council-member/routes').then( + (mod) => mod.COUNCIL_MEMBER_ROUTES + ) + }, + { + path: 'business', + loadChildren: () => + import('../business/routes').then((mod) => mod.BUSINESS_ROUTES) + }, + { + path: 'settings', + loadComponent: () => + import( + '../settings/containers/settings-overview/settings-overview.component' + ).then((mod) => mod.SettingsOverviewComponent) + }, + { + path: '', + redirectTo: '/layout/votes/list', + pathMatch: 'full' + } + ] + }, + { + path: 'welcome', + loadComponent: () => + import('./containers/welcome/welcome.component').then( + (mod) => mod.WelcomeComponent + ) + }, + { + path: '', + redirectTo: '/layout/votes', + pathMatch: 'full' + } +]; diff --git a/src/app/settings/containers/settings-overview/settings-overview.component.ts b/src/app/settings/containers/settings-overview/settings-overview.component.ts index 5c78d7e..1e02ea5 100644 --- a/src/app/settings/containers/settings-overview/settings-overview.component.ts +++ b/src/app/settings/containers/settings-overview/settings-overview.component.ts @@ -1,10 +1,13 @@ import { Component } from '@angular/core'; import { Browser } from '@capacitor/browser'; +import { IonicModule } from '@ionic/angular'; @Component({ selector: 'app-settings-overview', templateUrl: './settings-overview.component.html', - styleUrls: ['./settings-overview.component.scss'] + styleUrls: ['./settings-overview.component.scss'], + standalone: true, + imports: [IonicModule] }) export class SettingsOverviewComponent { constructor() {} diff --git a/src/app/settings/settings.module.ts b/src/app/settings/settings.module.ts deleted file mode 100644 index f9ac587..0000000 --- a/src/app/settings/settings.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { SettingsOverviewComponent } from './containers/settings-overview/settings-overview.component'; -import { IonicModule } from '@ionic/angular'; - -@NgModule({ - declarations: [SettingsOverviewComponent], - imports: [IonicModule, CommonModule] -}) -export class SettingsModule {} diff --git a/src/app/shared/components/error-screen/error-screen.component.ts b/src/app/shared/components/error-screen/error-screen.component.ts index 14d590f..f63892b 100644 --- a/src/app/shared/components/error-screen/error-screen.component.ts +++ b/src/app/shared/components/error-screen/error-screen.component.ts @@ -1,9 +1,12 @@ import { Component, EventEmitter, Output } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; @Component({ selector: 'app-error-screen', templateUrl: './error-screen.component.html', - styleUrls: ['./error-screen.component.scss'] + styleUrls: ['./error-screen.component.scss'], + standalone: true, + imports: [IonicModule] }) export class ErrorScreenComponent { @Output() retry: EventEmitter = new EventEmitter(); diff --git a/src/app/shared/components/loading-screen/loading-screen.component.ts b/src/app/shared/components/loading-screen/loading-screen.component.ts index c084235..7d6ecd7 100644 --- a/src/app/shared/components/loading-screen/loading-screen.component.ts +++ b/src/app/shared/components/loading-screen/loading-screen.component.ts @@ -1,12 +1,15 @@ import { Component, OnInit } from '@angular/core'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { concat, interval, tap, timer } from 'rxjs'; +import { IonicModule } from '@ionic/angular'; @UntilDestroy() @Component({ selector: 'app-loading-screen', templateUrl: './loading-screen.component.html', - styleUrls: ['./loading-screen.component.scss'] + styleUrls: ['./loading-screen.component.scss'], + standalone: true, + imports: [IonicModule] }) export class LoadingScreenComponent implements OnInit { currentFact: string; diff --git a/src/app/shared/components/no-content-screen/no-content-screen.component.ts b/src/app/shared/components/no-content-screen/no-content-screen.component.ts index e33c485..071133d 100644 --- a/src/app/shared/components/no-content-screen/no-content-screen.component.ts +++ b/src/app/shared/components/no-content-screen/no-content-screen.component.ts @@ -1,9 +1,12 @@ import { Component, EventEmitter, Output } from '@angular/core'; +import { IonicModule } from '@ionic/angular'; @Component({ selector: 'app-no-content-screen', templateUrl: './no-content-screen.component.html', - styleUrls: ['./no-content-screen.component.scss'] + styleUrls: ['./no-content-screen.component.scss'], + standalone: true, + imports: [IonicModule] }) export class NoContentScreenComponent { @Output() resetFilter: EventEmitter = new EventEmitter(); diff --git a/src/app/shared/components/text-card/text-card.component.ts b/src/app/shared/components/text-card/text-card.component.ts index f5fa6e4..4252ba6 100644 --- a/src/app/shared/components/text-card/text-card.component.ts +++ b/src/app/shared/components/text-card/text-card.component.ts @@ -1,9 +1,13 @@ import { Component, Input } from '@angular/core'; +import { SafeHtmlPipe } from '../../pipes/safe-html.pipe'; +import { NgIf } from '@angular/common'; @Component({ selector: 'app-text-card', templateUrl: './text-card.component.html', - styleUrls: ['./text-card.component.scss'] + styleUrls: ['./text-card.component.scss'], + standalone: true, + imports: [NgIf, SafeHtmlPipe] }) export class TextCardComponent { @Input() title: string; diff --git a/src/app/shared/directives/hide-keyboard-on-enter.directive.ts b/src/app/shared/directives/hide-keyboard-on-enter.directive.ts index a5124cf..31531df 100644 --- a/src/app/shared/directives/hide-keyboard-on-enter.directive.ts +++ b/src/app/shared/directives/hide-keyboard-on-enter.directive.ts @@ -3,7 +3,8 @@ import { Keyboard } from '@capacitor/keyboard'; import { Platform } from '@ionic/angular'; @Directive({ - selector: '[appHideKeyboardOnEnter]' + selector: '[appHideKeyboardOnEnter]', + standalone: true }) export class HideKeyboardOnEnterDirective { constructor(private platform: Platform) {} diff --git a/src/app/shared/pipes/o-data-date-time.pipe.ts b/src/app/shared/pipes/o-data-date-time.pipe.ts index cf8541b..06a93e4 100644 --- a/src/app/shared/pipes/o-data-date-time.pipe.ts +++ b/src/app/shared/pipes/o-data-date-time.pipe.ts @@ -1,7 +1,8 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ - name: 'oDataDateTime' + name: 'oDataDateTime', + standalone: true }) export class ODataDateTimePipe implements PipeTransform { constructor() {} diff --git a/src/app/shared/pipes/safe-html.pipe.ts b/src/app/shared/pipes/safe-html.pipe.ts index 0d42569..bf37b36 100644 --- a/src/app/shared/pipes/safe-html.pipe.ts +++ b/src/app/shared/pipes/safe-html.pipe.ts @@ -2,7 +2,8 @@ import { Pipe, PipeTransform } from '@angular/core'; import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; @Pipe({ - name: 'safeHtml' + name: 'safeHtml', + standalone: true }) export class SafeHtmlPipe implements PipeTransform { constructor(private sanitized: DomSanitizer) {} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts deleted file mode 100644 index 7d965ef..0000000 --- a/src/app/shared/shared.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { SafeHtmlPipe } from './pipes/safe-html.pipe'; -import { HideKeyboardOnEnterDirective } from './directives/hide-keyboard-on-enter.directive'; -import { LoadingScreenComponent } from './components/loading-screen/loading-screen.component'; -import { IonicModule } from '@ionic/angular'; -import { ErrorScreenComponent } from './components/error-screen/error-screen.component'; -import { TextCardComponent } from './components/text-card/text-card.component'; -import { NoContentScreenComponent } from './components/no-content-screen/no-content-screen.component'; -import { ODataDateTimePipe } from './pipes/o-data-date-time.pipe'; - -@NgModule({ - declarations: [ - SafeHtmlPipe, - ODataDateTimePipe, - HideKeyboardOnEnterDirective, - LoadingScreenComponent, - ErrorScreenComponent, - NoContentScreenComponent, - TextCardComponent - ], - imports: [CommonModule, IonicModule], - exports: [ - SafeHtmlPipe, - ODataDateTimePipe, - HideKeyboardOnEnterDirective, - LoadingScreenComponent, - ErrorScreenComponent, - NoContentScreenComponent, - TextCardComponent - ] -}) -export class SharedModule {} diff --git a/src/app/votes/components/vote-card/vote-card.component.ts b/src/app/votes/components/vote-card/vote-card.component.ts index acb1e75..6d38852 100644 --- a/src/app/votes/components/vote-card/vote-card.component.ts +++ b/src/app/votes/components/vote-card/vote-card.component.ts @@ -3,12 +3,17 @@ import { Vote, Voting } from 'swissparl'; import { VoteService } from '../../services/votes.service'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { map } from 'rxjs/operators'; +import { TextCardComponent } from '../../../shared/components/text-card/text-card.component'; +import { ODataDateTimePipe } from '../../../shared/pipes/o-data-date-time.pipe'; +import { NgFor } from '@angular/common'; @UntilDestroy() @Component({ selector: 'app-vote-card', templateUrl: './vote-card.component.html', - styleUrls: ['./vote-card.component.scss'] + styleUrls: ['./vote-card.component.scss'], + standalone: true, + imports: [NgFor, TextCardComponent, ODataDateTimePipe] }) export class VoteCardComponent implements OnInit { @Input() vote: Vote; diff --git a/src/app/votes/container/vote-detail/vote-detail.page.ts b/src/app/votes/container/vote-detail/vote-detail.page.ts index 6111ad3..2080c19 100644 --- a/src/app/votes/container/vote-detail/vote-detail.page.ts +++ b/src/app/votes/container/vote-detail/vote-detail.page.ts @@ -1,17 +1,34 @@ import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute, Router, RouterLink } from '@angular/router'; import { Vote } from 'swissparl'; import { VoteService } from '../../services/votes.service'; import { catchError, first, switchMap, tap } from 'rxjs/operators'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { FormControl } from '@angular/forms'; +import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { Subject, from, of } from 'rxjs'; +import { IonicModule } from '@ionic/angular'; +import { VoteCardComponent } from '../../components/vote-card/vote-card.component'; +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'; @UntilDestroy() @Component({ selector: 'app-vote-detail', templateUrl: './vote-detail.page.html', - styleUrls: ['./vote-detail.page.scss'] + styleUrls: ['./vote-detail.page.scss'], + standalone: true, + imports: [ + NgIf, + RouterLink, + ReactiveFormsModule, + IonicModule, + VoteCardComponent, + TextCardComponent, + LoadingScreenComponent, + ErrorScreenComponent + ] }) export class VoteDetailPage implements OnInit { vote: Vote = null; diff --git a/src/app/votes/container/vote-list/vote-list.page.ts b/src/app/votes/container/vote-list/vote-list.page.ts index 3ca73dc..0211c7a 100644 --- a/src/app/votes/container/vote-list/vote-list.page.ts +++ b/src/app/votes/container/vote-list/vote-list.page.ts @@ -4,12 +4,29 @@ import { catchError, first, tap, switchMap } from 'rxjs/operators'; import { Vote } from 'swissparl'; import { VoteService } from '../../services/votes.service'; import { BehaviorSubject, Subject, combineLatest, of } from 'rxjs'; -import { IonSearchbar } from '@ionic/angular'; +import { IonicModule, IonSearchbar } from '@ionic/angular'; +import { HideKeyboardOnEnterDirective } from '../../../shared/directives/hide-keyboard-on-enter.directive'; +import { VoteCardComponent } from '../../components/vote-card/vote-card.component'; +import { LoadingScreenComponent } from '../../../shared/components/loading-screen/loading-screen.component'; +import { ErrorScreenComponent } from '../../../shared/components/error-screen/error-screen.component'; +import { NoContentScreenComponent } from '../../../shared/components/no-content-screen/no-content-screen.component'; +import { NgFor, NgIf } from '@angular/common'; @Component({ selector: 'app-vote-list', templateUrl: './vote-list.page.html', - styleUrls: ['./vote-list.page.scss'] + styleUrls: ['./vote-list.page.scss'], + standalone: true, + imports: [ + NgIf, + NgFor, + IonicModule, + VoteCardComponent, + HideKeyboardOnEnterDirective, + LoadingScreenComponent, + ErrorScreenComponent, + NoContentScreenComponent + ] }) export class VoteListComponent implements OnInit { top = 10; diff --git a/src/app/votes/routes.ts b/src/app/votes/routes.ts new file mode 100644 index 0000000..009b2b3 --- /dev/null +++ b/src/app/votes/routes.ts @@ -0,0 +1,23 @@ +import { Route } from '@angular/router'; + +export const VOTE_ROUTES: Route[] = [ + { + path: 'list', + loadComponent: () => + import('./container/vote-list/vote-list.page').then( + (m) => m.VoteListComponent + ) + }, + { + path: 'detail/:id', + loadComponent: () => + import('./container/vote-detail/vote-detail.page').then( + (m) => m.VoteDetailPage + ) + }, + { + path: '', + redirectTo: 'list', + pathMatch: 'full' + } +]; diff --git a/src/app/votes/votes.module.ts b/src/app/votes/votes.module.ts deleted file mode 100644 index b1d938a..0000000 --- a/src/app/votes/votes.module.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { RouterModule, Routes } from '@angular/router'; -import { IonicModule } from '@ionic/angular'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { VoteListComponent } from './container/vote-list/vote-list.page'; -import { VoteDetailPage } from './container/vote-detail/vote-detail.page'; -import { VoteCardComponent } from './components/vote-card/vote-card.component'; -import { SharedModule } from '../shared/shared.module'; - -const routes: Routes = [ - { - path: 'votes/detail/:id', - component: VoteDetailPage - } -]; - -@NgModule({ - declarations: [VoteListComponent, VoteDetailPage, VoteCardComponent], - imports: [ - IonicModule, - CommonModule, - FormsModule, - ReactiveFormsModule, - RouterModule.forChild(routes), - SharedModule - ] -}) -export class VotesModule {} diff --git a/src/main.ts b/src/main.ts index 741c9eb..50d3c40 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,13 +1,29 @@ -import { enableProdMode } from '@angular/core'; -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { enableProdMode, importProvidersFrom } from '@angular/core'; -import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; +import { RouterModule } from '@angular/router'; +import { bootstrapApplication, BrowserModule } from '@angular/platform-browser'; +import { AppComponent } from './app/app.component'; +import { IonicModule } from '@ionic/angular'; +import { IonicStorageModule } from '@ionic/storage-angular'; if (environment.production) { enableProdMode(); } -platformBrowserDynamic() - .bootstrapModule(AppModule) - .catch((err) => console.log(err)); +bootstrapApplication(AppComponent, { + providers: [ + importProvidersFrom( + BrowserModule, + IonicModule.forRoot(), + RouterModule.forRoot([ + { + path: '', + loadChildren: () => + import('./app/layout/routes').then((m) => m.TAB_ROUTES) + } + ]), + IonicStorageModule.forRoot() + ) + ] +}).then((r) => console.log('Application started'));