re-enable submit button in finally block
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user