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

Add updateConfigNodeUsers function to editor

This commit is contained in:
Nick O'Leary 2016-06-28 14:57:48 +01:00
parent 5f047633c3
commit 9d52ed5ff6

View File

@ -165,27 +165,7 @@ RED.nodes = (function() {
} }
} }
n.dirty = true; n.dirty = true;
var updatedConfigNode = false; updateConfigNodeUsers(n);
for (var d in n._def.defaults) {
if (n._def.defaults.hasOwnProperty(d)) {
var property = n._def.defaults[d];
if (property.type) {
var type = registry.getNodeType(property.type);
if (type && type.category == "config") {
var configNode = configNodes[n[d]];
if (configNode) {
if (configNode.users.indexOf(n) === -1) {
updatedConfigNode = true;
configNode.users.push(n);
}
}
}
}
}
}
if (updatedConfigNode) {
// TODO: refresh config tab?
}
if (n._def.category == "subflows" && typeof n.i === "undefined") { if (n._def.category == "subflows" && typeof n.i === "undefined") {
var nextId = 0; var nextId = 0;
RED.nodes.eachNode(function(node) { RED.nodes.eachNode(function(node) {
@ -990,6 +970,26 @@ RED.nodes = (function() {
return result; return result;
} }
// Update any config nodes referenced by the provided node to ensure their 'users' list is correct
function updateConfigNodeUsers(n) {
for (var d in n._def.defaults) {
if (n._def.defaults.hasOwnProperty(d)) {
var property = n._def.defaults[d];
if (property.type) {
var type = registry.getNodeType(property.type);
if (type && type.category == "config") {
var configNode = configNodes[n[d]];
if (configNode) {
if (configNode.users.indexOf(n) === -1) {
configNode.users.push(n);
}
}
}
}
}
}
}
return { return {
registry:registry, registry:registry,
setNodeList: registry.setNodeList, setNodeList: registry.setNodeList,
@ -1061,6 +1061,7 @@ RED.nodes = (function() {
getAllFlowNodes: getAllFlowNodes, getAllFlowNodes: getAllFlowNodes,
createExportableNodeSet: createExportableNodeSet, createExportableNodeSet: createExportableNodeSet,
createCompleteNodeSet: createCompleteNodeSet, createCompleteNodeSet: createCompleteNodeSet,
updateConfigNodeUsers: updateConfigNodeUsers,
id: getID, id: getID,
dirty: function(d) { dirty: function(d) {
if (d == null) { if (d == null) {