Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
feat: limit amount of children we show (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
niekvanstaveren committed Feb 18, 2020
1 parent b16a727 commit f5d636e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/locale/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
'Object.OrgChart.DummyWarn': 'The data contains multiple root nodes.',
'Object.OrgChart.CycleWarning': 'Data contains circular references, nodes are omitted.',
'Object.OrgChart.MissingRoot': 'No root node, check your data for circular references.',
'Object.OrgChart.MaxChildren': 'Maximum of children reached only showing 100 child nodes.',
'Object.OrgChart.LabelExpression': 'Label expression',
'Object.OrgChart.SubLabelExpression': 'Sub-label expression',
'Object.OrgChart.ExtraLabelExpression': 'Extra-label expression',
Expand Down
11 changes: 9 additions & 2 deletions src/utils/tree-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,17 @@ export function createNodes(matrix, attributeIndecies, status, navigationMode, t
}

const rootNodes = [];
let maxNodeWarning = false;
for (let i = 0; i < allNodes.length; ++i) {
const node = allNodes[i];
const parentNode = nodeMap[node.parentId];
node.parent = parentNode;
if (parentNode) {
parentNode.children.push({ childNumber: parentNode.children.length, ...node });
parentNode.children.length > 100
? (maxNodeWarning = true)
: parentNode.children.push({ childNumber: parentNode.children.length, ...node });
} else {
rootNodes.push(node);
rootNodes.length > 100 ? (maxNodeWarning = true) : rootNodes.push(node);
}
}

Expand All @@ -195,6 +198,10 @@ export function createNodes(matrix, attributeIndecies, status, navigationMode, t
if (status === MAX_DATA) {
warn.push(translator.get('Object.OrgChart.MaxData'));
}
// Only show a maximum of children.
if (maxNodeWarning) {
warn.push(translator.get('Object.OrgChart.MaxChildren'));
}
// I have not looked at these functions at all. But we need to check the data as well I would say.
if (anyCycle(allNodes)) {
warn.push(translator.get('Object.OrgChart.CycleWarning'));
Expand Down

0 comments on commit f5d636e

Please sign in to comment.