#5237 Removed use of node.type from renderer

This commit is contained in:
Knut Sveidqvist
2024-05-20 14:29:38 +02:00
parent b6ef7367c2
commit c8f2abad18
3 changed files with 9 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ export const addVertex = async (nodeEl, graph, nodeArr, node) => {
nodeDb[node.id] = child;
// // Add the element to the DOM
if (node.type !== 'group') {
if (!node.isGroup) {
const childNodeEl = await insertNode(nodeEl, node, node.dir);
boundingBox = childNodeEl.node().getBBox();
child.domId = childNodeEl;
@@ -106,7 +106,7 @@ const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, depth) => {
width: node.width,
height: node.height,
};
if (node.type === 'group') {
if (node.isGroup) {
log.debug('Id abc88 subgraph = ', node.id, node.x, node.y, node.labelData);
const subgraphEl = subgraphsEl.insert('g').attr('class', 'subgraph');
// TODO use faster way of cloning
@@ -135,7 +135,7 @@ const drawNodes = (relX, relY, nodeArray, svg, subgraphsEl, depth) => {
}
});
nodeArray.forEach(function (node) {
if (node && node.type === 'group') {
if (node && node.isGroup) {
drawNodes(relX + node.x, relY + node.y, node.children, svg, subgraphsEl, depth + 1);
}
});
@@ -192,7 +192,7 @@ const getNextPort = (node, edgeDirection, graphDirection) => {
const addSubGraphs = function (nodeArr) {
const parentLookupDb = { parentById: {}, childrenById: {} };
const subgraphs = nodeArr.filter((node) => node.type === 'group');
const subgraphs = nodeArr.filter((node) => node.isGroup);
log.info('Subgraphs - ', subgraphs);
subgraphs.forEach(function (subgraph) {
const children = nodeArr.filter((node) => node.parentId === subgraph.id);

View File

@@ -279,6 +279,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
if (!newNode.type && parsedItem.doc) {
log.info('Setting cluster for ', itemId, getDir(parsedItem));
newNode.type = 'group';
newNode.isGroup = true;
newNode.dir = getDir(parsedItem);
newNode.shape = parsedItem.type === DIVIDER_TYPE ? SHAPE_DIVIDER : SHAPE_GROUP;
newNode.cssClasses =
@@ -300,6 +301,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
dir: newNode.dir,
domId: stateDomId(itemId, graphItemCount),
type: newNode.type,
isGroup: newNode.type === 'group',
padding: 15,
rx: 10,
ry: 10,
@@ -325,6 +327,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
id: itemId + NOTE_ID + '-' + graphItemCount,
domId: stateDomId(itemId, graphItemCount, NOTE),
type: newNode.type,
isGroup: newNode.type === 'group',
padding: 15, //getConfig().flowchart.padding
useRough,
};
@@ -337,6 +340,7 @@ export const dataFetcher = (parent, parsedItem, diagramStates, nodes, edges, alt
id: itemId + PARENT_ID,
domId: stateDomId(itemId, graphItemCount, PARENT),
type: 'group',
isGroup: true,
padding: 0, //getConfig().flowchart.padding
useRough,
};

View File

@@ -165,7 +165,7 @@ const recursiveRender = async (_elem, graph, diagramType, id, parentCluster, sit
graph.nodes().forEach(function (v) {
const n = graph.node(v);
log.info(v, n.type, n.diff);
if (n.type === 'group') {
if (n.isGroup) {
diff = n.diff;
}
});