re-enable submit button in finally block

This commit is contained in:
2021-09-07 16:02:09 +02:00
parent d21a5986a8
commit 356c8c0bbd
6 changed files with 98 additions and 64 deletions

View File

@ -35,18 +35,23 @@ export class OverheadAdvanceDetailsComponent implements OnInit {
}
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")
try {
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.overheadAdvance = await this.overheadAdvanceService.putOverheadAdvance(this.overheadAdvance)
this.messageService.add(`Successfully changed overheadAdvance with id ${this.overheadAdvance.id}`)
}
this.router.navigate(['/overheadadvances'])
} finally {
this.submitButton.disabled = false
}
this.router.navigate(['/overheadadvances'])
// this.submitButton.disabled = false
}