@@ -8,16 +8,16 @@ function Columns({ blob, index, mode, onDelete, onUpdateColumn }) {
88 const getTranslation = useContext ( TranslationContext ) ;
99 const color = ( mode === 'json' ) ? "blue" : index ? "yellow" : "green" ;
1010 const name = ( mode === 'json' ) ? "both sides" : index ? "sentence" : "base sentence" ;
11- const value = blob . getIn ( [ "values" , " sentence" ] , "dash" ) ;
12- useEffect (
13- ( ) => {
14- onUpdateColumn ( "sentence" , value ) ;
15- if ( mode === 'json' ) {
16- onUpdateColumn ( "to_sentence" , "json" ) ;
17- }
18- } ,
19- [ ]
20- ) ;
11+ // We store 'dedash' flag in ' sentence' value because its value has no matter anywhere else
12+ const dedash = blob . getIn ( [ "values" , "sentence" ] , null ) === "dedash" ;
13+ useEffect ( ( ) => {
14+ // On json format we have both sentences in one file,
15+ // so to_sentence is already selected, we store a random value there
16+ // to get 'Next Step' button active at once
17+ if ( mode === 'json' ) {
18+ onUpdateColumn ( "to_sentence" , "json_mode" ) ;
19+ }
20+ } , [ ] ) ;
2121
2222 return (
2323 < div className = "blob blob_corp" >
@@ -28,34 +28,37 @@ function Columns({ blob, index, mode, onDelete, onUpdateColumn }) {
2828 { getTranslation ( name ) }
2929 </ Button >
3030 </ div >
31- { ! index && ( mode === 'txt' ) && (
31+ { ! index && ( mode === 'txt' || mode === 'marker' ) && (
3232 < Checkbox className = "blob-checkbox"
3333 label = { getTranslation ( "Hide dashes" ) }
34- onClick = { ( ) => onUpdateColumn ( "sentence" , value === "dash" ? "dedash" : "dash" , value ) }
35- checked = { value === " dedash" } />
34+ onClick = { ( ) => onUpdateColumn ( "sentence" , dedash ? mode : "dedash" ) }
35+ checked = { dedash } />
3636 ) || < div className = "blob-checkbox" /> }
3737 </ div >
3838 ) ;
3939}
4040
41- function Linker ( { blobs, state, onSelect, onDelete, onUpdateColumn } ) {
41+ function Linker ( { blobs, state, onSelect, onSetMarked , onDelete, onUpdateColumn } ) {
4242 const getTranslation = useContext ( TranslationContext ) ;
4343
4444 const first = state . first ( ) ;
45- const selected = first ? first . get ( "id" ) . join ( "/" ) : null ;
45+ const firstId = first ? first . get ( "id" ) : null ;
46+ const selected = firstId ? firstId . join ( "/" ) : null ;
4647 const mode = first ? first . get ( "data_type" ) : null ;
48+ const marked = ( mode === 'marked' ) ;
4749
48- const stateOptions = blobs . filter (
49- blob => ( ! mode || blob . get ( "data_type" ) === mode ) ) . reduce (
50- ( acc , blob ) => [
51- ...acc ,
50+ // Filtering stored files by type on mode current value
51+ // Note: 'marked' mode value means 'txt' files type
52+ const stateOptions = (
53+ blobs . filter ( blob => ! mode || blob . get ( "data_type" ) === ( marked ? 'txt' : mode ) )
54+ ) . reduce ( ( acc , blob ) =>
55+ [ ...acc ,
5256 {
5357 key : blob . get ( "id" ) . join ( "/" ) ,
5458 value : blob . get ( "id" ) . join ( "/" ) ,
5559 text : blob . get ( "name" )
5660 }
57- ] ,
58- [ ]
61+ ] , [ ]
5962 ) ;
6063
6164 function onChange ( event , data ) {
@@ -86,7 +89,17 @@ function Linker({ blobs, state, onSelect, onDelete, onUpdateColumn }) {
8689 onUpdateColumn = { onUpdateColumn ( id ) }
8790 />
8891 ) )
89- . toArray ( ) }
92+ . toArray ( )
93+ }
94+ { ( mode === 'txt' || mode === 'marked' ) && (
95+ < div className = "container-gray" >
96+ < Checkbox className = "blob-checkbox"
97+ label = { getTranslation ( ff ) }
98+ onClick = { onSetMarked }
99+ checked = { marked }
100+ />
101+ </ div >
102+ ) }
90103 </ div >
91104 ) ;
92105}
0 commit comments