Prevent form from closing if validation fails (#651)

* Prevent form from closing if validation fails

* Prevent closing on failure for custom forms

* Fixing group actions

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
davidjumani 2020-09-16 15:15:56 +05:30 committed by Rohit Yadav
parent 60551aeac2
commit 070cbc1d7c
52 changed files with 93 additions and 128 deletions

View File

@ -984,13 +984,13 @@ export default {
if (!hasJobId) {
this.fetchData()
}
this.closeAction()
}
}).catch(error => {
console.log(error)
this.$notifyError(error)
}).finally(f => {
this.actionLoading = false
this.closeAction()
})
})
},

View File

@ -212,13 +212,12 @@ export default {
this.$notification.success({
message: this.$t('label.loadbalancerinstance')
})
this.loading = false
this.$parent.$parent.close()
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
this.$parent.$parent.close()
this.parentFetchData()
}).finally(() => {
this.loading = false
})
}
}

View File

@ -135,11 +135,11 @@ export default {
catchMessage: this.$t('error.fetching.async.job.result')
})
}
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeAction()
})
})
}

View File

@ -154,8 +154,6 @@ export default {
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
this.$parent.$parent.close()
this.parentFetchData()
}).finally(() => {
this.loading = false
})

View File

@ -485,12 +485,12 @@ export default {
this.$emit('refresh-data')
}
})
this.closeAction()
this.$emit('refresh-data')
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -136,12 +136,12 @@ export default {
catchMessage: this.$t('error.fetching.async.job.result'),
successMessage: `${this.$t('message.success.delete.vm')} ${this.resource.name}`
})
this.parentFetchData()
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.parentFetchData()
this.closeAction()
})
})
},

View File

@ -198,12 +198,12 @@ export default {
this.$emit('refresh-data')
}
})
this.closeAction()
this.$emit('refresh-data')
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -182,8 +182,6 @@ export default {
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
this.$parent.$parent.close()
this.parentFetchData()
}).finally(() => {
this.loading = false
})

View File

@ -170,12 +170,12 @@ export default {
this.$emit('refresh-data')
}
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -383,12 +383,10 @@ export default {
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
duration: 0
})
}).finally(() => {
this.loading = false
this.closeAction()
})
}
}
this.closeAction()
}).catch(error => {
this.$notification.error({
message: this.$t('message.request.failed'),
@ -397,7 +395,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.closeAction()
})
})
},

View File

@ -349,12 +349,10 @@ export default {
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
duration: 0
})
}).finally(() => {
this.loading = false
this.closeAction()
})
}
}
this.closeAction()
}).catch(error => {
this.$notification.error({
message: this.$t('message.request.failed'),
@ -363,7 +361,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.closeAction()
})
})
},

View File

@ -145,12 +145,12 @@ export default {
message: this.$t('label.action.change.password'),
description: `${this.$t('message.success.change.password')} ${this.resource.username}`
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -105,6 +105,7 @@ export default {
description: values.samlEnable ? `${this.$t('message.success.enable.saml.auth')} ${this.$t('label.for')} ${this.resource.username}`
: `${this.$t('message.success.disable.saml.auth')} ${this.$t('label.for')} ${this.resource.username}`
})
this.handleClose()
}).catch(error => {
this.$notification.error({
message: this.$t('message.request.failed'),
@ -113,7 +114,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.handleClose()
})
})
}

View File

@ -162,11 +162,11 @@ export default {
description: 'Sucessfully created role ' + params.name
})
}
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeAction()
})
},
fetchRoles () {

View File

@ -254,6 +254,7 @@ export default {
this.$set(this.resource, 'isDel', true)
this.parentUpdActionData(this.resource)
}
this.parentCloseAction()
}).catch(error => {
this.$notification.error({
message: this.$t('message.request.failed'),
@ -261,7 +262,6 @@ export default {
})
}).finally(f => {
this.action.loading = false
this.parentCloseAction()
})
})
},

View File

@ -201,6 +201,7 @@ export default {
message: this.$t('label.edit.user'),
description: `${this.$t('message.success.update.user')} ${params.username}`
})
this.closeAction()
}).catch(error => {
this.$notification.error({
message: this.$t('message.request.failed'),
@ -209,7 +210,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.closeAction()
})
})
},

View File

@ -178,11 +178,11 @@ export default {
description: 'Sucessfully imported role ' + params.name
})
}
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeAction()
})
},
rulesCsvToJson (rulesCsv) {

View File

@ -247,12 +247,12 @@ export default {
}
api('addKubernetesSupportedVersion', params).then(json => {
this.$message.success(`${this.$t('message.success.add.kuberversion')}: ${values.semanticversion}`)
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -289,15 +289,14 @@ export default {
message: this.$t('message.success.upload'),
description: this.$t('message.success.upload.description')
})
this.closeAction()
this.$emit('refresh-data')
}).catch(e => {
this.$notification.error({
message: this.$t('message.upload.failed'),
description: `${this.$t('message.upload.iso.failed.description')} - ${e}`,
duration: 0
})
}).finally(() => {
this.closeAction()
this.$emit('refresh-data')
})
},
handleSubmit (e) {
@ -337,12 +336,12 @@ export default {
message: this.$t('label.action.register.iso'),
description: `${this.$t('message.success.register.iso')} ${params.name}`
})
this.closeAction()
this.$emit('refresh-data')
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeAction()
this.$emit('refresh-data')
})
} else {
if (this.fileList.length !== 1) {

View File

@ -503,15 +503,14 @@ export default {
message: this.$t('message.success.upload'),
description: this.$t('message.success.upload.template.description')
})
this.$emit('refresh-data')
this.closeAction()
}).catch(e => {
this.$notification.error({
message: this.$t('message.upload.failed'),
description: `${this.$t('message.upload.template.failed.description')} - ${e}`,
duration: 0
})
}).finally(() => {
this.$emit('refresh-data')
this.closeAction()
})
},
fetchZone () {
@ -881,12 +880,12 @@ export default {
message: this.$t('label.register.template'),
description: `${this.$t('message.success.register.template')} ${params.name}`
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeAction()
})
} else {
this.loading = true

View File

@ -280,12 +280,12 @@ export default {
loadingMessage: `${this.$t('label.deleting.template')} ${this.resource.name} ${this.$t('label.in.progress')}`,
catchMessage: this.$t('error.fetching.async.job.result')
})
this.onCloseModal()
this.fetchData()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.deleteLoading = false
this.onCloseModal()
this.fetchData()
})
},
fetchZoneData () {

View File

@ -130,12 +130,12 @@ export default {
}
api('updateKubernetesSupportedVersion', params).then(json => {
this.$message.success(`${this.$t('message.success.update.kubeversion')}: ${this.resource.name}`)
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -249,20 +249,17 @@ export default {
isextractable: this.resource.isExtractable,
featured: this.resource.featured,
op: this.selectedOperation.toLowerCase()
}).then(response => {
this.$notification.success({
message: `${this.$t('label.success.updated')} ${resourceType} ${this.$t('label.permissions')}`
})
this.closeModal()
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
}).finally(e => {
this.loading = false
})
.then(response => {
this.$notification.success({
message: `${this.$t('label.success.updated')} ${resourceType} ${this.$t('label.permissions')}`
})
})
.catch(error => {
this.$notifyError(error)
})
.finally(e => {
this.loading = false
this.closeModal()
this.parentFetchData()
})
}
}
}

View File

@ -667,12 +667,12 @@ export default {
message: this.$t('label.add.primary.storage'),
description: this.$t('label.add.primary.storage')
})
this.closeModal()
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeModal()
this.parentFetchData()
})
})
}

View File

@ -278,12 +278,12 @@ export default {
message: this.$t('label.add.secondary.storage'),
description: this.$t('label.add.secondary.storage')
})
this.closeModal()
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeModal()
this.parentFetchData()
})
})
}

View File

@ -240,6 +240,9 @@ export default {
if (cluster.id && this.showDedicated) {
this.dedicateCluster(cluster.id)
}
this.parentFetchData()
this.parentToggleLoading()
this.$parent.$parent.close()
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
@ -248,9 +251,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.parentFetchData()
this.parentToggleLoading()
this.$parent.$parent.close()
})
},
dedicateCluster (clusterId) {

View File

@ -294,6 +294,8 @@ export default {
if (host.id && this.showDedicated) {
this.dedicateHost(host.id)
}
this.parentFetchData()
this.$parent.$parent.close()
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
@ -302,8 +304,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.parentFetchData()
this.$parent.$parent.close()
})
},
dedicateHost (hostId) {

View File

@ -150,12 +150,12 @@ export default {
duration: 0
})
}
this.parentFetchData()
this.closeAction()
}).catch(error => {
console.log(error)
})
this.loading = false
this.parentFetchData()
this.closeAction()
})
},
migrateData (args, title) {

View File

@ -199,8 +199,6 @@ export default {
duration: 0
})
this.loading = false
this.parentFetchData()
this.$parent.$parent.close()
})
})
},

View File

@ -485,11 +485,11 @@ export default {
description: this.$t('message.success.create.isolated.network')
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.actionLoading = false
this.closeAction()
})
})
},

View File

@ -426,12 +426,12 @@ export default {
message: 'Network',
description: this.$t('message.success.create.l2.network')
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.actionLoading = false
this.closeAction()
})
})
},

View File

@ -794,12 +794,12 @@ export default {
description: this.$t('message.success.add.guest.network')
})
this.resetForm()
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.actionLoading = false
this.closeAction()
})
})
},

View File

@ -222,11 +222,11 @@ export default {
})
this.$emit('refresh-data')
}
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeAction()
})
})
}

View File

@ -343,12 +343,10 @@ export default {
}
})
this.closeModal()
this.form.resetFields()
}).catch(error => {
console.error(error)
this.$message.error(this.$t('message.success.add.vpn.customer.gateway'))
}).finally(() => {
this.form.resetFields()
this.closeModal()
})
})
}

View File

@ -246,11 +246,11 @@ export default {
networkid: this.selectedVpcTier
}).then(() => {
this.parentFetchData()
this.handleClose()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.handleClose()
})
},
handleClose () {

View File

@ -343,7 +343,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
}).finally(() => {
this.addTagLoading = false
})
@ -379,7 +378,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
},
handleChangePage (page, pageSize) {

View File

@ -216,6 +216,8 @@ export default {
loadingMessage: `${this.$t('label.assigning.vms')} ${this.$t('label.to')} ${this.resource.name}`,
catchMessage: this.$t('error.fetching.async.job.result')
})
this.$emit('refresh-data')
this.closeModal()
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
@ -224,8 +226,6 @@ export default {
})
}).finally(() => {
this.fetchLoading = false
this.$emit('refresh-data')
this.closeModal()
})
},
changePage (page, pageSize) {

View File

@ -275,6 +275,7 @@ export default {
loadingMessage: `${this.$t('label.acquiring.ip')} ${this.$t('label.for')} ${this.resource.name} ${this.$t('label.is.in.progress')}`,
catchMessage: this.$t('error.fetching.async.job.result')
})
this.onCloseModal()
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
@ -283,7 +284,6 @@ export default {
})
}).finally(() => {
this.acquireLoading = false
this.onCloseModal()
})
},
releaseIpAddress (ip) {

View File

@ -689,7 +689,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
})
},
@ -725,7 +724,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
},
openStickinessModal (id) {
@ -786,7 +784,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
},
handleDeleteStickinessPolicy () {
@ -819,7 +816,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
},
handleSubmitStickinessForm (e) {
@ -933,7 +929,6 @@ export default {
}).catch(error => {
this.$notifyError(error)
this.loading = false
this.closeModal()
})
},
handleDeleteRule (rule) {
@ -969,7 +964,6 @@ export default {
}).catch(error => {
this.$notifyError(error)
this.loading = false
this.closeModal()
})
},
handleOpenAddVMModal () {

View File

@ -469,7 +469,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
this.fetchData()
})
},
@ -548,7 +547,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
},
handleDeleteTag (tag) {
@ -583,7 +581,6 @@ export default {
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
})
},
openAddVMModal () {

View File

@ -1061,12 +1061,12 @@ export default {
? `${this.$t('message.create.service.offering')}: `
: `${this.$t('message.create.compute.offering')}: `
this.$message.success(message + values.name)
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeAction()
})
})
},

View File

@ -651,12 +651,12 @@ export default {
}
api('createDiskOffering', params).then(json => {
this.$message.success(`${this.$t('message.disk.offering.created')} ${values.name}}`)
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeAction()
})
})
},

View File

@ -932,12 +932,12 @@ export default {
params.traffictype = 'GUEST' // traffic type dropdown has been removed since it has only one option ('Guest'). Hardcode traffic type value here.
api('createNetworkOffering', params).then(json => {
this.$message.success('Network offering created: ' + values.name)
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeAction()
})
})
},

View File

@ -402,12 +402,12 @@ export default {
}
api('createVPCOffering', params).then(json => {
this.$message.success(`${this.$t('message.create.vpc.offering')}: ` + values.name)
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeAction()
})
})
},

View File

@ -284,11 +284,11 @@ export default {
message: this.$t('label.action.update.offering.access'),
description: this.$t('label.action.update.offering.access')
})
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.closeAction()
})
})
},

View File

@ -267,12 +267,12 @@ export default {
loadingMessage: `Adding Account: ${params.account} to project...`,
catchMessage: 'Error encountered while fetching async job result'
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},
@ -302,13 +302,13 @@ export default {
loadingMessage: `Adding User ${params.username} to project...`,
catchMessage: 'Error encountered while fetching async job result'
})
this.$emit('refresh-data')
this.closeAction()
}).catch(error => {
console.log('catch')
this.$notifyError(error)
}).finally(() => {
this.$emit('refresh-data')
this.loading = false
this.closeAction()
})
})
},

View File

@ -240,12 +240,12 @@ export default {
message: this.$t('label.update.project.role'),
description: this.$t('label.update.project.role')
})
this.fetchData()
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.fetchData()
this.closeAction()
})
})
},
@ -278,12 +278,12 @@ export default {
message: this.$t('label.create.project.role'),
description: this.$t('label.create.project.role')
})
this.fetchData()
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.fetchData()
this.closeAction()
})
})
},
@ -297,12 +297,12 @@ export default {
message: this.$t('label.delete.project.role'),
description: this.$t('label.delete.project.role')
})
this.fetchData()
this.closeAction()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.fetchData()
this.closeAction()
})
}
}

View File

@ -116,12 +116,12 @@ export default {
loadingMessage: this.$t('message.create.snapshot.from.vmsnapshot.progress'),
catchMessage: this.$t('error.fetching.async.job.result')
})
this.$emit('refresh-data')
this.closeModal()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeModal()
})
})
},

View File

@ -172,12 +172,12 @@ export default {
loadingMessage: this.$t('message.create.volume.processing'),
catchMessage: this.$t('error.fetching.async.job.result')
})
this.$emit('refresh-data')
this.closeModal()
}).catch(error => {
this.$notifyError(error)
}).finally(() => {
this.loading = false
this.$emit('refresh-data')
this.closeModal()
})
})
},

View File

@ -156,12 +156,10 @@ export default {
this.parentFetchData()
}
})
}).catch(error => {
this.$notifyError(error)
this.closeModal()
}).finally(() => {
this.closeModal()
this.parentFetchData()
}).catch(error => {
this.$notifyError(error)
})
}
}

View File

@ -121,6 +121,7 @@ export default {
this.closeModal()
}
})
this.closeModal()
}).catch(error => {
this.$notification.error({
message: `${this.$t('label.error')} ${error.response.status}`,
@ -129,7 +130,6 @@ export default {
})
}).finally(() => {
this.loading = false
this.closeModal()
})
})
},

View File

@ -229,10 +229,8 @@ export default {
description: `${this.$t('message.upload.iso.failed.description')} - ${e}`,
duration: 0
})
this.closeAction()
}).finally(() => {
this.loading = false
this.closeAction()
})
})
})