overhead stuff
This commit is contained in:
@ -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