#1295 Adding support for multiline descriptions for states

This commit is contained in:
Knut Sveidqvist
2020-04-26 09:47:47 +02:00
parent 0aede618ec
commit 5662c06a33
3 changed files with 26 additions and 8 deletions

View File

@@ -52,13 +52,26 @@ const setupNode = (g, parent, node, altFlag) => {
};
}
// Description
// Build of the array of description strings accordinging
if (node.description) {
if (Array.isArray(node.description)) {
if (Array.isArray(nodeDb[node.id].description)) {
// There already is an array of strings,add to it
nodeDb[node.id].shape = 'rectWithTitle';
nodeDb[node.id].description = node.description;
nodeDb[node.id].description.push(node.description);
} else {
nodeDb[node.id].description = node.description;
if (nodeDb[node.id].description.length > 0) {
// if there is a description already transformit to an array
nodeDb[node.id].shape = 'rectWithTitle';
if (nodeDb[node.id].description === node.id) {
// If the previous description was the is, remove it
nodeDb[node.id].description = [node.description];
} else {
nodeDb[node.id].description = [nodeDb[node.id].description, node.description];
}
} else {
nodeDb[node.id].shape = 'rect';
nodeDb[node.id].description = node.description;
}
}
}