Fix for node with wrong type

This commit is contained in:
Knut Sveidqvist
2021-11-30 20:28:51 +01:00
parent a018789026
commit 3526e35012
10 changed files with 62 additions and 30 deletions

View File

@@ -70,11 +70,7 @@ const setupNode = (g, parent, node, altFlag) => {
nodeDb[node.id].shape = 'rectWithTitle';
if (nodeDb[node.id].description === node.id) {
// If the previous description was the is, remove it
if (Array.isArray(node.description)) {
nodeDb[node.id].description = node.description;
} else {
nodeDb[node.id].description = [node.description];
}
nodeDb[node.id].description = [node.description];
} else {
nodeDb[node.id].description = [nodeDb[node.id].description, node.description];
}
@@ -83,6 +79,15 @@ const setupNode = (g, parent, node, altFlag) => {
nodeDb[node.id].description = node.description;
}
}
nodeDb[node.id].description = common.sanitizeTextOrArray(
nodeDb[node.id].description,
getConfig()
);
}
//
if (nodeDb[node.id].description.length === 1 && nodeDb[node.id].shape === 'rectWithTitle') {
nodeDb[node.id].shape = 'rect';
}
// Save data for description and group so that for instance a statement without description overwrites
@@ -100,17 +105,10 @@ const setupNode = (g, parent, node, altFlag) => {
(altFlag ? 'statediagram-cluster statediagram-cluster-alt' : 'statediagram-cluster');
}
let nodeShape = nodeDb[node.id].shape;
let nodeLabelText = nodeDb[node.id].description;
if (Array.isArray(nodeLabelText) && nodeLabelText.length == 1) {
nodeShape = 'rect';
nodeLabelText = nodeLabelText[0];
}
const nodeData = {
labelStyle: '',
shape: nodeShape,
labelText: nodeLabelText,
shape: nodeDb[node.id].shape,
labelText: nodeDb[node.id].description,
// typeof nodeDb[node.id].description === 'object'
// ? nodeDb[node.id].description[0]
// : nodeDb[node.id].description,