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