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

@ -52,16 +52,22 @@ export class CommercialUnitDetailsComponent implements OnInit {
}
async saveCommercialPremise() {
this.submitButton.disabled = true
this.messageService.add(`saveCommercialPremise: ${ JSON.stringify(this.commercialPremise, undefined, 4) }`)
if (this.commercialPremise.id == 0) {
this.messageService.add("about to insert new commercialPremise")
this.commercialPremise = await this.commercialPremiseService.postCommercialPremise(this.commercialPremise)
this.messageService.add(`Successfully added flat with id ${this.commercialPremise.id}`)
} else {
this.messageService.add("about to update existing commercialPremise")
try {
this.submitButton.disabled = true
this.messageService.add(`saveCommercialPremise: ${ JSON.stringify(this.commercialPremise, undefined, 4) }`)
if (this.commercialPremise.id == 0) {
this.messageService.add("about to insert new commercialPremise")
this.commercialPremise = await this.commercialPremiseService.postCommercialPremise(this.commercialPremise)
this.messageService.add(`Successfully added commercialPremise with id ${this.commercialPremise.id}`)
} else {
this.messageService.add("about to update existing commercialPremise")
this.commercialPremise = await this.commercialPremiseService.putCommercialPremise(this.commercialPremise)
this.messageService.add(`Successfully changed commercialPremise with id ${this.commercialPremise.id}`)
}
this.router.navigate(['/commercialunits'])
} finally {
this.submitButton.disabled = false
}
this.router.navigate(['/commercialunits'])
}