overhead stuff

This commit is contained in:
2021-09-02 18:26:55 +02:00
parent 7c180f0986
commit 1ce54cf9cf
11 changed files with 257 additions and 6 deletions

View File

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

View File

@ -0,0 +1,35 @@
<section class="mat-typography">
<mat-card class="defaultCard">
<mat-card-header>
<mat-card-title>
<span>Betriebskostensätze</span>
<span class="spacer"></span>
<a mat-button routerLink="/overheadadvance">Neu anlegen</a>
</mat-card-title>
</mat-card-header>
<mat-card-content>
<div>
<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>
</ng-container>
<ng-container matColumnDef="amount">
<th mat-header-cell *matHeaderCellDef>Betrag</th>
<td mat-cell *matCellDef="let element">{{element.amount}} €</td>
</ng-container>
<ng-container matColumnDef="startdate">
<th mat-header-cell *matHeaderCellDef>Beginn</th>
<td mat-cell *matCellDef="let element">{{element.startdate}}</td>
</ng-container>
<ng-container matColumnDef="enddate">
<th mat-header-cell *matHeaderCellDef>Ende</th>
<td mat-cell *matCellDef="let element">{{element.enddate}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [routerLink]="['/overheadadvance/', row.id]"></tr>
</table>
</div>
</mat-card-content>
</mat-card>
</section>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OverheadAdvanceListComponent } from './overhead-advance-list.component';
describe('OverheadAdvanceListComponent', () => {
let component: OverheadAdvanceListComponent;
let fixture: ComponentFixture<OverheadAdvanceListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ OverheadAdvanceListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(OverheadAdvanceListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,41 @@
import { Component, OnInit } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { OverheadAdvanceService } from '../data-object-service';
import { OverheadAdvance } from '../data-objects';
import { MessageService } from '../message.service';
@Component({
selector: 'app-overhead-advance-list',
templateUrl: './overhead-advance-list.component.html',
styleUrls: ['./overhead-advance-list.component.css']
})
export class OverheadAdvanceListComponent implements OnInit {
overheadAdvances: OverheadAdvance[]
dataSource: MatTableDataSource<OverheadAdvance>
displayedColumns: string[] = [ "description", "amount", "startdate", "enddate" ]
constructor(
private overheadAdvanceService: OverheadAdvanceService,
private messageService: MessageService
) { }
async getOverheadAdvances(): Promise<void> {
try {
this.messageService.add("Trying to load overheadAdvances")
this.overheadAdvances = await this.overheadAdvanceService.getOverheadAdvances()
this.messageService.add("OverheadAdvances loaded")
this.dataSource = new MatTableDataSource<OverheadAdvance>(this.overheadAdvances)
} catch (err) {
this.messageService.add(`Error in getOverheadAdvances: ${ JSON.stringify(err, undefined, 4) }`)
}
}
ngOnInit(): void {
this.messageService.add("OverheadAdvanceListComponent.ngOnInit")
this.getOverheadAdvances()
}
}