re-enable submit button in finally block
This commit is contained in:
parent
d21a5986a8
commit
356c8c0bbd
@ -52,16 +52,22 @@ export class CommercialUnitDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveCommercialPremise() {
|
async saveCommercialPremise() {
|
||||||
this.submitButton.disabled = true
|
try {
|
||||||
this.messageService.add(`saveCommercialPremise: ${ JSON.stringify(this.commercialPremise, undefined, 4) }`)
|
this.submitButton.disabled = true
|
||||||
if (this.commercialPremise.id == 0) {
|
this.messageService.add(`saveCommercialPremise: ${ JSON.stringify(this.commercialPremise, undefined, 4) }`)
|
||||||
this.messageService.add("about to insert new commercialPremise")
|
if (this.commercialPremise.id == 0) {
|
||||||
this.commercialPremise = await this.commercialPremiseService.postCommercialPremise(this.commercialPremise)
|
this.messageService.add("about to insert new commercialPremise")
|
||||||
this.messageService.add(`Successfully added flat with id ${this.commercialPremise.id}`)
|
this.commercialPremise = await this.commercialPremiseService.postCommercialPremise(this.commercialPremise)
|
||||||
} else {
|
this.messageService.add(`Successfully added commercialPremise with id ${this.commercialPremise.id}`)
|
||||||
this.messageService.add("about to update existing commercialPremise")
|
} 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'])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,16 +63,22 @@ export class FlatDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveFlat() {
|
async saveFlat() {
|
||||||
this.submitButton.disabled = true
|
try {
|
||||||
this.messageService.add(`saveFlat: ${ JSON.stringify(this.flat, undefined, 4) }`)
|
this.submitButton.disabled = true
|
||||||
if (this.flat.id == 0) {
|
this.messageService.add(`saveFlat: ${ JSON.stringify(this.flat, undefined, 4) }`)
|
||||||
this.messageService.add("about to insert new flat")
|
if (this.flat.id == 0) {
|
||||||
this.flat = await this.flatService.postFlat(this.flat)
|
this.messageService.add("about to insert new flat")
|
||||||
this.messageService.add(`Successfully added flat with id ${this.flat.id}`)
|
this.flat = await this.flatService.postFlat(this.flat)
|
||||||
} else {
|
this.messageService.add(`Successfully added flat with id ${this.flat.id}`)
|
||||||
this.messageService.add("about to update existing flat")
|
} 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 {
|
ngOnInit(): void {
|
||||||
|
@ -35,18 +35,23 @@ export class OverheadAdvanceDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveOverheadAdvance() {
|
async saveOverheadAdvance() {
|
||||||
this.submitButton.disabled = true
|
try {
|
||||||
this.messageService.add("saveOverheadAdvance")
|
this.submitButton.disabled = true
|
||||||
this.messageService.add(JSON.stringify(this.overheadAdvance, undefined, 4))
|
this.messageService.add("saveOverheadAdvance")
|
||||||
if (this.overheadAdvance.id == 0) {
|
this.messageService.add(JSON.stringify(this.overheadAdvance, undefined, 4))
|
||||||
this.messageService.add("about to insert new overheadAdvance")
|
if (this.overheadAdvance.id == 0) {
|
||||||
this.overheadAdvance = await this.overheadAdvanceService.postOverheadAdvance(this.overheadAdvance)
|
this.messageService.add("about to insert new overheadAdvance")
|
||||||
this.messageService.add(`Successfully added overheadAdvance with id ${this.overheadAdvance.id}`)
|
this.overheadAdvance = await this.overheadAdvanceService.postOverheadAdvance(this.overheadAdvance)
|
||||||
} else {
|
this.messageService.add(`Successfully added overheadAdvance with id ${this.overheadAdvance.id}`)
|
||||||
this.messageService.add("about to update existing overheadAdvance")
|
} else {
|
||||||
|
this.messageService.add("about to update existing overheadAdvance")
|
||||||
|
this.overheadAdvance = await this.overheadAdvanceService.putOverheadAdvance(this.overheadAdvance)
|
||||||
|
this.messageService.add(`Successfully changed overheadAdvance with id ${this.overheadAdvance.id}`)
|
||||||
|
}
|
||||||
|
this.router.navigate(['/overheadadvances'])
|
||||||
|
} finally {
|
||||||
|
this.submitButton.disabled = false
|
||||||
}
|
}
|
||||||
this.router.navigate(['/overheadadvances'])
|
|
||||||
// this.submitButton.disabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,16 +52,22 @@ export class ParkingDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveParking() {
|
async saveParking() {
|
||||||
this.submitButton.disabled = true
|
try {
|
||||||
this.messageService.add(`saveParking: ${ JSON.stringify(this.parking, undefined, 4) }`)
|
this.submitButton.disabled = true
|
||||||
if (this.parking.id == 0) {
|
this.messageService.add(`saveParking: ${ JSON.stringify(this.parking, undefined, 4) }`)
|
||||||
this.messageService.add("about to insert new parking")
|
if (this.parking.id == 0) {
|
||||||
this.parking = await this.parkingService.postParking(this.parking)
|
this.messageService.add("about to insert new parking")
|
||||||
this.messageService.add(`Successfully added flat with id ${this.parking.id}`)
|
this.parking = await this.parkingService.postParking(this.parking)
|
||||||
} else {
|
this.messageService.add(`Successfully added parking with id ${this.parking.id}`)
|
||||||
this.messageService.add("about to update existing parking")
|
} 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'])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,18 +41,23 @@ export class PremiseDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async savePremise() {
|
async savePremise() {
|
||||||
this.submitButton.disabled = true
|
try {
|
||||||
this.messageService.add("savePremise")
|
this.submitButton.disabled = true
|
||||||
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
|
this.messageService.add("savePremise")
|
||||||
if (this.premise.id == 0) {
|
this.messageService.add(JSON.stringify(this.premise, undefined, 4))
|
||||||
this.messageService.add("about to insert new premise")
|
if (this.premise.id == 0) {
|
||||||
this.premise = await this.premiseService.postPremise(this.premise)
|
this.messageService.add("about to insert new premise")
|
||||||
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
|
this.premise = await this.premiseService.postPremise(this.premise)
|
||||||
} else {
|
this.messageService.add(`Successfully added premises with id ${this.premise.id}`)
|
||||||
this.messageService.add("about to update existing premise")
|
} 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 {
|
ngOnInit(): void {
|
||||||
|
@ -56,23 +56,29 @@ export class TenantDetailsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async saveTenant() {
|
async saveTenant() {
|
||||||
this.submitButton.disabled = true
|
try {
|
||||||
this.messageService.add("saveTenant")
|
this.submitButton.disabled = true
|
||||||
this.messageService.add(JSON.stringify(this.tenant, undefined, 4))
|
this.messageService.add("saveTenant")
|
||||||
if (this.tenant.id == 0) {
|
this.messageService.add(JSON.stringify(this.tenant, undefined, 4))
|
||||||
this.messageService.add("about to insert new tenant")
|
if (this.tenant.id == 0) {
|
||||||
this.account = {
|
this.messageService.add("about to insert new tenant")
|
||||||
"id": 0,
|
this.account = {
|
||||||
"description": `account_${this.tenant.firstname}_${this.tenant.lastname}`
|
"id": 0,
|
||||||
|
"description": `account_${this.tenant.firstname}_${this.tenant.lastname}`
|
||||||
|
}
|
||||||
|
this.account = await this.accountService.postAccount(this.account)
|
||||||
|
this.tenant.account = this.account.id
|
||||||
|
this.tenant = await this.tenantService.postTenant(this.tenant)
|
||||||
|
this.messageService.add(`Successfully added account with id ${this.account.id} and tenant with id ${this.tenant.id}`)
|
||||||
|
} else {
|
||||||
|
this.messageService.add("about to update existing tenant")
|
||||||
|
this.tenant = await this.tenantService.putTenant(this.tenant)
|
||||||
|
this.messageService.add(`Successfully changed tenant with id ${this.tenant.id}`)
|
||||||
}
|
}
|
||||||
this.account = await this.accountService.postAccount(this.account)
|
this.router.navigate(['/tenants'])
|
||||||
this.tenant.account = this.account.id
|
} finally {
|
||||||
this.tenant = await this.tenantService.postTenant(this.tenant)
|
this.submitButton.disabled = false
|
||||||
this.messageService.add(`Successfully added account with id ${this.account.id} and tenant with id ${this.tenant.id}`)
|
|
||||||
} else {
|
|
||||||
this.messageService.add("about to update existing tenant")
|
|
||||||
}
|
}
|
||||||
this.router.navigate(['/tenants'])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user