mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add config-node sidebar tab
Accessed from the drop-down menu
This commit is contained in:
@@ -39,9 +39,27 @@ RED.nodes = function() {
|
||||
function addNode(n) {
|
||||
if (n._def.category == "config") {
|
||||
configNodes[n.id] = n;
|
||||
RED.configTab.refresh();
|
||||
} else {
|
||||
n.dirty = true;
|
||||
nodes.push(n);
|
||||
var updatedConfigNode = false;
|
||||
for (var d in n._def.defaults) {
|
||||
var property = n._def.defaults[d];
|
||||
if (property.type) {
|
||||
var type = getType(property.type)
|
||||
if (type && type.category == "config") {
|
||||
var configNode = configNodes[n[d]];
|
||||
if (configNode) {
|
||||
updatedConfigNode = true;
|
||||
configNode.users.push(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updatedConfigNode) {
|
||||
RED.configTab.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
function addLink(l) {
|
||||
@@ -68,6 +86,7 @@ RED.nodes = function() {
|
||||
var removedLinks = [];
|
||||
if (id in configNodes) {
|
||||
delete configNodes[id];
|
||||
RED.configTab.refresh();
|
||||
} else {
|
||||
var node = getNode(id);
|
||||
if (node) {
|
||||
@@ -75,6 +94,24 @@ RED.nodes = function() {
|
||||
removedLinks = links.filter(function(l) { return (l.source === node) || (l.target === node); });
|
||||
removedLinks.map(function(l) {links.splice(links.indexOf(l), 1); });
|
||||
}
|
||||
var updatedConfigNode = false;
|
||||
for (var d in node._def.defaults) {
|
||||
var property = node._def.defaults[d];
|
||||
if (property.type) {
|
||||
var type = getType(property.type)
|
||||
if (type && type.category == "config") {
|
||||
var configNode = configNodes[node[d]];
|
||||
if (configNode) {
|
||||
updatedConfigNode = true;
|
||||
var users = configNode.users;
|
||||
users.splice(users.indexOf(node),1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updatedConfigNode) {
|
||||
RED.configTab.refresh();
|
||||
}
|
||||
}
|
||||
return removedLinks;
|
||||
}
|
||||
|
Reference in New Issue
Block a user