re-enable submit button in finally block
This commit is contained in:
@ -63,16 +63,22 @@ export class FlatDetailsComponent implements OnInit {
|
||||
}
|
||||
|
||||
async saveFlat() {
|
||||
this.submitButton.disabled = true
|
||||
this.messageService.add(`saveFlat: ${ JSON.stringify(this.flat, undefined, 4) }`)
|
||||
if (this.flat.id == 0) {
|
||||
this.messageService.add("about to insert new flat")
|
||||
this.flat = await this.flatService.postFlat(this.flat)
|
||||
this.messageService.add(`Successfully added flat with id ${this.flat.id}`)
|
||||
} else {
|
||||
this.messageService.add("about to update existing flat")
|
||||
try {
|
||||
this.submitButton.disabled = true
|
||||
this.messageService.add(`saveFlat: ${ JSON.stringify(this.flat, undefined, 4) }`)
|
||||
if (this.flat.id == 0) {
|
||||
this.messageService.add("about to insert new flat")
|
||||
this.flat = await this.flatService.postFlat(this.flat)
|
||||
this.messageService.add(`Successfully added flat with id ${this.flat.id}`)
|
||||
} else {
|
||||
this.messageService.add("about to update existing flat")
|
||||
this.flat = await this.flatService.putFlat(this.flat)
|
||||
this.messageService.add(`Successfully changed flat with id ${this.flat.id}`)
|
||||
}
|
||||
this.router.navigate(['/flats'])
|
||||
} finally {
|
||||
this.submitButton.disabled = false
|
||||
}
|
||||
this.router.navigate(['/flats'])
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
Reference in New Issue
Block a user