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

Update config node user list when node edits are undone

This commit is contained in:
Nick O'Leary 2015-09-28 10:15:47 +01:00
parent ecde942255
commit a2297f303d

View File

@ -149,12 +149,14 @@ RED.history = (function() {
for (i in ev.changes) { for (i in ev.changes) {
if (ev.changes.hasOwnProperty(i)) { if (ev.changes.hasOwnProperty(i)) {
node = RED.nodes.node(i); node = RED.nodes.node(i);
for (var d in ev.changes[i]) { if (node) {
if (ev.changes[i].hasOwnProperty(d)) { for (var d in ev.changes[i]) {
node[d] = ev.changes[i][d]; if (ev.changes[i].hasOwnProperty(d)) {
node[d] = ev.changes[i][d];
}
} }
node.dirty = true;
} }
node.dirty = true;
} }
} }
@ -169,6 +171,17 @@ RED.history = (function() {
} else if (ev.t == "edit") { } else if (ev.t == "edit") {
for (i in ev.changes) { for (i in ev.changes) {
if (ev.changes.hasOwnProperty(i)) { if (ev.changes.hasOwnProperty(i)) {
if (ev.node._def.defaults[i].type) {
// This is a config node property
var currentConfigNode = RED.nodes.node(ev.node[i]);
if (currentConfigNode) {
currentConfigNode.users.splice(currentConfigNode.users.indexOf(ev.node),1);
}
var newConfigNode = RED.nodes.node(ev.changes[i]);
if (newConfigNode) {
newConfigNode.users.push(ev.node);
}
}
ev.node[i] = ev.changes[i]; ev.node[i] = ev.changes[i];
} }
} }