option to insert new tenant

This commit is contained in:
2021-08-31 10:51:08 +02:00
parent af0e4ffd74
commit e238b1fb9f
5 changed files with 20 additions and 5 deletions

View File

@ -18,6 +18,7 @@ const routes: Routes = [
{ path: 'parkings', component: MyParkingsComponent, canActivate: [ AuthGuardService ] }, { path: 'parkings', component: MyParkingsComponent, canActivate: [ AuthGuardService ] },
{ path: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] }, { path: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] },
{ path: 'tenant/:id', component: TenantDetailsComponent, canActivate: [ AuthGuardService ] }, { path: 'tenant/:id', component: TenantDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'tenant', component: TenantDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'logout', component: LogoutComponent }, { path: 'logout', component: LogoutComponent },
{ path: 'login', component: LoginComponent } { path: 'login', component: LoginComponent }
] ]

View File

@ -1,3 +1,8 @@
table { table {
width: 75%; width: 75%;
} }
.spacer {
flex: 1 1 auto;
}

View File

@ -2,7 +2,9 @@
<mat-card class="defaultCard"> <mat-card class="defaultCard">
<mat-card-header> <mat-card-header>
<mat-card-title> <mat-card-title>
Meine Mieter/innen <span>Meine Mieter/innen</span>
<span class="spacer"></span>
<a mat-button routerLink="/tenant">Neu anlegen</a>
</mat-card-title> </mat-card-title>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>

View File

@ -10,7 +10,7 @@
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<div> <div>
<form (ngSubmit)="updateTenant()"> <form (ngSubmit)="saveTenant()">
<div> <div>
<mat-form-field appearance="outline"> <mat-form-field appearance="outline">
<mat-label>Anrede</mat-label> <mat-label>Anrede</mat-label>

View File

@ -39,15 +39,22 @@ export class TenantDetailsComponent implements OnInit {
async getTenant(): Promise<void> { async getTenant(): Promise<void> {
try { try {
const id = +this.route.snapshot.paramMap.get('id') const id = +this.route.snapshot.paramMap.get('id')
if (id != 0) {
this.tenant = await this.tenantService.getTenant(id) this.tenant = await this.tenantService.getTenant(id)
}
} catch (err) { } catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4)) this.messageService.add(JSON.stringify(err, undefined, 4))
} }
} }
updateTenant() { saveTenant() {
this.messageService.add("updateTenant") this.messageService.add("saveTenant")
this.messageService.add(JSON.stringify(this.tenant, undefined, 4)) this.messageService.add(JSON.stringify(this.tenant, undefined, 4))
if (this.tenant.id == 0) {
this.messageService.add("about to insert new tenant")
} else {
this.messageService.add("about to update existing tenant")
}
} }
ngOnInit(): void { ngOnInit(): void {