Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const StepInterval = ElementInterval.y;
type StepNodeKey = string;

const getStepKey = (stepOrder: number): StepNodeKey => `steps[${stepOrder}]`;
const parseStepIndex = (stepKey: string): number => parseInt(stepKey.replace(/steps\[(\d+)\]/, '$1'));

const calculateNodes = (groupId: string, data): GraphNodeMap<StepNodeKey> => {
const steps = transformStepGroup(data, groupId);
Expand All @@ -37,7 +38,7 @@ const calculateNodes = (groupId: string, data): GraphNodeMap<StepNodeKey> => {

const calculateLayout = (nodeMap: GraphNodeMap<StepNodeKey>): GraphLayout => {
const nodes = Object.keys(nodeMap)
.sort()
.sort((a, b) => parseStepIndex(a) - parseStepIndex(b))
.map(stepName => nodeMap[stepName]);
return sequentialLayouter(nodes);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum SwitchNodes {
type CaseNodeKey = string;

const getCaseKey = (caseIndex: number): CaseNodeKey => `cases[${caseIndex}]`;
const parseCaseIndex = (caseKey: CaseNodeKey): number => parseInt(caseKey.replace(/cases\[(\d+)\]/, '$1'));

const calculateNodeMap = (path: string, data): GraphNodeMap<SwitchNodes | CaseNodeKey> => {
const result = transformSwitchCondition(data, path);
Expand Down Expand Up @@ -55,7 +56,7 @@ const calculateNodeMap = (path: string, data): GraphNodeMap<SwitchNodes | CaseNo
const calculateLayout = (nodeMap: GraphNodeMap<SwitchNodes | CaseNodeKey>) => {
const { switchNode, choiceNode, ...cases } = nodeMap as GraphNodeMap<SwitchNodes>;
const casesNodes = Object.keys(cases)
.sort()
.sort((a, b) => parseCaseIndex(a) - parseCaseIndex(b))
.map(caseName => nodeMap[caseName]);
return switchCaseLayouter(switchNode, choiceNode, casesNodes);
};
Expand Down