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,6 +149,7 @@ 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);
if (node) {
for (var d in ev.changes[i]) { for (var d in ev.changes[i]) {
if (ev.changes[i].hasOwnProperty(d)) { if (ev.changes[i].hasOwnProperty(d)) {
node[d] = ev.changes[i][d]; node[d] = ev.changes[i][d];
@ -157,6 +158,7 @@ RED.history = (function() {
node.dirty = true; node.dirty = true;
} }
} }
}
} }
} else if (ev.t == "move") { } else if (ev.t == "move") {
@ -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];
} }
} }