mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Support select-all inside active group
This commit is contained in:
parent
d590bbdd2c
commit
a8e7627184
@ -74,7 +74,6 @@ RED.view = (function() {
|
|||||||
var mouse_position = null;
|
var mouse_position = null;
|
||||||
var mouse_mode = 0;
|
var mouse_mode = 0;
|
||||||
var mousedown_group_handle = null;
|
var mousedown_group_handle = null;
|
||||||
var moving_set = [];
|
|
||||||
var lasso = null;
|
var lasso = null;
|
||||||
var ghostNode = null;
|
var ghostNode = null;
|
||||||
var showStatus = false;
|
var showStatus = false;
|
||||||
@ -116,6 +115,49 @@ RED.view = (function() {
|
|||||||
var groupLayer;
|
var groupLayer;
|
||||||
var drag_lines;
|
var drag_lines;
|
||||||
|
|
||||||
|
var movingSet = (function() {
|
||||||
|
var setIds = new Set();
|
||||||
|
var set = [];
|
||||||
|
var api = {
|
||||||
|
add: function(node) {
|
||||||
|
if (Array.isArray(node)) {
|
||||||
|
for (var i=0;i<node.length;i++) {
|
||||||
|
api.add(node[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!setIds.has(node.id)) {
|
||||||
|
set.push({n:node});
|
||||||
|
setIds.add(node.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
remove: function(node, index) {
|
||||||
|
if (setIds.has(node.id)) {
|
||||||
|
setIds.delete(node.id);
|
||||||
|
if (index !== undefined && set[index].n === node) {
|
||||||
|
set.splice(index,1);
|
||||||
|
} else {
|
||||||
|
for (var i=0;i<set.length;i++) {
|
||||||
|
if (set[i].n === node) {
|
||||||
|
set.splice(i,1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clear: function() {
|
||||||
|
setIds.clear();
|
||||||
|
set = [];
|
||||||
|
},
|
||||||
|
length: function() { return set.length},
|
||||||
|
get: function(i) { return set[i] },
|
||||||
|
forEach: function(func) { set.forEach(func) },
|
||||||
|
nodes: function() { return set.map(function(n) { return n.n })}
|
||||||
|
}
|
||||||
|
return api;
|
||||||
|
})();
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
chart = $("#red-ui-workspace-chart");
|
chart = $("#red-ui-workspace-chart");
|
||||||
@ -433,7 +475,7 @@ RED.view = (function() {
|
|||||||
exitActiveGroup();
|
exitActiveGroup();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
nn.selected = true;
|
nn.selected = true;
|
||||||
moving_set.push({n:nn});
|
movingSet.add(nn);
|
||||||
if (group) {
|
if (group) {
|
||||||
selectGroup(group,false);
|
selectGroup(group,false);
|
||||||
enterActiveGroup(group);
|
enterActiveGroup(group);
|
||||||
@ -1113,7 +1155,7 @@ RED.view = (function() {
|
|||||||
selectGroup(targetGroup,false);
|
selectGroup(targetGroup,false);
|
||||||
enterActiveGroup(targetGroup);
|
enterActiveGroup(targetGroup);
|
||||||
}
|
}
|
||||||
moving_set.push({n:nn});
|
movingSet.add(nn);
|
||||||
updateActiveNodes();
|
updateActiveNodes();
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
@ -1314,8 +1356,8 @@ RED.view = (function() {
|
|||||||
mouse_mode = RED.state.MOVING_ACTIVE;
|
mouse_mode = RED.state.MOVING_ACTIVE;
|
||||||
clickElapsed = 0;
|
clickElapsed = 0;
|
||||||
spliceActive = false;
|
spliceActive = false;
|
||||||
if (moving_set.length === 1) {
|
if (movingSet.length() === 1) {
|
||||||
node = moving_set[0];
|
node = movingSet.get(0);
|
||||||
spliceActive = node.n.hasOwnProperty("_def") &&
|
spliceActive = node.n.hasOwnProperty("_def") &&
|
||||||
((node.n.hasOwnProperty("inputs") && node.n.inputs > 0) || (!node.n.hasOwnProperty("inputs") && node.n._def.inputs > 0)) &&
|
((node.n.hasOwnProperty("inputs") && node.n.inputs > 0) || (!node.n.hasOwnProperty("inputs") && node.n._def.inputs > 0)) &&
|
||||||
((node.n.hasOwnProperty("outputs") && node.n.outputs > 0) || (!node.n.hasOwnProperty("outputs") && node.n._def.outputs > 0)) &&
|
((node.n.hasOwnProperty("outputs") && node.n.outputs > 0) || (!node.n.hasOwnProperty("outputs") && node.n._def.outputs > 0)) &&
|
||||||
@ -1329,8 +1371,8 @@ RED.view = (function() {
|
|||||||
var minY = 0;
|
var minY = 0;
|
||||||
var maxX = space_width;
|
var maxX = space_width;
|
||||||
var maxY = space_height;
|
var maxY = space_height;
|
||||||
for (var n = 0; n<moving_set.length; n++) {
|
for (var n = 0; n<movingSet.length(); n++) {
|
||||||
node = moving_set[n];
|
node = movingSet.get(n);
|
||||||
if (d3.event.shiftKey) {
|
if (d3.event.shiftKey) {
|
||||||
node.n.ox = node.n.x;
|
node.n.ox = node.n.x;
|
||||||
node.n.oy = node.n.y;
|
node.n.oy = node.n.y;
|
||||||
@ -1339,7 +1381,9 @@ RED.view = (function() {
|
|||||||
node.n.y = mousePos[1]+node.dy;
|
node.n.y = mousePos[1]+node.dy;
|
||||||
node.n.dirty = true;
|
node.n.dirty = true;
|
||||||
if (node.n.type === "group") {
|
if (node.n.type === "group") {
|
||||||
node.n.groupMoved = true;
|
if (node.n.groupMoved !== false) {
|
||||||
|
node.n.groupMoved = true;
|
||||||
|
}
|
||||||
RED.group.markDirty(node.n);
|
RED.group.markDirty(node.n);
|
||||||
minX = Math.min(node.n.x-5,minX);
|
minX = Math.min(node.n.x-5,minX);
|
||||||
minY = Math.min(node.n.y-5,minY);
|
minY = Math.min(node.n.y-5,minY);
|
||||||
@ -1353,15 +1397,15 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (minX !== 0 || minY !== 0) {
|
if (minX !== 0 || minY !== 0) {
|
||||||
for (i = 0; i<moving_set.length; i++) {
|
for (i = 0; i<movingSet.length(); i++) {
|
||||||
node = moving_set[i];
|
node = movingSet.get(i);
|
||||||
node.n.x -= minX;
|
node.n.x -= minX;
|
||||||
node.n.y -= minY;
|
node.n.y -= minY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (maxX !== space_width || maxY !== space_height) {
|
if (maxX !== space_width || maxY !== space_height) {
|
||||||
for (i = 0; i<moving_set.length; i++) {
|
for (i = 0; i<movingSet.length(); i++) {
|
||||||
node = moving_set[i];
|
node = movingSet.get(i);
|
||||||
node.n.x -= (maxX - space_width);
|
node.n.x -= (maxX - space_width);
|
||||||
node.n.y -= (maxY - space_height);
|
node.n.y -= (maxY - space_height);
|
||||||
}
|
}
|
||||||
@ -1372,13 +1416,13 @@ RED.view = (function() {
|
|||||||
// mousedown_group.dirty = true;
|
// mousedown_group.dirty = true;
|
||||||
// }
|
// }
|
||||||
var gridOffset = [0,0];
|
var gridOffset = [0,0];
|
||||||
if (snapGrid != d3.event.shiftKey && moving_set.length > 0) {
|
if (snapGrid != d3.event.shiftKey && movingSet.length() > 0) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
|
|
||||||
// Prefer to snap nodes to the grid if there is one in the selection
|
// Prefer to snap nodes to the grid if there is one in the selection
|
||||||
do {
|
do {
|
||||||
node = moving_set[i++];
|
node = movingSet.get(i++);
|
||||||
} while(i<moving_set.length && node.n.type === "group")
|
} while(i<movingSet.length() && node.n.type === "group")
|
||||||
|
|
||||||
if (node.n.type === "group") {
|
if (node.n.type === "group") {
|
||||||
// TODO: Group snap to grid
|
// TODO: Group snap to grid
|
||||||
@ -1389,8 +1433,8 @@ RED.view = (function() {
|
|||||||
gridOffset[1] = node.n.y-(gridSize*Math.floor(node.n.y/gridSize));
|
gridOffset[1] = node.n.y-(gridSize*Math.floor(node.n.y/gridSize));
|
||||||
}
|
}
|
||||||
if (gridOffset[0] !== 0 || gridOffset[1] !== 0) {
|
if (gridOffset[0] !== 0 || gridOffset[1] !== 0) {
|
||||||
for (i = 0; i<moving_set.length; i++) {
|
for (i = 0; i<movingSet.length(); i++) {
|
||||||
node = moving_set[i];
|
node = movingSet.get(i);
|
||||||
node.n.x -= gridOffset[0];
|
node.n.x -= gridOffset[0];
|
||||||
node.n.y -= gridOffset[1];
|
node.n.y -= gridOffset[1];
|
||||||
if (node.n.x == node.n.ox && node.n.y == node.n.oy) {
|
if (node.n.x == node.n.ox && node.n.y == node.n.oy) {
|
||||||
@ -1401,8 +1445,8 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check link splice or group-add
|
// Check link splice or group-add
|
||||||
if (moving_set.length === 1 && moving_set[0].n.type !== "group") {
|
if (movingSet.length() === 1 && movingSet.get(0).n.type !== "group") {
|
||||||
node = moving_set[0];
|
node = movingSet.get(0);
|
||||||
if (spliceActive) {
|
if (spliceActive) {
|
||||||
if (!spliceTimer) {
|
if (!spliceTimer) {
|
||||||
spliceTimer = setTimeout(function() {
|
spliceTimer = setTimeout(function() {
|
||||||
@ -1544,7 +1588,7 @@ RED.view = (function() {
|
|||||||
} else {
|
} else {
|
||||||
n.selected = true;
|
n.selected = true;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1568,21 +1612,21 @@ RED.view = (function() {
|
|||||||
n.selected = (n.x > x && n.x < x2 && n.y > y && n.y < y2);
|
n.selected = (n.x > x && n.x < x2 && n.y > y && n.y < y2);
|
||||||
if (n.selected) {
|
if (n.selected) {
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
activeSubflow.out.forEach(function(n) {
|
activeSubflow.out.forEach(function(n) {
|
||||||
n.selected = (n.x > x && n.x < x2 && n.y > y && n.y < y2);
|
n.selected = (n.x > x && n.x < x2 && n.y > y && n.y < y2);
|
||||||
if (n.selected) {
|
if (n.selected) {
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (activeSubflow.status) {
|
if (activeSubflow.status) {
|
||||||
activeSubflow.status.selected = (activeSubflow.status.x > x && activeSubflow.status.x < x2 && activeSubflow.status.y > y && activeSubflow.status.y < y2);
|
activeSubflow.status.selected = (activeSubflow.status.x > x && activeSubflow.status.x < x2 && activeSubflow.status.y > y && activeSubflow.status.y < y2);
|
||||||
if (activeSubflow.status.selected) {
|
if (activeSubflow.status.selected) {
|
||||||
activeSubflow.status.dirty = true;
|
activeSubflow.status.dirty = true;
|
||||||
moving_set.push({n:activeSubflow.status});
|
movingSet.add(activeSubflow.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1594,11 +1638,11 @@ RED.view = (function() {
|
|||||||
updateSelection();
|
updateSelection();
|
||||||
}
|
}
|
||||||
if (mouse_mode == RED.state.MOVING_ACTIVE) {
|
if (mouse_mode == RED.state.MOVING_ACTIVE) {
|
||||||
if (moving_set.length > 0) {
|
if (movingSet.length() > 0) {
|
||||||
var addedToGroup = null;
|
var addedToGroup = null;
|
||||||
if (activeHoverGroup) {
|
if (activeHoverGroup) {
|
||||||
for (var j=0;j<moving_set.length;j++) {
|
for (var j=0;j<movingSet.length();j++) {
|
||||||
var n = moving_set[j];
|
var n = movingSet.get(j);
|
||||||
RED.group.addToGroup(activeHoverGroup,n.n);
|
RED.group.addToGroup(activeHoverGroup,n.n);
|
||||||
}
|
}
|
||||||
addedToGroup = activeHoverGroup;
|
addedToGroup = activeHoverGroup;
|
||||||
@ -1611,8 +1655,8 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ns = [];
|
var ns = [];
|
||||||
for (var j=0;j<moving_set.length;j++) {
|
for (var j=0;j<movingSet.length();j++) {
|
||||||
var n = moving_set[j];
|
var n = movingSet.get(j);
|
||||||
if (n.ox !== n.n.x || n.oy !== n.n.y) {
|
if (n.ox !== n.n.x || n.oy !== n.n.y) {
|
||||||
ns.push({n:n.n,ox:n.ox,oy:n.oy,moved:n.n.moved});
|
ns.push({n:n.n,ox:n.ox,oy:n.oy,moved:n.n.moved});
|
||||||
n.n.dirty = true;
|
n.n.dirty = true;
|
||||||
@ -1629,10 +1673,10 @@ RED.view = (function() {
|
|||||||
var link1 = {
|
var link1 = {
|
||||||
source:spliceLink.source,
|
source:spliceLink.source,
|
||||||
sourcePort:spliceLink.sourcePort,
|
sourcePort:spliceLink.sourcePort,
|
||||||
target: moving_set[0].n
|
target: movingSet.get(0).n
|
||||||
};
|
};
|
||||||
var link2 = {
|
var link2 = {
|
||||||
source:moving_set[0].n,
|
source:movingSet.get(0).n,
|
||||||
sourcePort:0,
|
sourcePort:0,
|
||||||
target: spliceLink.target
|
target: spliceLink.target
|
||||||
};
|
};
|
||||||
@ -1660,16 +1704,17 @@ RED.view = (function() {
|
|||||||
// RED.nodes.group(mousedown_node.g).selected = true;
|
// RED.nodes.group(mousedown_node.g).selected = true;
|
||||||
// mousedown_node.selected = true;
|
// mousedown_node.selected = true;
|
||||||
// mousedown_node.dirty = true;
|
// mousedown_node.dirty = true;
|
||||||
// moving_set.push({n:mousedown_node});
|
// movingSet.add(mousedown_node);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if (mouse_mode == RED.state.MOVING || mouse_mode == RED.state.MOVING_ACTIVE) {
|
if (mouse_mode == RED.state.MOVING || mouse_mode == RED.state.MOVING_ACTIVE) {
|
||||||
// if (mousedown_node) {
|
// if (mousedown_node) {
|
||||||
// delete mousedown_node.gSelected;
|
// delete mousedown_node.gSelected;
|
||||||
// }
|
// }
|
||||||
for (i=0;i<moving_set.length;i++) {
|
for (i=0;i<movingSet.length();i++) {
|
||||||
delete moving_set[i].ox;
|
var node = movingSet.get(i);
|
||||||
delete moving_set[i].oy;
|
delete node.ox;
|
||||||
|
delete node.oy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mouse_mode == RED.state.IMPORT_DRAGGING) {
|
if (mouse_mode == RED.state.IMPORT_DRAGGING) {
|
||||||
@ -1712,58 +1757,77 @@ RED.view = (function() {
|
|||||||
if (mouse_mode === RED.state.SELECTING_NODE && selectNodesOptions.single) {
|
if (mouse_mode === RED.state.SELECTING_NODE && selectNodesOptions.single) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearSelection();
|
|
||||||
exitActiveGroup();
|
if (activeGroup) {
|
||||||
activeGroups.forEach(function(g) {
|
var ag = activeGroup;
|
||||||
if (!g.g) {
|
clearSelection();
|
||||||
selectGroup(g, true);
|
enterActiveGroup(ag);
|
||||||
if (!g.selected) {
|
|
||||||
g.selected = true;
|
var groupNodes = RED.group.getNodes(ag,false);
|
||||||
|
groupNodes.forEach(function(n) {
|
||||||
|
if (n.type === 'group') {
|
||||||
|
selectGroup(n,true,true);
|
||||||
|
} else {
|
||||||
|
movingSet.add(n)
|
||||||
|
n.selected = true;
|
||||||
|
n.dirty = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
activeGroup.selected = true;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
clearSelection();
|
||||||
|
exitActiveGroup();
|
||||||
|
activeGroups.forEach(function(g) {
|
||||||
|
if (!g.g) {
|
||||||
|
selectGroup(g, true);
|
||||||
|
if (!g.selected) {
|
||||||
|
g.selected = true;
|
||||||
|
g.dirty = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g.selected = false;
|
||||||
g.dirty = true;
|
g.dirty = true;
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
g.selected = false;
|
|
||||||
g.dirty = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
activeNodes.forEach(function(n) {
|
activeNodes.forEach(function(n) {
|
||||||
if (mouse_mode === RED.state.SELECTING_NODE) {
|
if (mouse_mode === RED.state.SELECTING_NODE) {
|
||||||
if (selectNodesOptions.filter && !selectNodesOptions.filter(n)) {
|
if (selectNodesOptions.filter && !selectNodesOptions.filter(n)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!n.g && !n.selected) {
|
||||||
if (!n.g && !n.selected) {
|
|
||||||
n.selected = true;
|
|
||||||
n.dirty = true;
|
|
||||||
moving_set.push({n:n});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (mouse_mode !== RED.state.SELECTING_NODE && activeSubflow) {
|
|
||||||
activeSubflow.in.forEach(function(n) {
|
|
||||||
if (!n.selected) {
|
|
||||||
n.selected = true;
|
n.selected = true;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
activeSubflow.out.forEach(function(n) {
|
|
||||||
if (!n.selected) {
|
if (mouse_mode !== RED.state.SELECTING_NODE && activeSubflow) {
|
||||||
n.selected = true;
|
activeSubflow.in.forEach(function(n) {
|
||||||
n.dirty = true;
|
if (!n.selected) {
|
||||||
moving_set.push({n:n});
|
n.selected = true;
|
||||||
}
|
n.dirty = true;
|
||||||
});
|
movingSet.add(n);
|
||||||
if (activeSubflow.status) {
|
}
|
||||||
if (!activeSubflow.status.selected) {
|
});
|
||||||
activeSubflow.status.selected = true;
|
activeSubflow.out.forEach(function(n) {
|
||||||
activeSubflow.status.dirty = true;
|
if (!n.selected) {
|
||||||
moving_set.push({n:activeSubflow.status});
|
n.selected = true;
|
||||||
|
n.dirty = true;
|
||||||
|
movingSet.add(n);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (activeSubflow.status) {
|
||||||
|
if (!activeSubflow.status.selected) {
|
||||||
|
activeSubflow.status.selected = true;
|
||||||
|
activeSubflow.status.dirty = true;
|
||||||
|
movingSet.add(activeSubflow.status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selected_link = null;
|
selected_link = null;
|
||||||
if (mouse_mode !== RED.state.SELECTING_NODE) {
|
if (mouse_mode !== RED.state.SELECTING_NODE) {
|
||||||
updateSelection();
|
updateSelection();
|
||||||
@ -1772,13 +1836,13 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clearSelection() {
|
function clearSelection() {
|
||||||
if (RED.view.DEBUG) { console.warn("clearSelection", mouse_mode,"moving_set.length:",moving_set.length); }
|
if (RED.view.DEBUG) { console.warn("clearSelection", mouse_mode,"movingSet.length():",movingSet.length()); }
|
||||||
for (var i=0;i<moving_set.length;i++) {
|
for (var i=0;i<movingSet.length();i++) {
|
||||||
var n = moving_set[i];
|
var n = movingSet.get(i);
|
||||||
n.n.dirty = true;
|
n.n.dirty = true;
|
||||||
n.n.selected = false;
|
n.n.selected = false;
|
||||||
}
|
}
|
||||||
moving_set = [];
|
movingSet.clear();
|
||||||
selected_link = null;
|
selected_link = null;
|
||||||
if (activeGroup) {
|
if (activeGroup) {
|
||||||
activeGroup.active = false
|
activeGroup.active = false
|
||||||
@ -1812,9 +1876,10 @@ RED.view = (function() {
|
|||||||
activeLinkNodes[n].dirty = true;
|
activeLinkNodes[n].dirty = true;
|
||||||
})
|
})
|
||||||
activeLinkNodes = {};
|
activeLinkNodes = {};
|
||||||
for (var i=0;i<moving_set.length;i++) {
|
for (var i=0;i<movingSet.length();i++) {
|
||||||
if (moving_set[i].n.type === "link out" || moving_set[i].n.type === "link in") {
|
var msn = movingSet.get(i);
|
||||||
var linkNode = moving_set[i].n;
|
if (msn.n.type === "link out" || msn.n.type === "link in") {
|
||||||
|
var linkNode = msn.n;
|
||||||
activeLinkNodes[linkNode.id] = linkNode;
|
activeLinkNodes[linkNode.id] = linkNode;
|
||||||
var offFlowLinks = {};
|
var offFlowLinks = {};
|
||||||
linkNode.links.forEach(function(id) {
|
linkNode.links.forEach(function(id) {
|
||||||
@ -1896,8 +1961,8 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function editSelection() {
|
function editSelection() {
|
||||||
if (moving_set.length > 0) {
|
if (movingSet.length() > 0) {
|
||||||
var node = moving_set[0].n;
|
var node = movingSet.get(0).n;
|
||||||
if (node.type === "subflow") {
|
if (node.type === "subflow") {
|
||||||
RED.editor.editSubflow(activeSubflow);
|
RED.editor.editSubflow(activeSubflow);
|
||||||
} else if (node.type === "group") {
|
} else if (node.type === "group") {
|
||||||
@ -1955,7 +2020,7 @@ RED.view = (function() {
|
|||||||
updateActiveNodes();
|
updateActiveNodes();
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
} else if (moving_set.length > 0 || selected_link != null) {
|
} else if (movingSet.length() > 0 || selected_link != null) {
|
||||||
var result;
|
var result;
|
||||||
var node;
|
var node;
|
||||||
var removedNodes = [];
|
var removedNodes = [];
|
||||||
@ -1969,10 +2034,10 @@ RED.view = (function() {
|
|||||||
var startDirty = RED.nodes.dirty();
|
var startDirty = RED.nodes.dirty();
|
||||||
var startChanged = false;
|
var startChanged = false;
|
||||||
var selectedGroups = [];
|
var selectedGroups = [];
|
||||||
if (moving_set.length > 0) {
|
if (movingSet.length() > 0) {
|
||||||
|
|
||||||
for (var i=0;i<moving_set.length;i++) {
|
for (var i=0;i<movingSet.length();i++) {
|
||||||
node = moving_set[i].n;
|
node = movingSet.get(i).n;
|
||||||
if (node.type === "group") {
|
if (node.type === "group") {
|
||||||
selectedGroups.push(node);
|
selectedGroups.push(node);
|
||||||
}
|
}
|
||||||
@ -1985,8 +2050,8 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
for (var i=0;i<moving_set.length;i++) {
|
for (var i=0;i<movingSet.length();i++) {
|
||||||
node = moving_set[i].n;
|
node = movingSet.get(i).n;
|
||||||
node.selected = false;
|
node.selected = false;
|
||||||
if (node.type !== "group" && node.type !== "subflow") {
|
if (node.type !== "group" && node.type !== "subflow") {
|
||||||
if (node.x < 0) {
|
if (node.x < 0) {
|
||||||
@ -2049,7 +2114,7 @@ RED.view = (function() {
|
|||||||
if (instances) {
|
if (instances) {
|
||||||
subflowInstances = instances.instances;
|
subflowInstances = instances.instances;
|
||||||
}
|
}
|
||||||
moving_set = [];
|
movingSet.clear();
|
||||||
if (removedNodes.length > 0 || removedSubflowOutputs.length > 0 || removedSubflowInputs.length > 0 || removedSubflowStatus || removedGroups.length > 0) {
|
if (removedNodes.length > 0 || removedSubflowOutputs.length > 0 || removedSubflowInputs.length > 0 || removedSubflowStatus || removedGroups.length > 0) {
|
||||||
RED.nodes.dirty(true);
|
RED.nodes.dirty(true);
|
||||||
}
|
}
|
||||||
@ -2700,12 +2765,13 @@ RED.view = (function() {
|
|||||||
|
|
||||||
function prepareDrag(mouse) {
|
function prepareDrag(mouse) {
|
||||||
mouse_mode = RED.state.MOVING;
|
mouse_mode = RED.state.MOVING;
|
||||||
// Called when moving_set should be prepared to be dragged
|
// Called when movingSet should be prepared to be dragged
|
||||||
for (i=0;i<moving_set.length;i++) {
|
for (i=0;i<movingSet.length();i++) {
|
||||||
moving_set[i].ox = moving_set[i].n.x;
|
var msn = movingSet.get(i);
|
||||||
moving_set[i].oy = moving_set[i].n.y;
|
msn.ox = msn.n.x;
|
||||||
moving_set[i].dx = moving_set[i].n.x-mouse[0];
|
msn.oy = msn.n.y;
|
||||||
moving_set[i].dy = moving_set[i].n.y-mouse[1];
|
msn.dx = msn.n.x-mouse[0];
|
||||||
|
msn.dy = msn.n.y-mouse[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_offset = d3.mouse(document.body);
|
mouse_offset = d3.mouse(document.body);
|
||||||
@ -2740,7 +2806,7 @@ RED.view = (function() {
|
|||||||
enterActiveGroup(RED.nodes.group(d.g))
|
enterActiveGroup(RED.nodes.group(d.g))
|
||||||
|
|
||||||
mousedown_node.selected = true;
|
mousedown_node.selected = true;
|
||||||
moving_set.push({n:mousedown_node});
|
movingSet.add(mousedown_node);
|
||||||
var mouse = d3.touches(this)[0]||d3.mouse(this);
|
var mouse = d3.touches(this)[0]||d3.mouse(this);
|
||||||
mouse[0] += d.x-d.w/2;
|
mouse[0] += d.x-d.w/2;
|
||||||
mouse[1] += d.y-d.h/2;
|
mouse[1] += d.y-d.h/2;
|
||||||
@ -2797,10 +2863,10 @@ RED.view = (function() {
|
|||||||
var link1 = {
|
var link1 = {
|
||||||
source:spliceLink.source,
|
source:spliceLink.source,
|
||||||
sourcePort:spliceLink.sourcePort,
|
sourcePort:spliceLink.sourcePort,
|
||||||
target: moving_set[0].n
|
target: movingSet.get(0).n
|
||||||
};
|
};
|
||||||
var link2 = {
|
var link2 = {
|
||||||
source:moving_set[0].n,
|
source:movingSet.get(0).n,
|
||||||
sourcePort:0,
|
sourcePort:0,
|
||||||
target: spliceLink.target
|
target: spliceLink.target
|
||||||
};
|
};
|
||||||
@ -2829,16 +2895,11 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
if (d.selected) {
|
if (d.selected) {
|
||||||
d.selected = false;
|
d.selected = false;
|
||||||
for (i=0;i<moving_set.length;i+=1) {
|
movingSet.remove(d);
|
||||||
if (moving_set[i].n === d) {
|
|
||||||
moving_set.splice(i,1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!selectNodesOptions.filter || selectNodesOptions.filter(d)) {
|
if (!selectNodesOptions.filter || selectNodesOptions.filter(d)) {
|
||||||
d.selected = true;
|
d.selected = true;
|
||||||
moving_set.push({n:d});
|
movingSet.add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.dirty = true;
|
d.dirty = true;
|
||||||
@ -2878,15 +2939,34 @@ RED.view = (function() {
|
|||||||
selectGroup(nodeGroup,true);
|
selectGroup(nodeGroup,true);
|
||||||
}
|
}
|
||||||
} else if (nodeGroup === activeGroup ) {
|
} else if (nodeGroup === activeGroup ) {
|
||||||
// Clicked on a node in the active group
|
if (d3.event.shiftKey) {
|
||||||
if (!d3.event.ctrlKey && !d3.event.metaKey) {
|
if (!d3.event.ctrlKey && !d3.event.metaKey) {
|
||||||
// Ctrl not pressed so clear selection
|
var ag = activeGroup;
|
||||||
deselectGroup(nodeGroup);
|
clearSelection();
|
||||||
selectGroup(nodeGroup,false,false);
|
enterActiveGroup(ag);
|
||||||
|
activeGroup.selected = true;
|
||||||
|
}
|
||||||
|
var cnodes = RED.nodes.getAllFlowNodes(mousedown_node);
|
||||||
|
for (var n=0;n<cnodes.length;n++) {
|
||||||
|
if (!cnodes[n].selected) {
|
||||||
|
cnodes[n].selected = true;
|
||||||
|
cnodes[n].dirty = true;
|
||||||
|
movingSet.add(cnodes[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Clicked on a node in the active group
|
||||||
|
if (!d3.event.ctrlKey && !d3.event.metaKey) {
|
||||||
|
// Ctrl not pressed so clear selection
|
||||||
|
clearSelection();
|
||||||
|
deselectGroup(nodeGroup);
|
||||||
|
selectGroup(nodeGroup,false,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select this node
|
||||||
|
mousedown_node.selected = true;
|
||||||
|
movingSet.add(mousedown_node);
|
||||||
}
|
}
|
||||||
// Select this node
|
|
||||||
mousedown_node.selected = true;
|
|
||||||
moving_set.push({n:mousedown_node});
|
|
||||||
} else {
|
} else {
|
||||||
// Clicked on a node in a group
|
// Clicked on a node in a group
|
||||||
// - if this group is not selected, clear current selection
|
// - if this group is not selected, clear current selection
|
||||||
@ -2917,7 +2997,7 @@ RED.view = (function() {
|
|||||||
selectGroup(nodeGroup, !activeGroup, !!groupNodeSelectPrimed);
|
selectGroup(nodeGroup, !activeGroup, !!groupNodeSelectPrimed);
|
||||||
if (activeGroup) {
|
if (activeGroup) {
|
||||||
mousedown_node.selected = true;
|
mousedown_node.selected = true;
|
||||||
moving_set.push({n:mousedown_node});
|
movingSet.add(mousedown_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2930,12 +3010,7 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
} else if (d.selected && (d3.event.ctrlKey||d3.event.metaKey)) {
|
} else if (d.selected && (d3.event.ctrlKey||d3.event.metaKey)) {
|
||||||
mousedown_node.selected = false;
|
mousedown_node.selected = false;
|
||||||
for (i=0;i<moving_set.length;i+=1) {
|
movingSet.remove(mousedown_node);
|
||||||
if (moving_set[i].n === mousedown_node) {
|
|
||||||
moving_set.splice(i,1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// if (d.g && !RED.nodes.group(d.g).selected) {
|
// if (d.g && !RED.nodes.group(d.g).selected) {
|
||||||
@ -2958,7 +3033,7 @@ RED.view = (function() {
|
|||||||
for (var n=0;n<cnodes.length;n++) {
|
for (var n=0;n<cnodes.length;n++) {
|
||||||
cnodes[n].selected = true;
|
cnodes[n].selected = true;
|
||||||
cnodes[n].dirty = true;
|
cnodes[n].dirty = true;
|
||||||
moving_set.push({n:cnodes[n]});
|
movingSet.add(cnodes[n]);
|
||||||
}
|
}
|
||||||
} else if (!d.selected) {
|
} else if (!d.selected) {
|
||||||
if (!d3.event.ctrlKey && !d3.event.metaKey) {
|
if (!d3.event.ctrlKey && !d3.event.metaKey) {
|
||||||
@ -2967,7 +3042,7 @@ RED.view = (function() {
|
|||||||
exitActiveGroup();
|
exitActiveGroup();
|
||||||
}
|
}
|
||||||
mousedown_node.selected = true;
|
mousedown_node.selected = true;
|
||||||
moving_set.push({n:mousedown_node});
|
movingSet.add(mousedown_node);
|
||||||
}
|
}
|
||||||
selected_link = null;
|
selected_link = null;
|
||||||
if (d3.event.button != 2) {
|
if (d3.event.button != 2) {
|
||||||
@ -3219,14 +3294,14 @@ RED.view = (function() {
|
|||||||
g.dirty = true;
|
g.dirty = true;
|
||||||
}
|
}
|
||||||
if (addToMovingSet !== false) {
|
if (addToMovingSet !== false) {
|
||||||
moving_set.push({n:g});
|
movingSet.add(g);
|
||||||
}
|
}
|
||||||
if (includeNodes) {
|
if (includeNodes) {
|
||||||
var currentSet = new Set(moving_set.map(function(n) { return n.n }));
|
var currentSet = new Set(movingSet.nodes());
|
||||||
var allNodes = RED.group.getNodes(g,true);
|
var allNodes = RED.group.getNodes(g,true);
|
||||||
allNodes.forEach(function(n) {
|
allNodes.forEach(function(n) {
|
||||||
if (!currentSet.has(n)) {
|
if (!currentSet.has(n)) {
|
||||||
moving_set.push({n:n})
|
movingSet.add(n)
|
||||||
// n.selected = true;
|
// n.selected = true;
|
||||||
}
|
}
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
@ -3240,12 +3315,7 @@ RED.view = (function() {
|
|||||||
group.active = true;
|
group.active = true;
|
||||||
group.dirty = true;
|
group.dirty = true;
|
||||||
activeGroup = group;
|
activeGroup = group;
|
||||||
for (var i = moving_set.length-1; i >= 0; i -= 1) {
|
movingSet.remove(group);
|
||||||
if (moving_set[i].n === group) {
|
|
||||||
moving_set.splice(i,1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function exitActiveGroup() {
|
function exitActiveGroup() {
|
||||||
if (activeGroup) {
|
if (activeGroup) {
|
||||||
@ -3263,11 +3333,12 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
var nodeSet = new Set(g.nodes);
|
var nodeSet = new Set(g.nodes);
|
||||||
nodeSet.add(g);
|
nodeSet.add(g);
|
||||||
for (var i = moving_set.length-1; i >= 0; i -= 1) {
|
for (var i = movingSet.length()-1; i >= 0; i -= 1) {
|
||||||
if (nodeSet.has(moving_set[i].n) || moving_set[i].n === g) {
|
var msn = movingSet.get(i);
|
||||||
moving_set[i].n.selected = false;
|
if (nodeSet.has(msn.n) || msn.n === g) {
|
||||||
moving_set[i].n.dirty = true;
|
msn.n.selected = false;
|
||||||
moving_set.splice(i,1);
|
msn.n.dirty = true;
|
||||||
|
movingSet.remove(msn.n,i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3351,11 +3422,11 @@ RED.view = (function() {
|
|||||||
function showTouchMenu(obj,pos) {
|
function showTouchMenu(obj,pos) {
|
||||||
var mdn = mousedown_node;
|
var mdn = mousedown_node;
|
||||||
var options = [];
|
var options = [];
|
||||||
options.push({name:"delete",disabled:(moving_set.length===0 && selected_link === null),onselect:function() {deleteSelection();}});
|
options.push({name:"delete",disabled:(movingSet.length()===0 && selected_link === null),onselect:function() {deleteSelection();}});
|
||||||
options.push({name:"cut",disabled:(moving_set.length===0),onselect:function() {copySelection();deleteSelection();}});
|
options.push({name:"cut",disabled:(movingSet.length()===0),onselect:function() {copySelection();deleteSelection();}});
|
||||||
options.push({name:"copy",disabled:(moving_set.length===0),onselect:function() {copySelection();}});
|
options.push({name:"copy",disabled:(movingSet.length()===0),onselect:function() {copySelection();}});
|
||||||
options.push({name:"paste",disabled:(clipboard.length===0),onselect:function() {importNodes(clipboard,false,true);}});
|
options.push({name:"paste",disabled:(clipboard.length===0),onselect:function() {importNodes(clipboard,false,true);}});
|
||||||
options.push({name:"edit",disabled:(moving_set.length != 1),onselect:function() { RED.editor.edit(mdn);}});
|
options.push({name:"edit",disabled:(movingSet.length() != 1),onselect:function() { RED.editor.edit(mdn);}});
|
||||||
options.push({name:"select",onselect:function() {selectAll();}});
|
options.push({name:"select",onselect:function() {selectAll();}});
|
||||||
options.push({name:"undo",disabled:(RED.history.depth() === 0),onselect:function() {RED.history.pop();}});
|
options.push({name:"undo",disabled:(RED.history.depth() === 0),onselect:function() {RED.history.pop();}});
|
||||||
options.push({name:"add",onselect:function() {
|
options.push({name:"add",onselect:function() {
|
||||||
@ -4173,7 +4244,7 @@ RED.view = (function() {
|
|||||||
targets.forEach(function(n) {
|
targets.forEach(function(n) {
|
||||||
n.selected = true;
|
n.selected = true;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
});
|
});
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
@ -4340,6 +4411,13 @@ RED.view = (function() {
|
|||||||
d.y = minY;
|
d.y = minY;
|
||||||
d.w = maxX - minX;
|
d.w = maxX - minX;
|
||||||
d.h = maxY - minY;
|
d.h = maxY - minY;
|
||||||
|
// if set explicitly to false, this group has just been
|
||||||
|
// imported so needed this initial resize calculation.
|
||||||
|
// Now that's done, delete the flag so the normal
|
||||||
|
// logic kicks in.
|
||||||
|
if (d.groupMoved === false) {
|
||||||
|
delete d.groupMoved;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
delete d.groupMoved;
|
delete d.groupMoved;
|
||||||
}
|
}
|
||||||
@ -4388,12 +4466,12 @@ RED.view = (function() {
|
|||||||
var selectGroupRect = selectGroup.children[0];
|
var selectGroupRect = selectGroup.children[0];
|
||||||
selectGroupRect.setAttribute("width",d.w+8)
|
selectGroupRect.setAttribute("width",d.w+8)
|
||||||
selectGroupRect.setAttribute("height",d.h+8)
|
selectGroupRect.setAttribute("height",d.h+8)
|
||||||
selectGroupRect.style.strokeOpacity = (d.selected || d.highlighted)?0.8:0;
|
selectGroupRect.style.strokeOpacity = (d.active || d.selected || d.highlighted)?0.8:0;
|
||||||
selectGroupRect.style.strokeDasharray = (d.active)?"10 4":"";
|
selectGroupRect.style.strokeDasharray = (d.active)?"10 4":"";
|
||||||
selectGroupRect = selectGroup.children[1];
|
selectGroupRect = selectGroup.children[1];
|
||||||
selectGroupRect.setAttribute("width",d.w+8)
|
selectGroupRect.setAttribute("width",d.w+8)
|
||||||
selectGroupRect.setAttribute("height",d.h+8)
|
selectGroupRect.setAttribute("height",d.h+8)
|
||||||
selectGroupRect.style.strokeOpacity = (d.selected || d.highlighted)?0.8:0;
|
selectGroupRect.style.strokeOpacity = (d.active || d.selected || d.highlighted)?0.8:0;
|
||||||
selectGroupRect.style.strokeDasharray = (d.active)?"10 4":"";
|
selectGroupRect.style.strokeDasharray = (d.active)?"10 4":"";
|
||||||
|
|
||||||
if (d.highlighted) {
|
if (d.highlighted) {
|
||||||
@ -4517,21 +4595,25 @@ RED.view = (function() {
|
|||||||
if (addNewFlow && new_default_workspace) {
|
if (addNewFlow && new_default_workspace) {
|
||||||
RED.workspaces.show(new_default_workspace.id);
|
RED.workspaces.show(new_default_workspace.id);
|
||||||
}
|
}
|
||||||
var new_ms = new_nodes.filter(function(n) { return n.hasOwnProperty("x") && n.hasOwnProperty("y") && n.z == RED.workspaces.active() }).map(function(n) { return {n:n};});
|
var new_ms = new_nodes.filter(function(n) { return n.hasOwnProperty("x") && n.hasOwnProperty("y") && n.z == RED.workspaces.active() });
|
||||||
new_ms = new_ms.concat(new_groups.filter(function(g) { return g.z === RED.workspaces.active()}).map(function(g) { return {n:g}}))
|
new_ms = new_ms.concat(new_groups.filter(function(g) { return g.z === RED.workspaces.active()}))
|
||||||
var new_node_ids = new_nodes.map(function(n){ n.changed = true; return n.id; });
|
var new_node_ids = new_nodes.map(function(n){ n.changed = true; return n.id; });
|
||||||
|
|
||||||
|
clearSelection();
|
||||||
|
movingSet.clear();
|
||||||
|
movingSet.add(new_ms);
|
||||||
|
|
||||||
|
|
||||||
// TODO: pick a more sensible root node
|
// TODO: pick a more sensible root node
|
||||||
if (new_ms.length > 0) {
|
if (movingSet.length() > 0) {
|
||||||
|
|
||||||
|
|
||||||
if (mouse_position == null) {
|
if (mouse_position == null) {
|
||||||
mouse_position = [0,0];
|
mouse_position = [0,0];
|
||||||
}
|
}
|
||||||
|
|
||||||
var dx = mouse_position[0];
|
var dx = mouse_position[0];
|
||||||
var dy = mouse_position[1];
|
var dy = mouse_position[1];
|
||||||
if (new_ms.length > 0) {
|
if (movingSet.length() > 0) {
|
||||||
var root_node = new_ms[0].n;
|
var root_node = movingSet.get(0).n;
|
||||||
dx = root_node.x;
|
dx = root_node.x;
|
||||||
dy = root_node.y;
|
dy = root_node.y;
|
||||||
}
|
}
|
||||||
@ -4540,9 +4622,9 @@ RED.view = (function() {
|
|||||||
var minY = 0;
|
var minY = 0;
|
||||||
var i;
|
var i;
|
||||||
var node,group;
|
var node,group;
|
||||||
|
var l =movingSet.length();
|
||||||
for (i=0;i<new_ms.length;i++) {
|
for (i=0;i<l;i++) {
|
||||||
node = new_ms[i];
|
node = movingSet.get(i);
|
||||||
node.n.selected = true;
|
node.n.selected = true;
|
||||||
node.n.changed = true;
|
node.n.changed = true;
|
||||||
node.n.moved = true;
|
node.n.moved = true;
|
||||||
@ -4554,6 +4636,7 @@ RED.view = (function() {
|
|||||||
node.dx = node.n.x - mouse_position[0];
|
node.dx = node.n.x - mouse_position[0];
|
||||||
node.dy = node.n.y - mouse_position[1];
|
node.dy = node.n.y - mouse_position[1];
|
||||||
if (node.n.type === "group") {
|
if (node.n.type === "group") {
|
||||||
|
node.n.groupMoved = false;
|
||||||
minX = Math.min(node.n.x-5,minX);
|
minX = Math.min(node.n.x-5,minX);
|
||||||
minY = Math.min(node.n.y-5,minY);
|
minY = Math.min(node.n.y-5,minY);
|
||||||
} else {
|
} else {
|
||||||
@ -4561,8 +4644,8 @@ RED.view = (function() {
|
|||||||
minY = Math.min(node.n.y-node_height/2-5,minY);
|
minY = Math.min(node.n.y-node_height/2-5,minY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=0;i<new_ms.length;i++) {
|
for (i=0;i<l;i++) {
|
||||||
node = new_ms[i];
|
node = movingSet.get(i);
|
||||||
node.n.x -= minX;
|
node.n.x -= minX;
|
||||||
node.n.y -= minY;
|
node.n.y -= minY;
|
||||||
node.dx -= minX;
|
node.dx -= minX;
|
||||||
@ -4579,8 +4662,8 @@ RED.view = (function() {
|
|||||||
if (!touchImport) {
|
if (!touchImport) {
|
||||||
mouse_mode = RED.state.IMPORT_DRAGGING;
|
mouse_mode = RED.state.IMPORT_DRAGGING;
|
||||||
spliceActive = false;
|
spliceActive = false;
|
||||||
if (new_ms.length === 1) {
|
if (movingSet.length() === 1) {
|
||||||
node = new_ms[0];
|
node = movingSet.get(0);
|
||||||
spliceActive = node.n.hasOwnProperty("_def") &&
|
spliceActive = node.n.hasOwnProperty("_def") &&
|
||||||
((node.n.hasOwnProperty("inputs") && node.n.inputs > 0) || (!node.n.hasOwnProperty("inputs") && node.n._def.inputs > 0)) &&
|
((node.n.hasOwnProperty("inputs") && node.n.inputs > 0) || (!node.n.hasOwnProperty("inputs") && node.n._def.inputs > 0)) &&
|
||||||
((node.n.hasOwnProperty("outputs") && node.n.outputs > 0) || (!node.n.hasOwnProperty("outputs") && node.n._def.outputs > 0))
|
((node.n.hasOwnProperty("outputs") && node.n.outputs > 0) || (!node.n.hasOwnProperty("outputs") && node.n._def.outputs > 0))
|
||||||
@ -4594,8 +4677,6 @@ RED.view = (function() {
|
|||||||
RED.history.pop();
|
RED.history.pop();
|
||||||
mouse_mode = 0;
|
mouse_mode = 0;
|
||||||
});
|
});
|
||||||
clearSelection();
|
|
||||||
moving_set = new_ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var historyEvent = {
|
var historyEvent = {
|
||||||
@ -4607,7 +4688,7 @@ RED.view = (function() {
|
|||||||
subflows:new_subflows,
|
subflows:new_subflows,
|
||||||
dirty:RED.nodes.dirty()
|
dirty:RED.nodes.dirty()
|
||||||
};
|
};
|
||||||
if (new_ms.length === 0) {
|
if (movingSet.length() === 0) {
|
||||||
RED.nodes.dirty(true);
|
RED.nodes.dirty(true);
|
||||||
}
|
}
|
||||||
if (activeSubflow) {
|
if (activeSubflow) {
|
||||||
@ -4692,10 +4773,10 @@ RED.view = (function() {
|
|||||||
var changed = false;
|
var changed = false;
|
||||||
if (workspaceSelection.length > 0) {
|
if (workspaceSelection.length > 0) {
|
||||||
// TODO: toggle workspace state
|
// TODO: toggle workspace state
|
||||||
} else if (moving_set.length > 0) {
|
} else if (movingSet.length() > 0) {
|
||||||
var historyEvents = [];
|
var historyEvents = [];
|
||||||
for (var i=0;i<moving_set.length;i++) {
|
for (var i=0;i<movingSet.length();i++) {
|
||||||
var node = moving_set[i].n;
|
var node = movingSet.get(i).n;
|
||||||
if (node.type !== "group" && node.type !== "subflow") {
|
if (node.type !== "group" && node.type !== "subflow") {
|
||||||
if (isDisabled != node.d) {
|
if (isDisabled != node.d) {
|
||||||
historyEvents.push({
|
historyEvents.push({
|
||||||
@ -4734,8 +4815,8 @@ RED.view = (function() {
|
|||||||
|
|
||||||
var allNodes = new Set();
|
var allNodes = new Set();
|
||||||
|
|
||||||
if (moving_set.length > 0) {
|
if (movingSet.length() > 0) {
|
||||||
moving_set.forEach(function(n) {
|
movingSet.forEach(function(n) {
|
||||||
if (n.n.type !== 'group') {
|
if (n.n.type !== 'group') {
|
||||||
allNodes.add(n.n);
|
allNodes.add(n.n);
|
||||||
}
|
}
|
||||||
@ -4796,12 +4877,13 @@ RED.view = (function() {
|
|||||||
if (selectedNode) {
|
if (selectedNode) {
|
||||||
selectedNode.selected = true;
|
selectedNode.selected = true;
|
||||||
selectedNode.dirty = true;
|
selectedNode.dirty = true;
|
||||||
moving_set = [{n:selectedNode}];
|
movingSet.clear();
|
||||||
|
movingSet.add(selectedNode);
|
||||||
}
|
}
|
||||||
} else if (selection) {
|
} else if (selection) {
|
||||||
if (selection.nodes) {
|
if (selection.nodes) {
|
||||||
updateActiveNodes();
|
updateActiveNodes();
|
||||||
moving_set = [];
|
movingSet.clear();
|
||||||
// TODO: this selection group span groups
|
// TODO: this selection group span groups
|
||||||
// - if all in one group -> activate the group
|
// - if all in one group -> activate the group
|
||||||
// - if in multiple groups (or group/no-group)
|
// - if in multiple groups (or group/no-group)
|
||||||
@ -4810,7 +4892,7 @@ RED.view = (function() {
|
|||||||
if (n.type !== "group") {
|
if (n.type !== "group") {
|
||||||
n.selected = true;
|
n.selected = true;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
} else {
|
} else {
|
||||||
selectGroup(n,true);
|
selectGroup(n,true);
|
||||||
}
|
}
|
||||||
@ -4917,7 +4999,7 @@ RED.view = (function() {
|
|||||||
if (n) {
|
if (n) {
|
||||||
n.selected = true;
|
n.selected = true;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
moving_set.push({n:n});
|
movingSet.add(n);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -4953,7 +5035,7 @@ RED.view = (function() {
|
|||||||
text: RED._("common.label.done"),
|
text: RED._("common.label.done"),
|
||||||
class: "primary",
|
class: "primary",
|
||||||
click: function(e) {
|
click: function(e) {
|
||||||
var selection = moving_set.map(function(n) { return n.n;});
|
var selection = movingSet.nodes()
|
||||||
selectNodesOptions.done(selection);
|
selectNodesOptions.done(selection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user