mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add undo support for config-node delete
This commit is contained in:
parent
f2b73187d8
commit
a9a0b263dc
@ -145,6 +145,20 @@ RED.history = (function() {
|
||||
RED.nodes.addLink(ev.links[i]);
|
||||
}
|
||||
}
|
||||
if (ev.changes) {
|
||||
for (i in ev.changes) {
|
||||
if (ev.changes.hasOwnProperty(i)) {
|
||||
node = RED.nodes.node(i);
|
||||
for (var d in ev.changes[i]) {
|
||||
if (ev.changes[i].hasOwnProperty(d)) {
|
||||
node[d] = ev.changes[i][d];
|
||||
}
|
||||
}
|
||||
node.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (ev.t == "move") {
|
||||
for (i=0;i<ev.nodes.length;i++) {
|
||||
var n = ev.nodes[i];
|
||||
@ -191,9 +205,6 @@ RED.history = (function() {
|
||||
if (ev.node.type === 'subflow') {
|
||||
$("#menu-item-flow-menu-"+ev.node.id.replace(".","-")).text(ev.node.name);
|
||||
}
|
||||
|
||||
RED.palette.refresh();
|
||||
RED.workspaces.refresh();
|
||||
} else {
|
||||
RED.editor.updateNodeProperties(ev.node);
|
||||
RED.editor.validateNode(ev.node);
|
||||
@ -240,6 +251,7 @@ RED.history = (function() {
|
||||
RED.nodes.dirty(ev.dirty);
|
||||
RED.view.redraw(true);
|
||||
RED.palette.refresh();
|
||||
RED.workspaces.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -735,12 +735,25 @@ RED.editor = (function() {
|
||||
if (configTypeDef.oneditdelete) {
|
||||
configTypeDef.oneditdelete.call(RED.nodes.node(configId));
|
||||
}
|
||||
var historyEvent = {
|
||||
t:'delete',
|
||||
nodes:[configNode],
|
||||
changes: {},
|
||||
dirty: RED.nodes.dirty()
|
||||
}
|
||||
RED.nodes.remove(configId);
|
||||
for (var i=0;i<configNode.users.length;i++) {
|
||||
var user = configNode.users[i];
|
||||
historyEvent.changes[user.id] = {
|
||||
changed: user.changed,
|
||||
valid: user.valid
|
||||
};
|
||||
for (var d in user._def.defaults) {
|
||||
if (user._def.defaults.hasOwnProperty(d) && user[d] == configId) {
|
||||
historyEvent.changes[user.id][d] = configId
|
||||
user[d] = "";
|
||||
user.changed = true;
|
||||
user.dirty = true;
|
||||
}
|
||||
}
|
||||
validateNode(user);
|
||||
@ -749,6 +762,7 @@ RED.editor = (function() {
|
||||
RED.nodes.dirty(true);
|
||||
$( this ).dialog( "close" );
|
||||
RED.view.redraw();
|
||||
RED.history.push(historyEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user