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 Change node elementpath to array to fix tree selection #239

Merged
Merged
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions mscr-ui/src/common/components/schema-info/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,17 @@ export default function SchemaInfo(props: {

// Used by tree select and filtering
function getAllNodeIdsOnPathToLeaf(nodeIds: string[]) {
const elementPaths: string[] = [];
let idsOnPath: string[] = [];
nodeIds.forEach((nodeId) => {
const nodes = nodeIdToNodeDictionary[nodeId];
nodes.map((node) => elementPaths.push(node.elementPath));
nodes.map((node) => {
idsOnPath = idsOnPath.concat(node.rootPathIds);
});
});

const nodesToSelect: Set<string> = new Set();
elementPaths.forEach((path) => {
const nodeIdsOnPath = path.split('.');
nodeIdsOnPath.forEach((nodeId) => {
nodesToSelect.add(nodeId);
});
idsOnPath.forEach((pathNodeId) => {
nodesToSelect.add(pathNodeId);
});

return Array.from(nodesToSelect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ export default function NodeInfo(props: {
)}
{props.isNodeEditable &&
selectedNode &&
selectedNode?.elementPath !== 'ROOT' &&
!isLeafNode &&
!props.hasCustomRoot && (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ let treeIndex = 0;

function createRenderTree(
input: any,
elementPath: string,
rootPathIds: string[],
definitions: any,
idToNodeDictionary: { [key: string]: RenderTree[] },
) {
Expand All @@ -16,8 +16,7 @@ function createRenderTree(
visualTreeId: treeIndex.toString(),
id: obj.toString(),
properties: definitions[obj],
elementPath: elementPath == '' ? obj.toString() : elementPath + '.' + obj.toString(),
parentElementPath: elementPath,
rootPathIds: [...rootPathIds, obj.toString()],
children: [],
uri: definitions[obj]['@id'],
};
Expand All @@ -29,7 +28,7 @@ function createRenderTree(
// HAS CHILDREN, OTHERWISE IS LEAF
newNode.children = createRenderTree(
input[obj],
newNode.elementPath,
newNode.rootPathIds,
definitions,
idToNodeDictionary,
);
Expand All @@ -47,7 +46,7 @@ export function generateTreeFromJson(jsonInput: any) {
const generatedTree = new Promise<RenderTree[]>((resolve) => {
const renderedTree = createRenderTree(
jsonInput.content.tree,
'',
[],
jsonInput.content.definitions,
nodeIdToShallowNode
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export interface RenderTree {
visualTreeId: string;
id: string;
properties: any;
elementPath: string;
parentElementPath: string | undefined;
rootPathIds: string[];
children: RenderTree[];
uri: string;
}
Expand Down
3 changes: 1 addition & 2 deletions mscr-ui/src/modules/crosswalk-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export default function CrosswalkEditor({
const isEditModeActive = useSelector(selectIsEditContentActive());

const emptyTreeSelection: RenderTree = {
elementPath: '',
parentElementPath: undefined,
rootPathIds: [],
name: '',
id: '',
visualTreeId: '',
Expand Down
Loading