Skip to content

Commit d347c2e

Browse files
committed
solution
1 parent a592851 commit d347c2e

28 files changed

+857
-337
lines changed

src/app/app.component.html

Lines changed: 40 additions & 330 deletions
Large diffs are not rendered by default.

src/app/app.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import { Component } from '@angular/core';
2-
import { RouterOutlet } from '@angular/router';
2+
import { FlightSearchComponent } from './flight-search/flight-search.component';
3+
import { RouterLink, RouterOutlet } from '@angular/router';
34

45
@Component({
56
selector: 'app-root',
6-
imports: [RouterOutlet],
7+
imports: [
8+
RouterOutlet,
9+
RouterLink,
10+
],
711
templateUrl: './app.component.html',
812
styleUrl: './app.component.css'
913
})
1014
export class AppComponent {
11-
title = 'flight-app';
15+
title = 'Hallo Welt!';
1216
}

src/app/app.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2-
import { provideRouter } from '@angular/router';
2+
import { provideRouter, withComponentInputBinding } from '@angular/router';
33

44
import { routes } from './app.routes';
5+
import { provideHttpClient } from '@angular/common/http';
56

67
export const appConfig: ApplicationConfig = {
7-
providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes)]
8+
providers: [
9+
provideZoneChangeDetection({ eventCoalescing: true }),
10+
provideRouter(
11+
routes,
12+
withComponentInputBinding()
13+
),
14+
provideHttpClient(),
15+
]
816
};

src/app/app.routes.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
11
import { Routes } from '@angular/router';
2+
import { HomeComponent } from './home/home.component';
3+
import { FlightSearchComponent } from './flight-search/flight-search.component';
4+
import { PassengerSearchComponent } from './passenger-search/passenger-search.component';
5+
import { FlightEditComponent } from './flight-edit/flight-edit.component';
26

3-
export const routes: Routes = [];
7+
export const routes: Routes = [
8+
{
9+
path: '',
10+
pathMatch: 'full',
11+
redirectTo: 'home'
12+
},
13+
{
14+
path: 'home',
15+
component: HomeComponent
16+
},
17+
{
18+
path: 'flight-search',
19+
component: FlightSearchComponent,
20+
},
21+
{
22+
path: 'flight-edit/:id',
23+
component: FlightEditComponent
24+
},
25+
{
26+
path: 'passenger-search',
27+
component: PassengerSearchComponent
28+
},
29+
{
30+
path: '**',
31+
redirectTo: 'home'
32+
}
33+
];

src/app/data/flight.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
export interface Flight {
3+
id: number;
4+
from: string;
5+
to: string;
6+
date: string;
7+
}
8+
9+
export const initFlight: Flight = {
10+
id: 0,
11+
from: '',
12+
to: '',
13+
date: ''
14+
};

src/app/flight-card/flight-card.component.css

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@let flight = item();
2+
3+
<div class="card" [class.selected]="selected()">
4+
<div class="card-header">
5+
<h2 class="title"> {{flight.from}} - {{flight.to}} </h2>
6+
</div>
7+
8+
<div class="card-body">
9+
<p>Flight-No.: {{flight.id}}</p>
10+
<p>Date: {{flight.date | date: 'dd.MM.yyyy HH:mm' }}</p>
11+
<p>
12+
<button (click)="select()" class="btn btn-default">Select</button>
13+
<button (click)="unselect()" class="btn btn-default">Remove</button>
14+
<button [routerLink]="['/flight-edit', flight.id, {showDetails: true}]" class="btn btn-default">Edit</button>
15+
</p>
16+
</div>
17+
</div>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { FlightCardComponent } from './flight-card.component';
4+
5+
describe('FlightCardComponent', () => {
6+
let component: FlightCardComponent;
7+
let fixture: ComponentFixture<FlightCardComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [FlightCardComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(FlightCardComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Component, input, model, output } from '@angular/core';
2+
import { Flight } from '../data/flight';
3+
import { DatePipe } from '@angular/common';
4+
import { RouterLink } from '@angular/router';
5+
6+
@Component({
7+
selector: 'app-flight-card',
8+
imports: [DatePipe, RouterLink],
9+
templateUrl: './flight-card.component.html',
10+
styleUrl: './flight-card.component.css'
11+
})
12+
export class FlightCardComponent {
13+
14+
item = input.required<Flight>();
15+
// selected = input.required<boolean>();
16+
// selectedChange = output<boolean>();
17+
selected = model.required<boolean>();
18+
19+
select(): void {
20+
this.selected.set(true);
21+
}
22+
23+
unselect(): void {
24+
this.selected.set(false);
25+
}
26+
27+
}

src/app/flight-edit/flight-edit.component.css

Whitespace-only changes.

0 commit comments

Comments
 (0)