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,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 {
}
}