Skip to content

Commit

Permalink
bugfix: handle case where children come from same query as parent
Browse files Browse the repository at this point in the history
Signed-off-by: pogi7 <[email protected]>
  • Loading branch information
pogi7 committed Sep 4, 2024
1 parent e291e79 commit 1ae4fef
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions view/src/components/Tree/treeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ export const mapTreeValueData = (
}
})
.map((row: ITableData, index: number) => {
// Random uuid as an identifer for row
let uuid = crypto.randomUUID();

let identifier = recursiveIdentifier
? `${recursiveIdentifier}-${index}`
: `${index}`;
let processedRow = processEntry(row, rowMapping, identifier);
let processedRow = processEntry(row, rowMapping, uuid);

// Save the rowType for row-specific actions in the Table
// such as right click context menus, etc.
Expand All @@ -81,11 +84,20 @@ export const mapTreeValueData = (
// Otherwise, check for subRowMappings
if (rowMapping.isRecursive) {
children = recursiveMapper(rowMapping, "parent", row.iri, identifier);
// Check to make sure subRowMappings exists
} else if (rowMapping.subRowMappings) {
children = rowMapping.subRowMappings.flatMap(
(subMapping: IRowMapping) =>
recursiveMapper(subMapping, rowMapping.id, row.iri, identifier)
);
if (rowMapping.subRowMappings[0].id !== rowMapping.id) {
// Handles case where children nodes come from a different query than the parent
children = rowMapping.subRowMappings.flatMap(
(subMapping: IRowMapping) =>
recursiveMapper(subMapping, rowMapping.id, row.iri, identifier)
);
} else {
// Handles case where children nodes come from the same query than the parent
children = rowMapping.subRowMappings.flatMap(
(subMapping: IRowMapping) => recursiveMapper(subMapping, identifier=identifier)
);
}
}

if (children.length > 0) {
Expand Down

0 comments on commit 1ae4fef

Please sign in to comment.