@@ -113,7 +113,31 @@ export default function SearchGroups() {
113
113
} , [ searchGroupsStore , attributesSortOrder ] ) ;
114
114
115
115
useEffect ( ( ) => {
116
- if ( ! user || ! activeSearchParams || ! labelingTasks || ! attributes ) return ;
116
+ if ( ! user || ! activeSearchParams || ! labelingTasks || ! attributes || ! projectId ) return ;
117
+ if ( ! fullSearchStore || fullSearchStore [ SearchGroup . DRILL_DOWN ] == undefined ) return ;
118
+ if ( recordsInDisplay ) return ;
119
+ refreshTextHighlightNeeded ( ) ;
120
+ setHighlightingToRecords ( ) ;
121
+ if ( ! ( activeSlice && activeSlice . static ) ) {
122
+ dispatch ( updateAdditionalDataState ( 'loading' , true ) ) ;
123
+ const refetchTimer = setTimeout ( ( ) => {
124
+ refetchExtendedRecord ( {
125
+ variables : {
126
+ projectId : projectId ,
127
+ filterData : parseFilterToExtended ( activeSearchParams , attributes , configuration , labelingTasks , user , fullSearchStore [ SearchGroup . DRILL_DOWN ] ) ,
128
+ offset : 0 , limit : 20
129
+ }
130
+ } ) . then ( ( res ) => {
131
+ dispatch ( setSearchRecordsExtended ( postProcessRecordsExtended ( res . data [ 'searchRecordsExtended' ] , labelingTasks ) ) ) ;
132
+ dispatch ( updateAdditionalDataState ( 'loading' , false ) ) ;
133
+ } ) ;
134
+ } , 500 ) ;
135
+ return ( ) => clearTimeout ( refetchTimer ) ;
136
+ }
137
+ } , [ activeSearchParams , user , projectId , attributes , labelingTasks , configuration ] ) ;
138
+
139
+ useEffect ( ( ) => {
140
+ if ( ! user || ! activeSearchParams || ! labelingTasks || ! attributes || ! projectId ) return ;
117
141
if ( ! fullSearchStore || fullSearchStore [ SearchGroup . DRILL_DOWN ] == undefined ) return ;
118
142
if ( recordsInDisplay ) return ;
119
143
refreshTextHighlightNeeded ( ) ;
@@ -136,23 +160,8 @@ export default function SearchGroups() {
136
160
dispatch ( updateAdditionalDataState ( 'staticDataSliceCurrentCount' , res [ 'data' ] [ 'staticDataSlicesCurrentCount' ] ) ) ;
137
161
} ) ;
138
162
} ) ;
139
- } else {
140
- dispatch ( updateAdditionalDataState ( 'loading' , true ) ) ;
141
- const refetchTimer = setTimeout ( ( ) => {
142
- refetchExtendedRecord ( {
143
- variables : {
144
- projectId : projectId ,
145
- filterData : parseFilterToExtended ( activeSearchParams , attributes , configuration , labelingTasks , user , fullSearchStore [ SearchGroup . DRILL_DOWN ] ) ,
146
- offset : 0 , limit : 20
147
- }
148
- } ) . then ( ( res ) => {
149
- dispatch ( setSearchRecordsExtended ( postProcessRecordsExtended ( res . data [ 'searchRecordsExtended' ] , labelingTasks ) ) ) ;
150
- dispatch ( updateAdditionalDataState ( 'loading' , false ) ) ;
151
- } ) ;
152
- } , 500 ) ;
153
- return ( ) => clearTimeout ( refetchTimer ) ;
154
163
}
155
- } , [ activeSearchParams , user , projectId , attributes , labelingTasks , configuration , activeSlice ] ) ;
164
+ } , [ activeSlice , activeSearchParams , user , projectId , attributes , labelingTasks , ] ) ;
156
165
157
166
useEffect ( ( ) => {
158
167
if ( ! recordList ) return ;
@@ -477,6 +486,11 @@ export default function SearchGroups() {
477
486
const fullSearchCopy = jsonCopy ( fullSearchStore ) ;
478
487
const formControlsIdx = fullSearchCopy [ group . key ] . groupElements [ 'orderBy' ] [ index ] ;
479
488
const findActive = fullSearchCopy [ group . key ] . groupElements [ 'orderBy' ] . find ( ( el ) => el [ 'active' ] == true ) ;
489
+ const findRandom = fullSearchCopy [ group . key ] . groupElements [ 'orderBy' ] . find ( ( el ) => el [ 'orderByKey' ] == StaticOrderByKeys . RANDOM ) ;
490
+ if ( findRandom ) {
491
+ findRandom [ 'active' ] = false ;
492
+ findRandom [ 'color' ] = getActiveNegateGroupColor ( findRandom ) ;
493
+ }
480
494
if ( findActive && findActive != formControlsIdx ) findActive [ 'active' ] = false ;
481
495
if ( formControlsIdx [ 'active' ] && formControlsIdx [ 'direction' ] == - 1 ) {
482
496
formControlsIdx [ 'direction' ] = 1 ;
@@ -490,6 +504,18 @@ export default function SearchGroups() {
490
504
updateSearchParams ( fullSearchCopy ) ;
491
505
}
492
506
507
+ function updateRandomSeed ( ) {
508
+ const fullSearchCopy = jsonCopy ( fullSearchStore ) ;
509
+ const formControlsIdx = fullSearchCopy [ SearchGroup . ORDER_STATEMENTS ] . groupElements [ 'orderBy' ] . find ( ( el ) => el [ 'orderByKey' ] == StaticOrderByKeys . RANDOM ) ;
510
+ fullSearchCopy [ SearchGroup . ORDER_STATEMENTS ] . groupElements [ 'orderBy' ] . forEach ( ( el ) => {
511
+ if ( el [ 'orderByKey' ] != StaticOrderByKeys . RANDOM ) el [ 'active' ] = false ;
512
+ } ) ;
513
+ formControlsIdx [ 'active' ] = ! formControlsIdx [ 'active' ] ;
514
+ formControlsIdx [ 'color' ] = getActiveNegateGroupColor ( formControlsIdx ) ;
515
+ dispatch ( setFullSearchStore ( fullSearchCopy ) ) ;
516
+ updateSearchParams ( fullSearchCopy ) ;
517
+ }
518
+
493
519
function setRandomSeedGroup ( value ?: string ) {
494
520
const fullSearchCopy = jsonCopy ( fullSearchStore ) ;
495
521
const formControlsIdx = fullSearchCopy [ SearchGroup . ORDER_STATEMENTS ] . groupElements [ 'orderBy' ] . find ( ( el ) => el [ 'orderByKey' ] == StaticOrderByKeys . RANDOM ) ;
@@ -676,7 +702,7 @@ export default function SearchGroups() {
676
702
{ fullSearchStore [ group . key ] && < div className = "flex-grow flex flex-col" >
677
703
< div > Manually labeled</ div >
678
704
{ fullSearchStore [ group . key ] . groupElements [ 'manualLabels' ] && fullSearchStore [ group . key ] . groupElements [ 'manualLabels' ] . length == 0 ? ( < ButtonLabelsDisabled /> ) : (
679
- < Dropdown2 options = { fullSearchStore [ group . key ] . groupElements [ 'manualLabels' ] ?? [ ] } buttonName = { manualLabels . length == 0 ? 'None selected' : manualLabels . join ( ',' ) } hasCheckboxesThreeStates = { true } keepDrownOpen = { true }
705
+ < Dropdown2 options = { fullSearchStore [ group . key ] . groupElements [ 'manualLabels' ] ?? [ ] } buttonName = { manualLabels . length == 0 ? 'None selected' : manualLabels . join ( ', ' ) } hasCheckboxesThreeStates = { true } keepDrownOpen = { true }
680
706
selectedOption = { ( option : any ) => {
681
707
const labels = [ ...manualLabels , option . name ]
682
708
setManualLabels ( labels ) ;
@@ -686,7 +712,7 @@ export default function SearchGroups() {
686
712
687
713
< div className = "mt-2" > Weakly supervised</ div >
688
714
{ fullSearchStore [ group . key ] . groupElements [ 'weakSupervisionLabels' ] && fullSearchStore [ group . key ] . groupElements [ 'weakSupervisionLabels' ] . length == 0 ? ( < ButtonLabelsDisabled /> ) : (
689
- < Dropdown2 options = { fullSearchStore [ group . key ] . groupElements [ 'weakSupervisionLabels' ] ?? [ ] } buttonName = { weakSupervisionLabels . length == 0 ? 'None selected' : weakSupervisionLabels . join ( ',' ) } hasCheckboxesThreeStates = { true }
715
+ < Dropdown2 options = { fullSearchStore [ group . key ] . groupElements [ 'weakSupervisionLabels' ] ?? [ ] } buttonName = { weakSupervisionLabels . length == 0 ? 'None selected' : weakSupervisionLabels . join ( ', ' ) } hasCheckboxesThreeStates = { true }
690
716
selectedOption = { ( option : any ) => {
691
717
const labels = [ ...weakSupervisionLabels , option . name ]
692
718
setWeakSupervisionLabels ( labels ) ;
@@ -714,7 +740,7 @@ export default function SearchGroups() {
714
740
715
741
< div className = "mt-2" > Model callback</ div >
716
742
{ fullSearchStore [ group . key ] . groupElements [ 'modelCallbackLabels' ] && fullSearchStore [ group . key ] . groupElements [ 'modelCallbackLabels' ] . length == 0 ? ( < ButtonLabelsDisabled /> ) : (
717
- < Dropdown2 options = { fullSearchStore [ group . key ] . groupElements [ 'modelCallbackLabels' ] ?? [ ] } buttonName = { modelCallBacksLabels . length == 0 ? 'None selected' : modelCallBacksLabels . join ( ',' ) } hasCheckboxesThreeStates = { true }
743
+ < Dropdown2 options = { fullSearchStore [ group . key ] . groupElements [ 'modelCallbackLabels' ] ?? [ ] } buttonName = { modelCallBacksLabels . length == 0 ? 'None selected' : modelCallBacksLabels . join ( ', ' ) } hasCheckboxesThreeStates = { true }
718
744
selectedOption = { ( option : any ) => {
719
745
const labels = [ ...modelCallBacksLabels , option . name ]
720
746
setModelCallBacksLabels ( labels ) ;
@@ -772,7 +798,7 @@ export default function SearchGroups() {
772
798
< span className = "ml-2 text-sm truncate w-full" > { groupItem [ 'displayName' ] } </ span >
773
799
</ div >
774
800
</ div > ) : ( < div className = "flex flex-row items-center mr-2" >
775
- < div className = "flex flex-row items-center cursor-pointer" onClick = { ( ) => setActiveNegateGroup ( groupItem , index , group ) } >
801
+ < div className = "flex flex-row items-center cursor-pointer" onClick = { updateRandomSeed } >
776
802
< div style = { { backgroundColor : groupItem . color , borderColor : groupItem . color } }
777
803
className = "ml-2 mr-2 h-4 w-4 border-gray-300 border rounded cursor-pointer hover:bg-gray-200" >
778
804
</ div >
0 commit comments