mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Increment subflow name on import of duplicate
This commit is contained in:
parent
f4ec9a72d5
commit
216b5fba7a
@ -260,7 +260,24 @@ RED.nodes = (function() {
|
|||||||
return {nodes:removedNodes,links:removedLinks};
|
return {nodes:removedNodes,links:removedLinks};
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSubflow(sf) {
|
function addSubflow(sf, createNewIds) {
|
||||||
|
if (createNewIds) {
|
||||||
|
var subflowNames = Object.keys(subflows).map(function(sfid) {
|
||||||
|
return subflows[sfid].name;
|
||||||
|
});
|
||||||
|
|
||||||
|
subflowNames.sort();
|
||||||
|
var copyNumber = 1;
|
||||||
|
var subflowName = sf.name;
|
||||||
|
subflowNames.forEach(function(name) {
|
||||||
|
if (subflowName == name) {
|
||||||
|
copyNumber++;
|
||||||
|
subflowName = sf.name+" ("+copyNumber+")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sf.name = subflowName;
|
||||||
|
}
|
||||||
|
|
||||||
subflows[sf.id] = sf;
|
subflows[sf.id] = sf;
|
||||||
RED.nodes.registerType("subflow:"+sf.id, {
|
RED.nodes.registerType("subflow:"+sf.id, {
|
||||||
defaults:{name:{value:""}},
|
defaults:{name:{value:""}},
|
||||||
@ -612,7 +629,7 @@ RED.nodes = (function() {
|
|||||||
output.id = getID();
|
output.id = getID();
|
||||||
});
|
});
|
||||||
new_subflows.push(n);
|
new_subflows.push(n);
|
||||||
addSubflow(n);
|
addSubflow(n,createNewIds);
|
||||||
} else {
|
} else {
|
||||||
def = registry.getNodeType(n.type);
|
def = registry.getNodeType(n.type);
|
||||||
if (def && def.category == "config") {
|
if (def && def.category == "config") {
|
||||||
|
Loading…
Reference in New Issue
Block a user