Fix unsaved changes logic when a resources is deleted
This commit is contained in:
@@ -206,7 +206,6 @@ export default {
|
||||
this.$AutomationAPI.workflowUndelete({ workflowID: this.workflowID })
|
||||
.then(() => {
|
||||
this.fetchWorkflow()
|
||||
|
||||
this.toastSuccess(this.$t('notification:workflow.undelete.success'))
|
||||
})
|
||||
.catch(this.toastErrorHandler(this.$t('notification:workflow.undelete.error')))
|
||||
@@ -217,6 +216,7 @@ export default {
|
||||
this.$AutomationAPI.workflowDelete({ workflowID: this.workflowID })
|
||||
.then(() => {
|
||||
this.fetchWorkflow()
|
||||
this.workflow.deletedAt = new Date()
|
||||
|
||||
this.toastSuccess(this.$t('notification:workflow.delete.success'))
|
||||
this.$router.push({ name: 'automation.workflow' })
|
||||
@@ -236,7 +236,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.workflow.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.workflow, this.initialWorkflowState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -313,6 +313,8 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchNode()
|
||||
|
||||
this.node.deletedAt = new Date()
|
||||
|
||||
this.toastSuccess(this.$t('notification:federation.delete.success'))
|
||||
this.$router.push({ name: 'federation.nodes' })
|
||||
})
|
||||
@@ -363,7 +365,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.node.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.node, this.initialNodeState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -226,6 +226,8 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchRoute()
|
||||
|
||||
this.route.deletedAt = new Date()
|
||||
|
||||
this.toastSuccess(this.$t('notification:gateway.delete.success'))
|
||||
this.$router.push({ name: 'system.apigw' })
|
||||
})
|
||||
@@ -347,7 +349,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.route.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
const routeState = !isEqual(this.route, this.initialRouteState)
|
||||
|
||||
@@ -330,6 +330,8 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchApplication()
|
||||
|
||||
this.application.deletedAt = new Date()
|
||||
|
||||
this.toastSuccess(this.$t('notification:application.delete.success'))
|
||||
this.$router.push({ name: 'system.application' })
|
||||
})
|
||||
@@ -343,7 +345,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.application.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.application, this.initialApplicationState) || this.unifyAssetStateChange ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -188,6 +188,8 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchAuthclient()
|
||||
|
||||
this.authclient.deletedAt = new Date()
|
||||
|
||||
this.toastSuccess(this.$t('notification:authclient.delete.success'))
|
||||
this.$router.push({ name: 'system.authClient' })
|
||||
})
|
||||
@@ -223,7 +225,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.authclient.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.authclient, this.initialAuthclientState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -247,6 +247,7 @@ export default {
|
||||
/**
|
||||
* Resource deleted, move back to the list
|
||||
*/
|
||||
this.connection.deletedAt = new Date()
|
||||
this.$router.push({ name: `system.connection` })
|
||||
} else {
|
||||
this.connection.deletedAt = null
|
||||
@@ -261,7 +262,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.connection.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.connection, this.initialConnectionState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -197,7 +197,10 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchQueue()
|
||||
this.toastSuccess(this.$t(`notification:queue.${event}.success`))
|
||||
if (!deletedAt) this.$router.push({ name: 'system.queue' })
|
||||
if (!deletedAt) {
|
||||
this.queue.deletedAt = new Date()
|
||||
this.$router.push({ name: 'system.queue' })
|
||||
}
|
||||
})
|
||||
.catch(this.toastErrorHandler(this.$t(`notification:queue.${event}.error`)))
|
||||
.finally(() => {
|
||||
@@ -208,7 +211,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.queue.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.queue, this.initialQueueState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -229,6 +229,7 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchRole()
|
||||
|
||||
this.role.deletedAt = new Date()
|
||||
this.toastSuccess(this.$t('notification:role.delete.success'))
|
||||
this.$router.push({ name: 'system.role' })
|
||||
})
|
||||
@@ -334,7 +335,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.role.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
const isDirty = (this.roleMembers || []).some(m => m.dirty !== m.current) || !isEqual(this.role, this.initialRoleState)
|
||||
|
||||
@@ -188,6 +188,7 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchSensitivityLevel()
|
||||
|
||||
this.sensitivityLevel.deletedAt = new Date()
|
||||
this.toastSuccess(this.$t('notification:sensitivityLevel.delete.success'))
|
||||
this.$router.push({ name: 'system.sensitivityLevel' })
|
||||
})
|
||||
@@ -199,7 +200,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.sensitivityLevel.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.sensitivityLevel, this.initialSensitivityLevelState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -193,6 +193,7 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchTemplate()
|
||||
|
||||
this.template.deletedAt = new Date()
|
||||
this.toastSuccess(this.$t('notification:template.delete.success'))
|
||||
this.$router.push({ name: 'system.template' })
|
||||
})
|
||||
@@ -240,7 +241,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.template.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
next(!isEqual(this.template, this.initialTemplateState) ? window.confirm(this.$t('general:editor.unsavedChanges')) : true)
|
||||
|
||||
@@ -349,6 +349,7 @@ export default {
|
||||
.then(() => {
|
||||
this.fetchUser()
|
||||
|
||||
this.user.deletedAt = new Date()
|
||||
this.toastSuccess(this.$t('notification:user.delete.success'))
|
||||
this.$router.push({ name: 'system.user' })
|
||||
})
|
||||
@@ -525,7 +526,7 @@ export default {
|
||||
checkUnsavedChanges (next, to) {
|
||||
const isNewPage = this.$route.path.includes('/new') && to.name.includes('edit')
|
||||
|
||||
if (isNewPage) {
|
||||
if (isNewPage || this.user.deletedAt) {
|
||||
next(true)
|
||||
} else if (!to.name.includes('edit')) {
|
||||
let userChangesStatus = !isEqual(this.user, this.initialUserState)
|
||||
|
||||
Reference in New Issue
Block a user