mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #4043 from node-red-hitachi/fix-group-undo-position
fix group position after undo
This commit is contained in:
commit
adfc5b3e98
@ -586,11 +586,28 @@ RED.view = (function() {
|
||||
|
||||
var group = $(ui.helper).data("group");
|
||||
if (group) {
|
||||
var oldX = group.x;
|
||||
var oldY = group.y;
|
||||
RED.group.addToGroup(group, nn);
|
||||
var moveEvent = null;
|
||||
if ((group.x !== oldX) ||
|
||||
(group.y !== oldY)) {
|
||||
moveEvent = {
|
||||
t: "move",
|
||||
nodes: [{n: group,
|
||||
ox: oldX, oy: oldY,
|
||||
dx: group.x -oldX,
|
||||
dy: group.y -oldY}],
|
||||
dirty: true
|
||||
};
|
||||
}
|
||||
historyEvent = {
|
||||
t: 'multi',
|
||||
events: [historyEvent],
|
||||
|
||||
};
|
||||
if (moveEvent) {
|
||||
historyEvent.events.push(moveEvent)
|
||||
}
|
||||
historyEvent.events.push({
|
||||
t: "addToGroup",
|
||||
@ -1350,19 +1367,35 @@ RED.view = (function() {
|
||||
RED.editor.validateNode(nn);
|
||||
|
||||
if (targetGroup) {
|
||||
var oldX = targetGroup.x;
|
||||
var oldY = targetGroup.y;
|
||||
RED.group.addToGroup(targetGroup, nn);
|
||||
var moveEvent = null;
|
||||
if ((targetGroup.x !== oldX) ||
|
||||
(targetGroup.y !== oldY)) {
|
||||
moveEvent = {
|
||||
t: "move",
|
||||
nodes: [{n: targetGroup,
|
||||
ox: oldX, oy: oldY,
|
||||
dx: targetGroup.x -oldX,
|
||||
dy: targetGroup.y -oldY}],
|
||||
dirty: true
|
||||
};
|
||||
}
|
||||
if (historyEvent.t !== "multi") {
|
||||
historyEvent = {
|
||||
t:'multi',
|
||||
events: [historyEvent]
|
||||
}
|
||||
};
|
||||
}
|
||||
historyEvent.events.push({
|
||||
t: "addToGroup",
|
||||
group: targetGroup,
|
||||
nodes: nn
|
||||
})
|
||||
|
||||
});
|
||||
if (moveEvent) {
|
||||
historyEvent.events.push(moveEvent);
|
||||
}
|
||||
}
|
||||
|
||||
if (spliceLink) {
|
||||
@ -1698,6 +1731,7 @@ RED.view = (function() {
|
||||
|
||||
// Check link splice or group-add
|
||||
if (movingSet.length() === 1 && movingSet.get(0).n.type !== "group") {
|
||||
//}{//NIS
|
||||
node = movingSet.get(0);
|
||||
if (spliceActive) {
|
||||
if (!spliceTimer) {
|
||||
@ -2057,11 +2091,25 @@ RED.view = (function() {
|
||||
if (mouse_mode == RED.state.MOVING_ACTIVE) {
|
||||
if (movingSet.length() > 0) {
|
||||
var addedToGroup = null;
|
||||
var moveEvent = null;
|
||||
if (activeHoverGroup) {
|
||||
var oldX = activeHoverGroup.x;
|
||||
var oldY = activeHoverGroup.y;
|
||||
for (var j=0;j<movingSet.length();j++) {
|
||||
var n = movingSet.get(j);
|
||||
RED.group.addToGroup(activeHoverGroup,n.n);
|
||||
}
|
||||
if ((activeHoverGroup.x !== oldX) ||
|
||||
(activeHoverGroup.y !== oldY)) {
|
||||
moveEvent = {
|
||||
t: "move",
|
||||
nodes: [{n: activeHoverGroup,
|
||||
ox: oldX, oy: oldY,
|
||||
dx: activeHoverGroup.x -oldX,
|
||||
dy: activeHoverGroup.y -oldY}],
|
||||
dirty: true
|
||||
};
|
||||
}
|
||||
addedToGroup = activeHoverGroup;
|
||||
|
||||
activeHoverGroup.hovered = false;
|
||||
@ -2107,6 +2155,12 @@ RED.view = (function() {
|
||||
historyEvent.addToGroup = addedToGroup;
|
||||
}
|
||||
RED.nodes.dirty(true);
|
||||
if (moveEvent) {
|
||||
historyEvent = {
|
||||
t: "multi",
|
||||
events: [moveEvent, historyEvent]
|
||||
};
|
||||
}
|
||||
RED.history.push(historyEvent);
|
||||
}
|
||||
}
|
||||
@ -3466,11 +3520,25 @@ RED.view = (function() {
|
||||
updateActiveNodes();
|
||||
}
|
||||
|
||||
var moveEvent = null;
|
||||
if (activeHoverGroup) {
|
||||
var oldX = activeHoverGroup.x;
|
||||
var oldY = activeHoverGroup.y;
|
||||
for (var j=0;j<movingSet.length();j++) {
|
||||
var n = movingSet.get(j);
|
||||
RED.group.addToGroup(activeHoverGroup,n.n);
|
||||
}
|
||||
if ((activeHoverGroup.x !== oldX) ||
|
||||
(activeHoverGroup.y !== oldY)) {
|
||||
moveEvent = {
|
||||
t: "move",
|
||||
nodes: [{n: activeHoverGroup,
|
||||
ox: oldX, oy: oldY,
|
||||
dx: activeHoverGroup.x -oldX,
|
||||
dy: activeHoverGroup.y -oldY}],
|
||||
dirty: true
|
||||
};
|
||||
}
|
||||
historyEvent.addedToGroup = activeHoverGroup;
|
||||
|
||||
activeHoverGroup.hovered = false;
|
||||
@ -3479,7 +3547,6 @@ RED.view = (function() {
|
||||
activeGroup.selected = true;
|
||||
activeHoverGroup = null;
|
||||
}
|
||||
|
||||
if (mouse_mode == RED.state.DETACHED_DRAGGING) {
|
||||
var ns = [];
|
||||
for (var j=0;j<movingSet.length();j++) {
|
||||
@ -3490,7 +3557,15 @@ RED.view = (function() {
|
||||
n.n.moved = true;
|
||||
}
|
||||
}
|
||||
RED.history.replace({t:"multi",events:[historyEvent,{t:"move",nodes:ns}],dirty: historyEvent.dirty})
|
||||
var event = {t:"multi",events:[historyEvent,{t:"move",nodes:ns}],dirty: historyEvent.dirty};
|
||||
if (moveEvent) {
|
||||
event.events.push(moveEvent);
|
||||
}
|
||||
RED.history.replace(event)
|
||||
}
|
||||
else if(moveEvent) {
|
||||
var event = {t:"multi", events:[historyEvent, moveEvent], dirty: true};
|
||||
RED.history.replace(event);
|
||||
}
|
||||
|
||||
updateSelection();
|
||||
|
Loading…
Reference in New Issue
Block a user