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

[groups] Include groups when copying whole tabs

This commit is contained in:
Nick O'Leary 2020-03-26 20:26:58 +00:00
parent 03e9522d98
commit e0bef941b4
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 6 additions and 16 deletions

View File

@ -372,6 +372,9 @@ RED.nodes = (function() {
} }
} }
removedGroups = groupsByZ[id] || []; removedGroups = groupsByZ[id] || [];
removedGroups.forEach(function(g) {
delete groups[g.id]
})
delete groupsByZ[id]; delete groupsByZ[id];
for (n=0;n<removedNodes.length;n++) { for (n=0;n<removedNodes.length;n++) {

View File

@ -2073,6 +2073,7 @@ if (DEBUG_EVENTS) { console.warn("clearSelection", mouse_mode); }
selection.forEach(function(n) { selection.forEach(function(n) {
if (n.type === 'tab') { if (n.type === 'tab') {
nodes.push(n); nodes.push(n);
nodes = nodes.concat(RED.nodes.groups(n.id));
nodes = nodes.concat(RED.nodes.filterNodes({z:n.id})); nodes = nodes.concat(RED.nodes.filterNodes({z:n.id}));
} }
}); });
@ -2880,7 +2881,6 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
} }
if (mouse_mode == RED.state.IMPORT_DRAGGING) { if (mouse_mode == RED.state.IMPORT_DRAGGING) {
RED.keyboard.remove("escape"); RED.keyboard.remove("escape");
console.log("Dragged a node into the group")
} else if (mouse_mode == RED.state.QUICK_JOINING) { } else if (mouse_mode == RED.state.QUICK_JOINING) {
d3.event.stopPropagation(); d3.event.stopPropagation();
return; return;
@ -4288,11 +4288,10 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
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() }).map(function(n) { return {n:n};});
new_ms = new_ms.concat(new_groups.map(function(g) { return {n:g}})) new_ms = new_ms.concat(new_groups.filter(function(g) { return g.z === RED.workspaces.active()}).map(function(g) { return {n:g}}))
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; });
// var new_gs = new_groups.filter(function(g) { console.log(g.id,g.x,g.y); return g.nodes.length === 0}).map(function(g) { return {n:g}})
// TODO: pick a more sensible root node // TODO: pick a more sensible root node
if (new_ms.length > 0 /* || new_gs.length > 0*/) { if (new_ms.length > 0) {
if (mouse_position == null) { if (mouse_position == null) {
@ -4344,18 +4343,6 @@ if (DEBUG_EVENTS) { console.warn("nodeMouseDown", mouse_mode,d); }
} }
} }
// for (i=0;i<new_gs.length;i++) {
// group = new_gs[i];
// group.n.selected = true;
// group.n.x -= dx - mouse_position[0];
// group.n.y -= dy - mouse_position[1];
// group.dx = group.n.x - mouse_position[0];
// group.dy = group.n.y - mouse_position[1];
// group.n.x -= minX;
// group.n.y -= minY;
// group.dx -= minX;
// group.dy -= minY;
// }
if (!touchImport) { if (!touchImport) {
mouse_mode = RED.state.IMPORT_DRAGGING; mouse_mode = RED.state.IMPORT_DRAGGING;
spliceActive = false; spliceActive = false;