Merged contributor work
This commit is contained in:
@@ -440,21 +440,38 @@ 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') {
|
||||
this.$router.push({ name: 'NodeViewNew' });
|
||||
const workflowId = this.$store.getters.workflowId;
|
||||
const result = await this.dataHasChanged(workflowId);
|
||||
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) {
|
||||
this.$router.push({ name: 'NodeViewNew' });
|
||||
|
||||
this.$showMessage({
|
||||
title: 'Workflow created',
|
||||
message: 'A new workflow got created!',
|
||||
type: 'success',
|
||||
});
|
||||
this.$showMessage({
|
||||
title: 'Workflow created',
|
||||
message: 'A new workflow got created!',
|
||||
type: 'success',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.$router.push({ name: 'NodeViewNew' });
|
||||
|
||||
this.$showMessage({
|
||||
title: 'Workflow created',
|
||||
message: 'A new workflow got created!',
|
||||
type: 'success',
|
||||
});
|
||||
}
|
||||
} else if (key === 'credentials-open') {
|
||||
this.credentialOpenDialogVisible = true;
|
||||
} else if (key === 'credentials-new') {
|
||||
|
||||
@@ -33,6 +33,7 @@ import WorkflowActivator from '@/components/WorkflowActivator.vue';
|
||||
|
||||
import { restApi } from '@/components/mixins/restApi';
|
||||
import { genericHelpers } from '@/components/mixins/genericHelpers';
|
||||
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
|
||||
import { showMessage } from '@/components/mixins/showMessage';
|
||||
import { titleChange } from '@/components/mixins/titleChange';
|
||||
import { IWorkflowShortResponse } from '@/Interface';
|
||||
@@ -43,7 +44,7 @@ export default mixins(
|
||||
genericHelpers,
|
||||
restApi,
|
||||
showMessage,
|
||||
titleChange,
|
||||
workflowHelpers,
|
||||
).extend({
|
||||
name: 'WorkflowOpen',
|
||||
props: [
|
||||
@@ -89,10 +90,20 @@ export default mixins(
|
||||
this.$emit('closeDialog');
|
||||
return false;
|
||||
},
|
||||
openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
|
||||
async openWorkflow (data: IWorkflowShortResponse, column: any) { // tslint:disable-line:no-any
|
||||
if (column.label !== 'Active') {
|
||||
this.$titleSet(data.name, 'IDLE');
|
||||
this.$emit('openWorkflow', data.id);
|
||||
const workflowId = this.$store.getters.workflowId;
|
||||
const result = await this.dataHasChanged(workflowId);
|
||||
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.$emit('openWorkflow', data.id);
|
||||
}
|
||||
} else {
|
||||
this.$emit('openWorkflow', data.id);
|
||||
}
|
||||
}
|
||||
},
|
||||
openDialog () {
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
INodeTypesMaxCount,
|
||||
INodeUi,
|
||||
IWorkflowData,
|
||||
IWorkflowDb,
|
||||
IWorkflowDataUpdate,
|
||||
XYPositon,
|
||||
} from '../../Interface';
|
||||
@@ -30,6 +31,8 @@ import { restApi } from '@/components/mixins/restApi';
|
||||
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
||||
import { showMessage } from '@/components/mixins/showMessage';
|
||||
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import mixins from 'vue-typed-mixins';
|
||||
|
||||
export const workflowHelpers = mixins(
|
||||
@@ -478,5 +481,29 @@ export const workflowHelpers = mixins(
|
||||
node.position[1] += offsetPosition[1];
|
||||
}
|
||||
},
|
||||
async dataHasChanged(id: string) {
|
||||
const currentData = await this.getWorkflowDataToSave();
|
||||
|
||||
let data: IWorkflowDb;
|
||||
data = await this.restApi().getWorkflow(id);
|
||||
|
||||
if(data !== undefined) {
|
||||
const x = {
|
||||
nodes: data.nodes,
|
||||
connections: data.connections,
|
||||
settings: data.settings,
|
||||
name: data.name
|
||||
};
|
||||
const y = {
|
||||
nodes: currentData.nodes,
|
||||
connections: currentData.connections,
|
||||
settings: currentData.settings,
|
||||
name: currentData.name
|
||||
};
|
||||
return !isEqual(x, y);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user