option to insert new tenant

This commit is contained in:
Wolfgang Hottgenroth 2021-08-31 10:51:08 +02:00
parent af0e4ffd74
commit e238b1fb9f
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
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: 'commercialunits', component: MyCommercialUnitsComponent, canActivate: [ AuthGuardService ] },
{ path: 'tenant/:id', component: TenantDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'tenant', component: TenantDetailsComponent, canActivate: [ AuthGuardService ] },
{ path: 'logout', component: LogoutComponent },
{ path: 'login', component: LoginComponent }
]

View File

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

View File

@ -2,7 +2,9 @@
<mat-card class="defaultCard">
<mat-card-header>
<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-header>
<mat-card-content>

View File

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

View File

@ -39,15 +39,22 @@ export class TenantDetailsComponent implements OnInit {
async getTenant(): Promise<void> {
try {
const id = +this.route.snapshot.paramMap.get('id')
if (id != 0) {
this.tenant = await this.tenantService.getTenant(id)
}
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
}
}
updateTenant() {
this.messageService.add("updateTenant")
saveTenant() {
this.messageService.add("saveTenant")
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 {