🚧 Added Vuex dirty state flag as central source of truth for if there are unsaved changes
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<font-awesome-icon icon="check" class="execution-icon success" v-if="executionFinished" title="Execution was successful" />
|
||||
<font-awesome-icon icon="times" class="execution-icon error" v-else title="Execution did fail" />
|
||||
</span>
|
||||
of
|
||||
of
|
||||
<span class="workflow-name clickable" title="Open Workflow">
|
||||
<span @click="openWorkflow(workflowExecution.workflowId)">"{{workflowName}}"</span>
|
||||
</span>
|
||||
@@ -154,6 +154,9 @@ export default mixins(
|
||||
workflowRunning (): boolean {
|
||||
return this.$store.getters.isActionActive('workflowRunning');
|
||||
},
|
||||
isDirty () : boolean {
|
||||
return this.$store.getters.getStateIsDirty;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async openWorkflow (workflowId: string) {
|
||||
|
||||
@@ -398,7 +398,7 @@ export default mixins(
|
||||
return;
|
||||
}
|
||||
|
||||
this.$store.commit('setWorkflowName', workflowName);
|
||||
this.$store.commit('setWorkflowName', {newName: workflowName, setStateDirty: true});
|
||||
|
||||
this.$showMessage({
|
||||
title: 'Workflow renamed',
|
||||
@@ -440,18 +440,15 @@ export default mixins(
|
||||
|
||||
saveAs(blob, workflowName + '.json');
|
||||
} else if (key === 'workflow-save') {
|
||||
console.log("saving......");
|
||||
this.saveCurrentWorkflow();
|
||||
} else if (key === 'workflow-save-as') {
|
||||
console.log("saving......");
|
||||
this.saveCurrentWorkflow(true);
|
||||
} else if (key === 'help-about') {
|
||||
this.aboutDialogVisible = true;
|
||||
} else if (key === 'workflow-settings') {
|
||||
this.workflowSettingsDialogVisible = true;
|
||||
} else if (key === 'workflow-new') {
|
||||
const workflowId = this.$store.getters.workflowId;
|
||||
const result = await this.dataHasChanged(workflowId);
|
||||
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 === true) {
|
||||
|
||||
@@ -92,8 +92,7 @@ export default mixins(
|
||||
},
|
||||
async openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
|
||||
if (column.label !== 'Active') {
|
||||
const workflowId = this.$store.getters.workflowId;
|
||||
const result = await this.dataHasChanged(workflowId);
|
||||
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) {
|
||||
|
||||
@@ -31,7 +31,7 @@ export const moveNodeWorkflow = mixins(nodeIndex).extend({
|
||||
|
||||
const nodeViewOffsetPositionX = offsetPosition[0] + (e.pageX - this.moveLastPosition[0]);
|
||||
const nodeViewOffsetPositionY = offsetPosition[1] + (e.pageY - this.moveLastPosition[1]);
|
||||
this.$store.commit('setNodeViewOffsetPosition', [nodeViewOffsetPositionX, nodeViewOffsetPositionY]);
|
||||
this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true});
|
||||
|
||||
// Update the last position
|
||||
this.moveLastPosition[0] = e.pageX;
|
||||
@@ -87,7 +87,7 @@ export const moveNodeWorkflow = mixins(nodeIndex).extend({
|
||||
const offsetPosition = this.$store.getters.getNodeViewOffsetPosition;
|
||||
const nodeViewOffsetPositionX = offsetPosition[0] - e.deltaX;
|
||||
const nodeViewOffsetPositionY = offsetPosition[1] - e.deltaY;
|
||||
this.$store.commit('setNodeViewOffsetPosition', [nodeViewOffsetPositionX, nodeViewOffsetPositionY]);
|
||||
this.$store.commit('setNodeViewOffsetPosition', {newOffset: [nodeViewOffsetPositionX, nodeViewOffsetPositionY], setStateDirty: true});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -420,7 +420,7 @@ export const workflowHelpers = mixins(
|
||||
|
||||
this.$store.commit('setActive', workflowData.active || false);
|
||||
this.$store.commit('setWorkflowId', workflowData.id);
|
||||
this.$store.commit('setWorkflowName', workflowData.name);
|
||||
this.$store.commit('setWorkflowName', {newName: workflowData.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowSettings', workflowData.settings || {});
|
||||
} else {
|
||||
// Workflow exists already so update it
|
||||
@@ -435,7 +435,7 @@ export const workflowHelpers = mixins(
|
||||
}
|
||||
|
||||
this.$store.commit('removeActiveAction', 'workflowSaving');
|
||||
|
||||
this.$store.commit('setStateDirty', false);
|
||||
this.$showMessage({
|
||||
title: 'Workflow saved',
|
||||
message: `The workflow "${workflowData.name}" got saved!`,
|
||||
@@ -492,13 +492,13 @@ export const workflowHelpers = mixins(
|
||||
nodes: data.nodes,
|
||||
connections: data.connections,
|
||||
settings: data.settings,
|
||||
name: data.name
|
||||
name: data.name,
|
||||
};
|
||||
const y = {
|
||||
nodes: currentData.nodes,
|
||||
connections: currentData.connections,
|
||||
settings: currentData.settings,
|
||||
name: currentData.name
|
||||
name: currentData.name,
|
||||
};
|
||||
return !isEqual(x, y);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export const workflowSave = mixins(
|
||||
|
||||
this.$store.commit('setActive', workflowData.active || false);
|
||||
this.$store.commit('setWorkflowId', workflowData.id);
|
||||
this.$store.commit('setWorkflowName', workflowData.name);
|
||||
this.$store.commit('setWorkflowName', {newName: workflowData.name, setStateDirty: false});
|
||||
this.$store.commit('setWorkflowSettings', workflowData.settings || {});
|
||||
} else {
|
||||
// Workflow exists already so update it
|
||||
@@ -89,7 +89,7 @@ export const workflowSave = mixins(
|
||||
}
|
||||
|
||||
this.$store.commit('removeActiveAction', 'workflowSaving');
|
||||
|
||||
this.$store.commit('setStateDirty', false);
|
||||
this.$showMessage({
|
||||
title: 'Workflow saved',
|
||||
message: `The workflow "${workflowData.name}" got saved!`,
|
||||
|
||||
Reference in New Issue
Block a user