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