mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
[groups] Include groups when converting selection to subflow
This commit is contained in:
parent
c9194c3635
commit
1bf3b3077e
@ -395,7 +395,9 @@ RED.history = (function() {
|
|||||||
if (ev.nodes) {
|
if (ev.nodes) {
|
||||||
inverseEv.movedNodes = [];
|
inverseEv.movedNodes = [];
|
||||||
var z = ev.activeWorkspace;
|
var z = ev.activeWorkspace;
|
||||||
RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) {
|
var fullNodeList = RED.nodes.filterNodes({z:ev.subflow.subflow.id});
|
||||||
|
fullNodeList = fullNodeList.concat(RED.nodes.groups(ev.subflow.subflow.id))
|
||||||
|
fullNodeList.forEach(function(n) {
|
||||||
n.x += ev.subflow.offsetX;
|
n.x += ev.subflow.offsetX;
|
||||||
n.y += ev.subflow.offsetY;
|
n.y += ev.subflow.offsetY;
|
||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
@ -447,6 +449,9 @@ RED.history = (function() {
|
|||||||
if (ev.movedNodes) {
|
if (ev.movedNodes) {
|
||||||
ev.movedNodes.forEach(function(nid) {
|
ev.movedNodes.forEach(function(nid) {
|
||||||
nn = RED.nodes.node(nid);
|
nn = RED.nodes.node(nid);
|
||||||
|
if (!nn) {
|
||||||
|
nn = RED.nodes.group(nid);
|
||||||
|
}
|
||||||
nn.x -= ev.subflow.offsetX;
|
nn.x -= ev.subflow.offsetX;
|
||||||
nn.y -= ev.subflow.offsetY;
|
nn.y -= ev.subflow.offsetY;
|
||||||
nn.dirty = true;
|
nn.dirty = true;
|
||||||
@ -554,6 +559,9 @@ RED.history = (function() {
|
|||||||
list: function() {
|
list: function() {
|
||||||
return undoHistory;
|
return undoHistory;
|
||||||
},
|
},
|
||||||
|
listRedo: function() {
|
||||||
|
return redoHistory;
|
||||||
|
},
|
||||||
depth: function() {
|
depth: function() {
|
||||||
return undoHistory.length;
|
return undoHistory.length;
|
||||||
},
|
},
|
||||||
|
@ -305,6 +305,10 @@ RED.nodes = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moveNodeToTab(node, z) {
|
function moveNodeToTab(node, z) {
|
||||||
|
if (node.type === "group") {
|
||||||
|
moveGroupToTab(node,z);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (nodeTabMap[node.z]) {
|
if (nodeTabMap[node.z]) {
|
||||||
delete nodeTabMap[node.z][node.id];
|
delete nodeTabMap[node.z][node.id];
|
||||||
}
|
}
|
||||||
@ -314,6 +318,13 @@ RED.nodes = (function() {
|
|||||||
nodeTabMap[z][node.id] = node;
|
nodeTabMap[z][node.id] = node;
|
||||||
node.z = z;
|
node.z = z;
|
||||||
}
|
}
|
||||||
|
function moveGroupToTab(group, z) {
|
||||||
|
var index = groupsByZ[group.z].indexOf(group);
|
||||||
|
groupsByZ[group.z].splice(index,1);
|
||||||
|
groupsByZ[z] = groupsByZ[z] || [];
|
||||||
|
groupsByZ[z].push(group);
|
||||||
|
group.z = z;
|
||||||
|
}
|
||||||
|
|
||||||
function removeLink(l) {
|
function removeLink(l) {
|
||||||
var index = links.indexOf(l);
|
var index = links.indexOf(l);
|
||||||
|
@ -567,6 +567,19 @@ RED.subflow = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var i,n;
|
var i,n;
|
||||||
|
var nodeList = new Set();
|
||||||
|
var tmplist = selection.nodes.slice();
|
||||||
|
while(tmplist.length > 0) {
|
||||||
|
n = tmplist.shift();
|
||||||
|
if (n.type === "group") {
|
||||||
|
tmplist = tmplist.concat(n.nodes);
|
||||||
|
}
|
||||||
|
nodeList.add(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeList = Array.from(nodeList);
|
||||||
|
|
||||||
|
|
||||||
var nodes = {};
|
var nodes = {};
|
||||||
var new_links = [];
|
var new_links = [];
|
||||||
var removedLinks = [];
|
var removedLinks = [];
|
||||||
@ -575,13 +588,13 @@ RED.subflow = (function() {
|
|||||||
var candidateOutputs = [];
|
var candidateOutputs = [];
|
||||||
var candidateInputNodes = {};
|
var candidateInputNodes = {};
|
||||||
|
|
||||||
var boundingBox = [selection.nodes[0].x,
|
var boundingBox = [nodeList[0].x,
|
||||||
selection.nodes[0].y,
|
nodeList[0].y,
|
||||||
selection.nodes[0].x,
|
nodeList[0].x,
|
||||||
selection.nodes[0].y];
|
nodeList[0].y];
|
||||||
|
|
||||||
for (i=0;i<selection.nodes.length;i++) {
|
for (i=0;i<nodeList.length;i++) {
|
||||||
n = selection.nodes[i];
|
n = nodeList[i];
|
||||||
nodes[n.id] = {n:n,outputs:{}};
|
nodes[n.id] = {n:n,outputs:{}};
|
||||||
boundingBox = [
|
boundingBox = [
|
||||||
Math.min(boundingBox[0],n.x),
|
Math.min(boundingBox[0],n.x),
|
||||||
@ -723,8 +736,8 @@ RED.subflow = (function() {
|
|||||||
RED.nodes.removeLink(removedLinks[i]);
|
RED.nodes.removeLink(removedLinks[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0;i<selection.nodes.length;i++) {
|
for (i=0;i<nodeList.length;i++) {
|
||||||
n = selection.nodes[i];
|
n = nodeList[i];
|
||||||
if (/^link /.test(n.type)) {
|
if (/^link /.test(n.type)) {
|
||||||
n.links = n.links.filter(function(id) {
|
n.links = n.links.filter(function(id) {
|
||||||
var isLocalLink = nodes.hasOwnProperty(id);
|
var isLocalLink = nodes.hasOwnProperty(id);
|
||||||
|
Loading…
Reference in New Issue
Block a user