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 ParkingDetailsComponent implements OnInit {
}
async saveParking() {
this.submitButton.disabled = true
this.messageService.add(`saveParking: ${ JSON.stringify(this.parking, undefined, 4) }`)
if (this.parking.id == 0) {
this.messageService.add("about to insert new parking")
this.parking = await this.parkingService.postParking(this.parking)
this.messageService.add(`Successfully added flat with id ${this.parking.id}`)
} else {
this.messageService.add("about to update existing parking")
try {
this.submitButton.disabled = true
this.messageService.add(`saveParking: ${ JSON.stringify(this.parking, undefined, 4) }`)
if (this.parking.id == 0) {
this.messageService.add("about to insert new parking")
this.parking = await this.parkingService.postParking(this.parking)
this.messageService.add(`Successfully added parking with id ${this.parking.id}`)
} else {
this.messageService.add("about to update existing parking")
this.parking = await this.parkingService.putParking(this.parking)
this.messageService.add(`Successfully changed parking with id ${this.parking.id}`)
}
this.router.navigate(['/parkings'])
} finally {
this.submitButton.disabled = false
}
this.router.navigate(['/parkings'])
}