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

Enable shift-drag detach of just the selected link

This commit is contained in:
Nick O'Leary 2016-05-31 23:42:00 +01:00
parent 0afe98b399
commit 4e762e2063

View File

@ -539,18 +539,31 @@ RED.view = (function() {
if (d3.event.shiftKey) { if (d3.event.shiftKey) {
// Get all the wires we need to detach. // Get all the wires we need to detach.
var links = []; var links = [];
var filter; var existingLinks = [];
if (mousedown_port_type === 0) { if (selected_link &&
filter = { ((mousedown_port_type === 0 &&
source:mousedown_node, selected_link.source === mousedown_node &&
sourcePort: mousedown_port_index selected_link.sourcePort === mousedown_port_index
} ) ||
(mousedown_port_type === 1 &&
selected_link.target === mousedown_node
))
) {
existingLinks = [selected_link];
} else { } else {
filter = { var filter;
target: mousedown_node if (mousedown_port_type === 0) {
filter = {
source:mousedown_node,
sourcePort: mousedown_port_index
}
} else {
filter = {
target: mousedown_node
}
} }
existingLinks = RED.nodes.filterLinks(filter);
} }
var existingLinks = RED.nodes.filterLinks(filter);
for (i=0;i<existingLinks.length;i++) { for (i=0;i<existingLinks.length;i++) {
var link = existingLinks[i]; var link = existingLinks[i];
RED.nodes.removeLink(link); RED.nodes.removeLink(link);
@ -569,6 +582,7 @@ RED.view = (function() {
} else { } else {
showDragLines([{node:mousedown_node,port:mousedown_port_index,portType:mousedown_port_type}]); showDragLines([{node:mousedown_node,port:mousedown_port_index,portType:mousedown_port_type}]);
} }
selected_link = null;
} }
mousePos = mouse_position; mousePos = mouse_position;
for (i=0;i<drag_lines.length;i++) { for (i=0;i<drag_lines.length;i++) {
@ -1137,7 +1151,6 @@ RED.view = (function() {
// disable zoom // disable zoom
//vis.call(d3.behavior.zoom().on("zoom"), null); //vis.call(d3.behavior.zoom().on("zoom"), null);
mousedown_node = d; mousedown_node = d;
selected_link = null;
mouse_mode = RED.state.JOINING; mouse_mode = RED.state.JOINING;
mousedown_port_type = portType; mousedown_port_type = portType;
mousedown_port_index = portIndex || 0; mousedown_port_index = portIndex || 0;