mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
make entire node connectable
This commit is contained in:
parent
c10a546567
commit
e304f7c5b8
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="node-wrapper" :style="nodePosition">
|
<div class="node-wrapper" :style="nodePosition" v-on:mouseenter="onMouseEnter" v-on:mouseleave="onMouseLeave">
|
||||||
<div :class="{'selected': true, 'has-subtitles': !!nodeSubtitle}" v-show="isSelected"></div>
|
<div :class="{'selected': true, 'has-subtitles': !!nodeSubtitle}" v-show="isSelected"></div>
|
||||||
<div class="node-default" :ref="data.name" :style="nodeStyle" :class="nodeClass" @dblclick="setNodeActive" @click.left="mouseLeftClick" v-touch:start="touchStart" v-touch:end="touchEnd">
|
<div class="node-default" :ref="data.name" :style="nodeStyle" :class="nodeClass" @dblclick="setNodeActive" @click.left="mouseLeftClick" v-touch:start="touchStart" v-touch:end="touchEnd">
|
||||||
<div v-if="hasIssues" class="node-info-icon node-issues">
|
<div v-if="hasIssues" class="node-info-icon node-issues">
|
||||||
|
@ -248,6 +248,12 @@ export default mixins(externalHooks, nodeBase, nodeHelpers, workflowHelpers).ext
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onMouseEnter () {
|
||||||
|
this.$emit('mouseenter', this.data.name);
|
||||||
|
},
|
||||||
|
onMouseLeave () {
|
||||||
|
this.$emit('mouseleave', this.data.name);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
@runWorkflow="runWorkflow"
|
@runWorkflow="runWorkflow"
|
||||||
@moved="onNodeMoved"
|
@moved="onNodeMoved"
|
||||||
@run="onNodeRun"
|
@run="onNodeRun"
|
||||||
|
@mouseenter="onNodeEnter"
|
||||||
|
@mouseleave="onNodeLeave"
|
||||||
:id="'node-' + getNodeIndex(nodeData.name)"
|
:id="'node-' + getNodeIndex(nodeData.name)"
|
||||||
:key="getNodeIndex(nodeData.name)"
|
:key="getNodeIndex(nodeData.name)"
|
||||||
:name="nodeData.name"
|
:name="nodeData.name"
|
||||||
|
@ -310,6 +312,7 @@ export default mixins(
|
||||||
blankRedirect: false,
|
blankRedirect: false,
|
||||||
credentialsUpdated: false,
|
credentialsUpdated: false,
|
||||||
newNodeInsertPosition: null as null | XYPosition,
|
newNodeInsertPosition: null as null | XYPosition,
|
||||||
|
hoveringOverNodeName: null as null | string,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
|
@ -1268,15 +1271,23 @@ export default mixins(
|
||||||
|
|
||||||
let dropPrevented = false;
|
let dropPrevented = false;
|
||||||
|
|
||||||
this.instance.bind('connectionAborted', (info) => {
|
this.instance.bind('connectionAborted', (connection) => {
|
||||||
if (dropPrevented) {
|
if (dropPrevented) {
|
||||||
dropPrevented = false;
|
dropPrevented = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.hoveringOverNodeName) {
|
||||||
|
const sourceNodeName = this.$store.getters.getNodeNameByIndex(connection.sourceId.slice(NODE_NAME_PREFIX.length));
|
||||||
|
const outputIndex = connection.getParameters().index;
|
||||||
|
|
||||||
|
this.connectTwoNodes(sourceNodeName, outputIndex, this.hoveringOverNodeName, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
insertNodeAfterSelected({
|
insertNodeAfterSelected({
|
||||||
sourceId: info.sourceId,
|
sourceId: connection.sourceId,
|
||||||
index: info.getParameters().index,
|
index: connection.getParameters().index,
|
||||||
eventSource: 'node_connection_drop',
|
eventSource: 'node_connection_drop',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1455,11 +1466,19 @@ export default mixins(
|
||||||
}
|
}
|
||||||
|
|
||||||
const elements = document.querySelector('div.jtk-endpoint.dropHover');
|
const elements = document.querySelector('div.jtk-endpoint.dropHover');
|
||||||
if (elements && !droppable) {
|
if ((elements || this.hoveringOverNodeName) && !droppable) {
|
||||||
|
if (!elements && this.hoveringOverNodeName) {
|
||||||
|
const node = this.$store.getters.getNodeByName(this.hoveringOverNodeName);
|
||||||
|
const type: INodeTypeDescription = this.$store.getters.nodeType(node.type);
|
||||||
|
if (type.inputs.length !== 1) { // only attach to simple nodes with 1 input
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
droppable = true;
|
droppable = true;
|
||||||
CanvasHelpers.showDropConnectionState(connection);
|
CanvasHelpers.showDropConnectionState(connection);
|
||||||
}
|
}
|
||||||
else if (!elements && droppable) {
|
else if (!(elements || this.hoveringOverNodeName) && droppable) {
|
||||||
droppable = false;
|
droppable = false;
|
||||||
CanvasHelpers.showPullConnectionState(connection);
|
CanvasHelpers.showPullConnectionState(connection);
|
||||||
}
|
}
|
||||||
|
@ -1703,6 +1722,12 @@ export default mixins(
|
||||||
CanvasHelpers.showOrHideItemsLabel(connection);
|
CanvasHelpers.showOrHideItemsLabel(connection);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onNodeEnter (nodeName: string) {
|
||||||
|
this.hoveringOverNodeName = nodeName;
|
||||||
|
},
|
||||||
|
onNodeLeave () {
|
||||||
|
this.hoveringOverNodeName = null;
|
||||||
|
},
|
||||||
onNodeRun ({name, data}: {name: string, data: ITaskData[] | null}) {
|
onNodeRun ({name, data}: {name: string, data: ITaskData[] | null}) {
|
||||||
const sourceNodeName = name;
|
const sourceNodeName = name;
|
||||||
const sourceIndex = this.$store.getters.getNodeIndex(sourceNodeName);
|
const sourceIndex = this.$store.getters.getNodeIndex(sourceNodeName);
|
||||||
|
|
Loading…
Reference in a new issue