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

@ -41,18 +41,23 @@ export class PremiseDetailsComponent implements OnInit {
}
async savePremise() {
this.submitButton.disabled = true
this.messageService.add("savePremise")
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
if (this.premise.id == 0) {
this.messageService.add("about to insert new premise")
this.premise = await this.premiseService.postPremise(this.premise)
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
} else {
this.messageService.add("about to update existing premise")
try {
this.submitButton.disabled = true
this.messageService.add("savePremise")
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
if (this.premise.id == 0) {
this.messageService.add("about to insert new premise")
this.premise = await this.premiseService.postPremise(this.premise)
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
} else {
this.messageService.add("about to update existing premise")
this.premise = await this.premiseService.putPremise(this.premise)
this.messageService.add(`Successfully changed premises with id ${this.premise.id}`)
}
this.router.navigate(['/premises'])
} finally {
this.submitButton.disabled = false
}
this.router.navigate(['/premises'])
// this.submitButton.disabled = false
}
ngOnInit(): void {