@@ -113,7 +113,31 @@ export default function SearchGroups() {
113113 } , [ searchGroupsStore , attributesSortOrder ] ) ;
114114
115115 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 ;
117141 if ( ! fullSearchStore || fullSearchStore [ SearchGroup . DRILL_DOWN ] == undefined ) return ;
118142 if ( recordsInDisplay ) return ;
119143 refreshTextHighlightNeeded ( ) ;
@@ -136,23 +160,8 @@ export default function SearchGroups() {
136160 dispatch ( updateAdditionalDataState ( 'staticDataSliceCurrentCount' , res [ 'data' ] [ 'staticDataSlicesCurrentCount' ] ) ) ;
137161 } ) ;
138162 } ) ;
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 ) ;
154163 }
155- } , [ activeSearchParams , user , projectId , attributes , labelingTasks , configuration , activeSlice ] ) ;
164+ } , [ activeSlice , activeSearchParams , user , projectId , attributes , labelingTasks , ] ) ;
156165
157166 useEffect ( ( ) => {
158167 if ( ! recordList ) return ;
@@ -477,6 +486,11 @@ export default function SearchGroups() {
477486 const fullSearchCopy = jsonCopy ( fullSearchStore ) ;
478487 const formControlsIdx = fullSearchCopy [ group . key ] . groupElements [ 'orderBy' ] [ index ] ;
479488 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+ }
480494 if ( findActive && findActive != formControlsIdx ) findActive [ 'active' ] = false ;
481495 if ( formControlsIdx [ 'active' ] && formControlsIdx [ 'direction' ] == - 1 ) {
482496 formControlsIdx [ 'direction' ] = 1 ;
@@ -490,6 +504,18 @@ export default function SearchGroups() {
490504 updateSearchParams ( fullSearchCopy ) ;
491505 }
492506
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+
493519 function setRandomSeedGroup ( value ?: string ) {
494520 const fullSearchCopy = jsonCopy ( fullSearchStore ) ;
495521 const formControlsIdx = fullSearchCopy [ SearchGroup . ORDER_STATEMENTS ] . groupElements [ 'orderBy' ] . find ( ( el ) => el [ 'orderByKey' ] == StaticOrderByKeys . RANDOM ) ;
@@ -676,7 +702,7 @@ export default function SearchGroups() {
676702 { fullSearchStore [ group . key ] && < div className = "flex-grow flex flex-col" >
677703 < div > Manually labeled</ div >
678704 { 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 }
680706 selectedOption = { ( option : any ) => {
681707 const labels = [ ...manualLabels , option . name ]
682708 setManualLabels ( labels ) ;
@@ -686,7 +712,7 @@ export default function SearchGroups() {
686712
687713 < div className = "mt-2" > Weakly supervised</ div >
688714 { 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 }
690716 selectedOption = { ( option : any ) => {
691717 const labels = [ ...weakSupervisionLabels , option . name ]
692718 setWeakSupervisionLabels ( labels ) ;
@@ -714,7 +740,7 @@ export default function SearchGroups() {
714740
715741 < div className = "mt-2" > Model callback</ div >
716742 { 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 }
718744 selectedOption = { ( option : any ) => {
719745 const labels = [ ...modelCallBacksLabels , option . name ]
720746 setModelCallBacksLabels ( labels ) ;
@@ -772,7 +798,7 @@ export default function SearchGroups() {
772798 < span className = "ml-2 text-sm truncate w-full" > { groupItem [ 'displayName' ] } </ span >
773799 </ div >
774800 </ 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 } >
776802 < div style = { { backgroundColor : groupItem . color , borderColor : groupItem . color } }
777803 className = "ml-2 mr-2 h-4 w-4 border-gray-300 border rounded cursor-pointer hover:bg-gray-200" >
778804 </ div >
0 commit comments