@@ -7,6 +7,7 @@ import { TransitionModel } from "../models";
77import { StyledTransitionLabel } from "./components/playground/StyledTransitionLabel" ;
88import { UploadProps } from "./props/UploadProps" ;
99import { StateMaxSize , StateMinSize } from "../consts/StateSizes" ;
10+ import { PossibleTransitionValues } from "../consts/PossibleTransitionValues" ;
1011
1112export 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