more details pages

This commit is contained in:
2021-09-02 15:50:29 +02:00
parent ce4ff75bca
commit 7c180f0986
16 changed files with 348 additions and 24 deletions

View File

@ -3,6 +3,9 @@
<mat-card-header>
<mat-card-title>
Meine Büros
<span>Meine Büros</span>
<span class="spacer"></span>
<a mat-button routerLink="/commercialunit">Neu anlegen</a>
</mat-card-title>
</mat-card-header>
<mat-card-content>
@ -10,14 +13,14 @@
<table mat-table [dataSource]="dataSource" #zftable>
<ng-container matColumnDef="description">
<th mat-header-cell *matHeaderCellDef>Beschreibung</th>
<td mat-cell *matCellDef="let element">{{element.description}}</td>
<td mat-cell *matCellDef="let element">{{element.commercialPremise.description}}</td>
</ng-container>
<ng-container matColumnDef="premise">
<th mat-header-cell *matHeaderCellDef>Haus</th>
<td mat-cell *matCellDef="let element">{{element.premise}}</td>
<td mat-cell *matCellDef="let element">{{element.premise.description}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/commercialunit/', row.id]"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/commercialunit/', row.commercialPremise.id]"></tr>
</table>
</div>
</mat-card-content>

View File

@ -1,9 +1,14 @@
import { Component, OnInit } from '@angular/core';
import { MessageService } from '../message.service';
import { CommercialPremiseService } from '../data-object-service';
import { CommercialPremise } from '../data-objects';
import { CommercialPremiseService, PremiseService } from '../data-object-service';
import { CommercialPremise, Premise } from '../data-objects';
import { MatTableDataSource } from '@angular/material/table'
interface DN_CommercialPremise {
commercialPremise: CommercialPremise
premise: Premise
}
@Component({
selector: 'app-my-commercial-units',
templateUrl: './my-commercial-units.component.html',
@ -12,18 +17,40 @@ import { MatTableDataSource } from '@angular/material/table'
export class MyCommercialUnitsComponent implements OnInit {
commercialPremises: CommercialPremise[]
dataSource: MatTableDataSource<CommercialPremise>
premises: Premise[]
dnCommercialPremises: DN_CommercialPremise[] = []
dataSource: MatTableDataSource<DN_CommercialPremise>
displayedColumns: string[] = ["description", "premise"]
constructor(private commercialPremiseService: CommercialPremiseService, private messageService: MessageService) { }
constructor(
private commercialPremiseService: CommercialPremiseService,
private premiseService: PremiseService,
private messageService: MessageService
) { }
async getCommercialPremises(): Promise<void> {
try {
this.messageService.add("Trying to load commercialPremises")
this.commercialPremises = await this.commercialPremiseService.getCommercialPremises()
this.messageService.add("CommercialPremises loaded")
this.messageService.add("Trying to load premises")
this.premises = await this.premiseService.getPremises()
this.messageService.add(`Premises loaded: ${ JSON.stringify(this.premises, undefined, 4) }`)
this.dataSource = new MatTableDataSource<CommercialPremise>(this.commercialPremises)
const premisesDict = new Map<number, Premise>()
for (let p of this.premises) {
premisesDict.set(p.id, p)
}
for (let f of this.commercialPremises) {
this.dnCommercialPremises.push({
commercialPremise: f,
premise: premisesDict.get(f.premise)
})
}
this.dataSource = new MatTableDataSource<DN_CommercialPremise>(this.dnCommercialPremises)
} catch (err) {
this.messageService.add(JSON.stringify(err, undefined, 4))
}