@@ -15,10 +15,14 @@ function FieldButton({ text, onClick, isSelected }) {
1515 return < Button onClick = { onClick } content = { text } { ...color } /> ;
1616}
1717
18- function Column ( { index, fieldOptions, type, onSetColumnType, actions } ) {
18+ function Column ( { index, mode , fieldOptions, type, onSetColumnType, actions } ) {
1919 const getTranslation = useContext ( TranslationContext ) ;
20- const name = index ? "sentence" : "base sentence" ;
21- const color = index ? "yellow" : "green" ;
20+ const name = ( mode === 'txt' )
21+ ? ( index > 0 ? "sentence" : "base sentence" )
22+ : ( index < 0 ? "to sentence" : "from sentence" ) ;
23+ const color = ( mode === 'txt' )
24+ ? ( index > 0 ? "yellow" : "green" )
25+ : ( index < 0 ? "yellow" : "green" ) ;
2226 const columnButton = < Button className = "column-button" color = { color } content = { getTranslation ( name ) } /> ;
2327 const selectedField = fieldOptions . find ( x => is ( x . id , type ) ) ;
2428 const triggerColor = selectedField ? { color : "blue" } : { } ;
@@ -72,7 +76,7 @@ const ColumnWithData = compose(
7276 } ) )
7377) ( Column ) ;
7478
75- function Columns ( { blob, index, fieldOptions, columnTypes, onSetColumnType } ) {
79+ function Columns ( { blob, index, mode , fieldOptions, columnTypes, onSetColumnType } ) {
7680 const getTranslation = useContext ( TranslationContext ) ;
7781 const blobId = blob . get ( "id" ) ;
7882
@@ -83,16 +87,29 @@ function Columns({ blob, index, fieldOptions, columnTypes, onSetColumnType }) {
8387 < ColumnWithData
8488 key = { index }
8589 index = { index }
90+ mode = { mode }
8691 type = { columnTypes . getIn ( [ blobId , "sentence" ] ) }
8792 onSetColumnType = { onSetColumnType ( "sentence" ) }
8893 fieldOptions = { fieldOptions }
8994 />
95+ // Using negative indexes for json case,
96+ // so they are iterates and do not match with positive ones
97+ { mode === 'json' && (
98+ < ColumnWithData
99+ key = { - ( index + 1 ) }
100+ index = { - ( index + 1 ) }
101+ mode = { mode }
102+ type = { columnTypes . getIn ( [ blobId , "to_sentence" ] ) }
103+ onSetColumnType = { onSetColumnType ( "to_sentence" ) }
104+ fieldOptions = { fieldOptions }
105+ />
106+ ) }
90107 </ div >
91108 </ div >
92109 ) ;
93110}
94111
95- function ColumnMapper ( { state, types, columnTypes, onSetColumnType } ) {
112+ function ColumnMapper ( { state, mode , types, columnTypes, onSetColumnType } ) {
96113 const typesSortedFiltered = types
97114 . sortBy ( type => T ( type . get ( "translations" ) . toJS ( ) ) )
98115 . filter ( type => T ( type . get ( "translations" ) . toJS ( ) ) . trim ( ) != "" ) ;
@@ -123,6 +140,7 @@ function ColumnMapper({ state, types, columnTypes, onSetColumnType }) {
123140 key = { id . join ( "/" ) }
124141 blob = { v }
125142 index = { i ++ }
143+ mode = { mode }
126144 fieldOptions = { fieldOptions }
127145 columnTypes = { columnTypes }
128146 onSetColumnType = { onSetColumnType ( id ) }
0 commit comments