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

Merge pull request #2245 from node-red-hitachi/fix-conv-subflow

Fix error on converting selection to subflow
This commit is contained in:
Nick O'Leary 2019-07-30 23:03:30 +01:00 committed by GitHub
commit 96255e51d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -276,11 +276,13 @@ RED.history = (function() {
ev.node.changed = ev.changed; ev.node.changed = ev.changed;
} else if (ev.t == "createSubflow") { } else if (ev.t == "createSubflow") {
if (ev.nodes) { if (ev.nodes) {
var z = ev.activeWorkspace;
RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) { RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) {
n.x += ev.subflow.offsetX; n.x += ev.subflow.offsetX;
n.y += ev.subflow.offsetY; n.y += ev.subflow.offsetY;
n.z = ev.activeWorkspace; n.z = ev.activeWorkspace;
n.dirty = true; n.dirty = true;
RED.nodes.moveNodeToTab(n, z);
}); });
for (i=0;i<ev.nodes.length;i++) { for (i=0;i<ev.nodes.length;i++) {
RED.nodes.remove(ev.nodes[i]); RED.nodes.remove(ev.nodes[i]);

View File

@ -301,6 +301,17 @@ RED.nodes = (function() {
return {links:removedLinks,nodes:removedNodes}; return {links:removedLinks,nodes:removedNodes};
} }
function moveNodeToTab(node, z) {
if (nodeTabMap[node.z]) {
delete nodeTabMap[node.z][node.id];
}
if (!nodeTabMap[z]) {
nodeTabMap[z] = {};
}
nodeTabMap[z][node.id] = node;
node.z = z;
}
function removeLink(l) { function removeLink(l) {
var index = links.indexOf(l); var index = links.indexOf(l);
if (index != -1) { if (index != -1) {
@ -1466,6 +1477,8 @@ RED.nodes = (function() {
remove: removeNode, remove: removeNode,
clear: clear, clear: clear,
moveNodeToTab: moveNodeToTab,
addLink: addLink, addLink: addLink,
removeLink: removeLink, removeLink: removeLink,

View File

@ -723,7 +723,7 @@ RED.subflow = (function() {
} }
n.x -= offsetX; n.x -= offsetX;
n.y -= offsetY; n.y -= offsetY;
n.z = subflow.id; RED.nodes.moveNodeToTab(n, subflow.id);
} }
RED.history.push({ RED.history.push({