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

@@ -92,12 +92,28 @@ export default mixins(
},
async openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
if (column.label !== 'Active') {
const currentWorkflowId = this.$store.getters.workflowId;
if (data.id === currentWorkflowId) {
this.$showMessage({
title: 'Already open',
message: 'This is the current workflow',
type: 'error',
duration: 800,
});
// Do nothing if current workflow is the one user chose to open
return;
}
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;
} else {
// This is used to avoid duplicating the message
this.$store.commit('setStateDirty', false);
this.$emit('openWorkflow', data.id);
}
} else {