Add undo support for config-node delete

This commit is contained in:
Nick O'Leary
2015-09-25 21:49:53 +01:00
parent f2b73187d8
commit a9a0b263dc
2 changed files with 29 additions and 3 deletions

View File

@@ -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);
}
});
}