Skip to content

Commit 05a539e

Browse files
committed
fixed rows, states and transitions values not being trimmed when saved or uploaded which was causing their respective id issues
1 parent 7ecc539 commit 05a539e

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/components/Editor.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,12 @@ export const Editor = () => {
241241
(row[key === "^" ? "nul" : key] = Array.from(
242242
new Set(
243243
row[key === "^" ? "nul" : key]
244-
.toString()
245-
.split(" ")
246-
.filter((s) => s !== "")
244+
?.toString()
245+
?.trim()
246+
?.split(" ")
247+
?.filter((s) => s !== "")
247248
)
248-
).join(" "))
249+
)?.join(" "))
249250
);
250251

251252
if (!oldRow) {

src/features/Upload.tsx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TransitionModel } from "../models";
77
import { StyledTransitionLabel } from "./components/playground/StyledTransitionLabel";
88
import { UploadProps } from "./props/UploadProps";
99
import { StateMaxSize, StateMinSize } from "../consts/StateSizes";
10+
import { PossibleTransitionValues } from "../consts/PossibleTransitionValues";
1011

1112
export const Upload = (props: UploadProps) => {
1213
console.log("re rendering Upload: props", props);
@@ -65,12 +66,32 @@ export const Upload = (props: UploadProps) => {
6566
return;
6667
}
6768

68-
dataContext?.setRowId(data.rowId);
69-
dataContext?.setRows(data.rows);
70-
dataContext?.setStates(data.states);
71-
handleSetTransitions(data.transitions);
72-
dataContext?.setTransitions(data.transitions);
73-
dataContext?.setStateSize(data.stateSize);
69+
data?.rows?.forEach((row) => {
70+
PossibleTransitionValues?.concat("state")?.forEach((value) => {
71+
row[value === "^" ? "nul" : value] = row[
72+
value === "^" ? "nul" : value
73+
]
74+
?.toString()
75+
?.trim();
76+
});
77+
});
78+
79+
data?.states?.forEach((state) => {
80+
state.id = state?.id?.toString()?.trim();
81+
});
82+
83+
data?.transitions?.forEach((transition) => {
84+
transition.start = transition?.start?.toString()?.trim();
85+
transition.end = transition?.end?.toString()?.trim();
86+
transition.value = transition?.value?.toString()?.trim();
87+
});
88+
89+
dataContext?.setRowId(data?.rowId);
90+
dataContext?.setRows(data?.rows);
91+
dataContext?.setStates(data?.states);
92+
handleSetTransitions(data?.transitions);
93+
dataContext?.setTransitions(data?.transitions);
94+
dataContext?.setStateSize(data?.stateSize);
7495
console.log("Successfuly uploaded data.");
7596
};
7697
reader.readAsText(newFile);

0 commit comments

Comments
 (0)