1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Select links when nodes on either side selected

This commit is contained in:
Nick O'Leary 2022-01-03 23:29:12 +00:00
parent 24b52f09df
commit bef641609e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -128,6 +128,14 @@ RED.view = (function() {
if (!setIds.has(node.id)) { if (!setIds.has(node.id)) {
set.push({n:node}); set.push({n:node});
setIds.add(node.id); setIds.add(node.id);
var links = RED.nodes.getNodeLinks(node.id,PORT_TYPE_INPUT).concat(RED.nodes.getNodeLinks(node.id,PORT_TYPE_OUTPUT))
for (var i=0,l=links.length;i<l;i++) {
var link = links[i]
if (link.source === node && setIds.has(link.target.id) ||
link.target === node && setIds.has(link.source.id)) {
selectedLinks.add(link)
}
}
} }
} }
}, },
@ -144,6 +152,10 @@ RED.view = (function() {
} }
} }
} }
var links = RED.nodes.getNodeLinks(node.id,PORT_TYPE_INPUT).concat(RED.nodes.getNodeLinks(node.id,PORT_TYPE_OUTPUT))
for (var i=0,l=links.length;i<l;i++) {
selectedLinks.remove(links[i]);
}
} }
}, },
clear: function() { clear: function() {
@ -1896,6 +1908,7 @@ RED.view = (function() {
if (mouse_mode === RED.state.SELECTING_NODE && selectNodesOptions.single) { if (mouse_mode === RED.state.SELECTING_NODE && selectNodesOptions.single) {
return; return;
} }
selectedLinks.clear();
if (activeGroup) { if (activeGroup) {
var ag = activeGroup; var ag = activeGroup;
@ -1967,7 +1980,6 @@ RED.view = (function() {
} }
} }
} }
selectedLinks.clear();
if (mouse_mode !== RED.state.SELECTING_NODE) { if (mouse_mode !== RED.state.SELECTING_NODE) {
updateSelection(); updateSelection();
} }
@ -3262,7 +3274,7 @@ RED.view = (function() {
mousedown_node.selected = true; mousedown_node.selected = true;
movingSet.add(mousedown_node); movingSet.add(mousedown_node);
} }
selectedLinks.clear(); // selectedLinks.clear();
if (d3.event.button != 2) { if (d3.event.button != 2) {
mouse_mode = RED.state.MOVING; mouse_mode = RED.state.MOVING;
var mouse = d3.touches(this)[0]||d3.mouse(this); var mouse = d3.touches(this)[0]||d3.mouse(this);
@ -3390,7 +3402,7 @@ RED.view = (function() {
} }
mousedown_link = d; mousedown_link = d;
if (selectedLinks.length() === 0 || !(d3.event.metaKey || d3.event.ctrlKey)) { if (!(d3.event.metaKey || d3.event.ctrlKey)) {
clearSelection(); clearSelection();
} }
if (d3.event.metaKey || d3.event.ctrlKey) { if (d3.event.metaKey || d3.event.ctrlKey) {
@ -3408,7 +3420,7 @@ RED.view = (function() {
redraw(); redraw();
focusView(); focusView();
d3.event.stopPropagation(); d3.event.stopPropagation();
if (!mousedown_link.link && selectedLinks.length() === 1 && selectedLinks.has(mousedown_link) && (d3.event.metaKey || d3.event.ctrlKey)) { if (!mousedown_link.link && movingSet.length() === 0 && selectedLinks.length() === 1 && selectedLinks.has(mousedown_link) && (d3.event.metaKey || d3.event.ctrlKey)) {
d3.select(this).classed("red-ui-flow-link-splice",true); d3.select(this).classed("red-ui-flow-link-splice",true);
var point = d3.mouse(this); var point = d3.mouse(this);
var clickedGroup = getGroupAt(point[0],point[1]); var clickedGroup = getGroupAt(point[0],point[1]);