overhead stuff
This commit is contained in:
@ -0,0 +1,41 @@
|
||||
<section class="mat-typography">
|
||||
<mat-card class="defaultCard">
|
||||
<mat-card-header>
|
||||
<mat-card-title>
|
||||
{{overheadAdvance?.description}}
|
||||
</mat-card-title>
|
||||
<mat-card-subtitle>
|
||||
ID: {{overheadAdvance?.id}}
|
||||
</mat-card-subtitle>
|
||||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<div>
|
||||
<form (ngSubmit)="saveOverheadAdvance()">
|
||||
<div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beschreibung</mat-label>
|
||||
<input matInput name="description" [(ngModel)]="overheadAdvance.description"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Betrag (€)</mat-label>
|
||||
<input matInput type="number" name="amount" [(ngModel)]="overheadAdvance.amount"/>
|
||||
</mat-form-field>
|
||||
</div><div>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Beginn</mat-label>
|
||||
<input matInput name="startdate" [(ngModel)]="overheadAdvance.startdate" [matDatepicker]="startdatepicker"/>
|
||||
<mat-datepicker-toggle matSuffix [for]="startdatepicker"></mat-datepicker-toggle>
|
||||
<mat-datepicker #startdatepicker></mat-datepicker>
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Ende</mat-label>
|
||||
<input matInput name="enddate" [(ngModel)]="overheadAdvance.enddate"/>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<button #submitButton type="submit" mat-raised-button color="primary">Speichern</button>
|
||||
</form>
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
@ -0,0 +1,25 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { OverheadAdvanceDetailsComponent } from './overhead-advance-details.component';
|
||||
|
||||
describe('OverheadAdvanceDetailsComponent', () => {
|
||||
let component: OverheadAdvanceDetailsComponent;
|
||||
let fixture: ComponentFixture<OverheadAdvanceDetailsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ OverheadAdvanceDetailsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(OverheadAdvanceDetailsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,56 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { OverheadAdvanceService } from '../data-object-service';
|
||||
import { NULL_OverheadAdvance, OverheadAdvance } from '../data-objects';
|
||||
import { MessageService } from '../message.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-overhead-advance-details',
|
||||
templateUrl: './overhead-advance-details.component.html',
|
||||
styleUrls: ['./overhead-advance-details.component.css']
|
||||
})
|
||||
export class OverheadAdvanceDetailsComponent implements OnInit {
|
||||
|
||||
@ViewChild('submitButton') submitButton: MatButton
|
||||
|
||||
overheadAdvance: OverheadAdvance = NULL_OverheadAdvance
|
||||
|
||||
constructor(
|
||||
private overheadAdvanceService: OverheadAdvanceService,
|
||||
private messageService: MessageService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
async getOverheadAdvance(): Promise<void> {
|
||||
try {
|
||||
const id = +this.route.snapshot.paramMap.get('id')
|
||||
if (id != 0) {
|
||||
this.overheadAdvance = await this.overheadAdvanceService.getOverheadAdvance(id)
|
||||
}
|
||||
} catch (err) {
|
||||
this.messageService.add(JSON.stringify(err, undefined, 4))
|
||||
}
|
||||
}
|
||||
|
||||
async saveOverheadAdvance() {
|
||||
this.submitButton.disabled = true
|
||||
this.messageService.add("saveOverheadAdvance")
|
||||
this.messageService.add(JSON.stringify(this.overheadAdvance, undefined, 4))
|
||||
if (this.overheadAdvance.id == 0) {
|
||||
this.messageService.add("about to insert new overheadAdvance")
|
||||
this.overheadAdvance = await this.overheadAdvanceService.postOverheadAdvance(this.overheadAdvance)
|
||||
this.messageService.add(`Successfully added overheadAdvance with id ${this.overheadAdvance.id}`)
|
||||
} else {
|
||||
this.messageService.add("about to update existing overheadAdvance")
|
||||
}
|
||||
this.router.navigate(['/overheadadvances'])
|
||||
// this.submitButton.disabled = false
|
||||
}
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user