Improvements on #911 to display unsaved changes. Now works with back button. (#1098)

Co-authored-by: Omar Ajoue <krynble@gmail.com>
This commit is contained in:
Jan
2020-10-25 12:47:49 +01:00
committed by GitHub
parent dc93694a1a
commit 72ac20b070
4 changed files with 48 additions and 3 deletions

View File

@@ -214,6 +214,21 @@ export default mixins(
deep: true,
},
},
async beforeRouteLeave(to, from, next) {
const result = this.$store.getters.getStateIsDirty;
if(result) {
const importConfirm = await this.confirmMessage(`When you switch workflows your current workflow changes will be lost.`, 'Save your Changes?', 'warning', 'Yes, switch workflows and forget changes');
if (importConfirm === false) {
next(false);
} else {
// Prevent other popups from displaying
this.$store.commit('setStateDirty', false);
next();
}
} else {
next();
}
},
computed: {
activeNode (): INodeUi | null {
return this.$store.getters.activeNode;
@@ -358,6 +373,8 @@ export default mixins(
await this.addNodes(data.nodes, data.connections);
this.$store.commit('setStateDirty', false);
return data;
},
touchTap (e: MouseEvent | TouchEvent) {
@@ -1339,6 +1356,8 @@ export default mixins(
];
await this.addNodes(defaultNodes);
this.$store.commit('setStateDirty', false);
},
async initView (): Promise<void> {
if (this.$route.params.action === 'workflowSave') {
@@ -1351,9 +1370,17 @@ export default mixins(
if (this.$route.name === 'ExecutionById') {
// Load an execution
const executionId = this.$route.params.id;
await this.openExecution(executionId);
} else {
const result = this.$store.getters.getStateIsDirty;
if(result) {
const importConfirm = await this.confirmMessage(`When you switch workflows your current workflow changes will be lost.`, 'Save your Changes?', 'warning', 'Yes, switch workflows and forget changes');
if (importConfirm === false) {
return Promise.resolve();
}
}
// Load a workflow
let workflowId = null as string | null;
if (this.$route.params.name) {