Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSCFC4EMSCR-585 pull request to develop #237

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions mscr-ui/src/common/components/schema-info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,51 @@ export default function SchemaInfo(props: {

// Used by tree select and filtering
function getAllNodeIdsOnPathToLeaf(nodeIds: string[]) {
let nodesWithElementPath: {[elementPath: string] : RenderTree[]} = {};
const nodesToSelect: Set<string> = new Set();
const elementPaths: string[] = [];
for (let key in nodeIdToNodeDictionary) {
if (nodeIdToNodeDictionary[key]) {
let renderTrees = nodeIdToNodeDictionary[key];
if (renderTrees && renderTrees.length > 0) {
renderTrees.forEach(tree => {
if (tree && tree.elementPath) {
let treeArray = [];
treeArray = nodesWithElementPath[tree.elementPath];
if (treeArray && treeArray.length > 0) {
treeArray.push(tree);
} else {
treeArray = [];
treeArray.push(tree);
}
nodesWithElementPath[tree.elementPath] = treeArray;
}
});

}
}
}
nodeIds.forEach((nodeId) => {
nodesToSelect.add(nodeId);
const nodes = nodeIdToNodeDictionary[nodeId];
nodes.map((node) => elementPaths.push(node.elementPath));
});

const nodesToSelect: Set<string> = new Set();
elementPaths.forEach((path) => {
const nodeIdsOnPath = path.split('.');
nodeIdsOnPath.forEach((nodeId) => {
nodesToSelect.add(nodeId);
});
if (nodes && nodes.length > 0) {
nodes.map((node) => {
if (node.parentElementPath) {
let nodeInParentElementPath: string | undefined = node.parentElementPath;
while(nodeInParentElementPath !== undefined) {
let parentNodeTrees: RenderTree[] = nodesWithElementPath[nodeInParentElementPath];
inner:
for (let parentNodeTree of parentNodeTrees) {
if (parentNodeTree && parentNodeTree.id) {
nodesToSelect.add(parentNodeTree.id);
nodeInParentElementPath = parentNodeTree.parentElementPath
break inner; // there should be only one parent
}
}
}
}
});
}
});

return Array.from(nodesToSelect);
Expand Down
Loading