mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-30 13:51:21 -08:00
add delete connection
This commit is contained in:
parent
b140d71a42
commit
1fadd1c9c9
|
@ -1682,8 +1682,8 @@ export default mixins(
|
||||||
return uuids[0] === sourceEndpoint && uuids[1] === targetEndpoint;
|
return uuids[0] === sourceEndpoint && uuids[1] === targetEndpoint;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onNodeMoved (node: INodeUi) {
|
getIncomingOutgoingConnections(nodeName: string): {incoming: Connection[], outgoing: Connection[]} {
|
||||||
const name = `${NODE_NAME_PREFIX}${this.$store.getters.getNodeIndex(node.name)}`;
|
const name = `${NODE_NAME_PREFIX}${this.$store.getters.getNodeIndex(nodeName)}`;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const outgoing = this.instance.getConnections({
|
const outgoing = this.instance.getConnections({
|
||||||
source: name,
|
source: name,
|
||||||
|
@ -1694,6 +1694,14 @@ export default mixins(
|
||||||
target: name,
|
target: name,
|
||||||
}) as Connection[];
|
}) as Connection[];
|
||||||
|
|
||||||
|
return {
|
||||||
|
incoming,
|
||||||
|
outgoing,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
onNodeMoved (node: INodeUi) {
|
||||||
|
const {incoming, outgoing} = this.getIncomingOutgoingConnections(node.name);
|
||||||
|
|
||||||
[...incoming, ...outgoing].forEach((connection: Connection) => {
|
[...incoming, ...outgoing].forEach((connection: Connection) => {
|
||||||
CanvasHelpers.showOrHideMidpointArrow(connection);
|
CanvasHelpers.showOrHideMidpointArrow(connection);
|
||||||
CanvasHelpers.showOrHideItemsLabel(connection);
|
CanvasHelpers.showOrHideItemsLabel(connection);
|
||||||
|
@ -1749,7 +1757,10 @@ export default mixins(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const node = this.$store.getters.getNodeByName(nodeName);
|
const node = this.$store.getters.getNodeByName(nodeName) as INodeUi | null;
|
||||||
|
if (!node) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// "requiredNodeTypes" are also defined in cli/commands/run.ts
|
// "requiredNodeTypes" are also defined in cli/commands/run.ts
|
||||||
const requiredNodeTypes = [ START_NODE_TYPE ];
|
const requiredNodeTypes = [ START_NODE_TYPE ];
|
||||||
|
@ -1774,6 +1785,27 @@ export default mixins(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// connect nodes before/after deleted node
|
||||||
|
const nodeType: INodeTypeDescription = this.$store.getters.nodeType(node.type, node.typeVersion);
|
||||||
|
if (nodeType.outputs.length === 1
|
||||||
|
&& nodeType.inputs.length === 1) {
|
||||||
|
const {incoming, outgoing} = this.getIncomingOutgoingConnections(node.name);
|
||||||
|
if (incoming.length === 1 && outgoing.length === 1) {
|
||||||
|
const conn1 = incoming[0];
|
||||||
|
const conn2 = outgoing[0];
|
||||||
|
if (conn1.__meta && conn2.__meta) {
|
||||||
|
const sourceNodeName = conn1.__meta.sourceNodeName;
|
||||||
|
const sourceNodeOutputIndex = conn1.__meta.sourceOutputIndex;
|
||||||
|
const targetNodeName = conn2.__meta.targetNodeName;
|
||||||
|
const targetNodeOuputIndex = conn2.__meta.targetOutputIndex;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.connectTwoNodes(sourceNodeName, sourceNodeOutputIndex, targetNodeName, targetNodeOuputIndex);
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nodeIndex = this.$store.getters.getNodeIndex(nodeName);
|
const nodeIndex = this.$store.getters.getNodeIndex(nodeName);
|
||||||
const nodeIdName = `node-${nodeIndex}`;
|
const nodeIdName = `node-${nodeIndex}`;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue