File tree Expand file tree Collapse file tree
src/components/portfolioPage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class Corpora extends Component {
2525 let count = this . props . items . length ;
2626 let total = this . props . from ;
2727 let listIds = this . props . ids . map ( ( corpus ) =>
28- < div key = { corpus } > < input type = "checkbox" value = { corpus } onChange = { this . handleChange } /> { corpus } < ItemCreator corpus = { corpus } conf = { this . props . conf } /> </ div >
28+ < div key = { corpus } > < input type = "checkbox" value = { corpus } onChange = { this . handleChange } checked = { this . isChecked ( corpus ) } /> { corpus } < ItemCreator corpus = { corpus } conf = { this . props . conf } /> </ div >
2929 ) ;
3030 return (
3131 < div className = "col-md-8 p-4" >
@@ -68,7 +68,7 @@ class Corpora extends Component {
6868 handleChange = ( e ) => {
6969 let list = this . state . listCorpus ;
7070 let index = list . indexOf ( e . target . value ) ;
71- if ( index != - 1 ) {
71+ if ( index !== - 1 ) {
7272 list . splice ( index , 1 ) ;
7373 } else {
7474 list . push ( e . target . value ) ;
@@ -78,6 +78,14 @@ class Corpora extends Component {
7878 } ) ;
7979 console . log ( 'this.state=' , this . state ) ;
8080 }
81+
82+ isChecked ( corpus ) {
83+ let list = this . state . listCorpus ;
84+ if ( ! list . includes ( corpus ) ) {
85+ return true ;
86+ }
87+ return false ;
88+ }
8189}
8290
8391function Item ( props ) {
You can’t perform that action at this time.
0 commit comments