fee pages

This commit is contained in:
2021-09-07 17:52:02 +02:00
parent 356c8c0bbd
commit cf35af9c1e
13 changed files with 288 additions and 5 deletions

View File

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

View File

@ -0,0 +1,39 @@
<section class="mat-typography">
<mat-card class="defaultCard">
<mat-card-header>
<mat-card-title>
<span>Mietsätze</span>
<span class="spacer"></span>
<a mat-button routerLink="/fee">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="fee_type">
<th mat-header-cell *matHeaderCellDef>Typ</th>
<td mat-cell *matCellDef="let element">{{element.fee_type}}</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]="['/fee/', 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 { FeeListComponent } from './fee-list.component';
describe('FeeListComponent', () => {
let component: FeeListComponent;
let fixture: ComponentFixture<FeeListComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ FeeListComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(FeeListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

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