mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🎉 Works with ctrl s, now working on a user saving from the side bar
This commit is contained in:
parent
ad1228e0ea
commit
70a584a46d
|
@ -186,6 +186,38 @@ export default mixins(
|
||||||
// When a node gets set as active deactivate the create-menu
|
// When a node gets set as active deactivate the create-menu
|
||||||
this.createNodeActive = false;
|
this.createNodeActive = false;
|
||||||
},
|
},
|
||||||
|
nodes: {
|
||||||
|
handler: async function (val, oldVal) {
|
||||||
|
// Load a workflow
|
||||||
|
let workflowId = null as string | null;
|
||||||
|
if (this.$route && this.$route.params.name) {
|
||||||
|
workflowId = this.$route.params.name;
|
||||||
|
}
|
||||||
|
if(workflowId !== null) {
|
||||||
|
this.isDirty = await this.dataHasChanged(workflowId);
|
||||||
|
} else {
|
||||||
|
this.isDirty = true;
|
||||||
|
}
|
||||||
|
console.log(this.isDirty);
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
|
connections: {
|
||||||
|
handler: async function (val, oldVal) {
|
||||||
|
// Load a workflow
|
||||||
|
let workflowId = null as string | null;
|
||||||
|
if (this.$route && this.$route.params.name) {
|
||||||
|
workflowId = this.$route.params.name;
|
||||||
|
}
|
||||||
|
if(workflowId !== null) {
|
||||||
|
this.isDirty = await this.dataHasChanged(workflowId);
|
||||||
|
} else {
|
||||||
|
this.isDirty = true;
|
||||||
|
}
|
||||||
|
console.log(this.isDirty);
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
activeNode (): INodeUi | null {
|
activeNode (): INodeUi | null {
|
||||||
|
@ -259,6 +291,7 @@ export default mixins(
|
||||||
ctrlKeyPressed: false,
|
ctrlKeyPressed: false,
|
||||||
debouncedFunctions: [] as any[], // tslint:disable-line:no-any
|
debouncedFunctions: [] as any[], // tslint:disable-line:no-any
|
||||||
stopExecutionInProgress: false,
|
stopExecutionInProgress: false,
|
||||||
|
isDirty: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
|
@ -433,6 +466,8 @@ export default mixins(
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
this.isDirty = false;
|
||||||
|
|
||||||
this.callDebounced('saveCurrentWorkflow', 1000);
|
this.callDebounced('saveCurrentWorkflow', 1000);
|
||||||
} else if (e.key === 'Enter') {
|
} else if (e.key === 'Enter') {
|
||||||
// Activate the last selected node
|
// Activate the last selected node
|
||||||
|
@ -1305,6 +1340,7 @@ export default mixins(
|
||||||
if (this.$route.params.action === 'workflowSave') {
|
if (this.$route.params.action === 'workflowSave') {
|
||||||
// In case the workflow got saved we do not have to run init
|
// In case the workflow got saved we do not have to run init
|
||||||
// as only the route changed but all the needed data is already loaded
|
// as only the route changed but all the needed data is already loaded
|
||||||
|
this.isDirty = false;
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1331,20 +1367,13 @@ export default mixins(
|
||||||
document.addEventListener('keydown', this.keyDown);
|
document.addEventListener('keydown', this.keyDown);
|
||||||
document.addEventListener('keyup', this.keyUp);
|
document.addEventListener('keyup', this.keyUp);
|
||||||
|
|
||||||
window.addEventListener("beforeunload", (e) => {
|
window.addEventListener("beforeunload", (e) => {
|
||||||
let workflowId = null as string | null;
|
if(this.isDirty === true) {
|
||||||
if (this.$route.params.name) {
|
const confirmationMessage = 'It looks like you have been editing something. '
|
||||||
workflowId = this.$route.params.name;
|
+ 'If you leave before saving, your changes will be lost.';
|
||||||
|
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
|
||||||
|
return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
|
||||||
}
|
}
|
||||||
if(workflowId !== null) {
|
|
||||||
//const dataHasChanged = await this.dataHasChanged(workflowId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmationMessage = 'It looks like you have been editing something. '
|
|
||||||
+ 'If you leave before saving, your changes will be lost.';
|
|
||||||
|
|
||||||
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
|
|
||||||
return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
__addConnection (connection: [IConnection, IConnection], addVisualConnection = false) {
|
__addConnection (connection: [IConnection, IConnection], addVisualConnection = false) {
|
||||||
|
|
Loading…
Reference in a new issue