@@ -103,7 +103,7 @@ async function createSuggestions({
103103 previousEquation,
104104 columns,
105105 searchBody,
106- searchBodyIndex = 0 ,
106+ searchBodyIndex,
107107} : {
108108 diracxUrl : string | null ;
109109 accessToken : string | undefined ;
@@ -150,15 +150,11 @@ async function createSuggestions({
150150 const type = columns . map (
151151 ( column ) => column . meta ?. type || CategoryType . STRING ,
152152 ) as CategoryType [ ] ;
153- const hideSuggestion = columns . map (
154- ( column ) => column . meta ?. isQuasiUnique || false ,
155- ) ;
156153
157154 return {
158155 items : items ,
159156 type,
160157 nature : Array ( items . length ) . fill ( SearchBarTokenNature . CATEGORY ) ,
161- hideSuggestion : hideSuggestion ,
162158 } ;
163159 }
164160
@@ -169,16 +165,26 @@ async function createSuggestions({
169165 items : [ "minute" , "hour" , "day" , "week" , "month" , "year" ] ,
170166 nature : Array ( 6 ) . fill ( SearchBarTokenNature . VALUE ) ,
171167 type : Array ( 6 ) . fill ( CategoryType . DATE ) ,
172- hideSuggestion : Array ( 6 ) . fill ( previousToken . hideSuggestion ) ,
173168 } ;
174169 }
175170
176- if ( ! previousToken . hideSuggestion ) {
171+ const hideSuggestion = columns . some (
172+ ( column ) =>
173+ column . header === previousEquation . items [ 0 ] . label &&
174+ column . meta ?. isQuasiUnique === true ,
175+ ) ;
176+
177+ if ( ! hideSuggestion ) {
177178 // Load the suggestions for the selected category
179+
180+ /**
181+ * The internal name of the category is used to fetch the job summary
182+ */
178183 const category = fromHumanReadableText (
179184 String ( previousEquation . items [ 0 ] . label ) ,
180185 columns ,
181186 ) ;
187+
182188 await fetchJobSummary ( category ) ;
183189 const items = data . map ( ( item ) =>
184190 String ( item [ category as keyof JobSummary ] ) ,
@@ -188,7 +194,6 @@ async function createSuggestions({
188194 items : items ,
189195 nature : Array ( items . length ) . fill ( SearchBarTokenNature . VALUE ) ,
190196 type : Array ( items . length ) . fill ( previousToken . type ) ,
191- hideSuggestion : Array ( items . length ) . fill ( previousToken . hideSuggestion ) ,
192197 } ;
193198 }
194199 }
@@ -201,58 +206,41 @@ async function createSuggestions({
201206 items : items ,
202207 type : Array ( items . length ) . fill ( CategoryType . STRING ) ,
203208 nature : Array ( items . length ) . fill ( SearchBarTokenNature . OPERATOR ) ,
204- hideSuggestion : Array ( items . length ) . fill (
205- previousToken . hideSuggestion ,
206- ) ,
207209 } ;
208210 case CategoryType . NUMBER :
209211 items = Operators . getNumberOperators ( ) . map ( ( op ) => op . getDisplay ( ) ) ;
210212 return {
211213 items : items ,
212214 type : Array ( items . length ) . fill ( CategoryType . NUMBER ) ,
213215 nature : Array ( items . length ) . fill ( SearchBarTokenNature . OPERATOR ) ,
214- hideSuggestion : Array ( items . length ) . fill (
215- previousToken . hideSuggestion ,
216- ) ,
217216 } ;
218217 case CategoryType . BOOLEAN :
219218 items = Operators . getBooleanOperators ( ) . map ( ( op ) => op . getDisplay ( ) ) ;
220219 return {
221220 items : items ,
222221 type : Array ( items . length ) . fill ( CategoryType . BOOLEAN ) ,
223222 nature : Array ( items . length ) . fill ( SearchBarTokenNature . OPERATOR ) ,
224- hideSuggestion : Array ( items . length ) . fill (
225- previousToken . hideSuggestion ,
226- ) ,
227223 } ;
228224 case CategoryType . DATE :
229225 items = Operators . getDateOperators ( ) . map ( ( op ) => op . getDisplay ( ) ) ;
230226 return {
231227 items : items ,
232228 type : Array ( items . length ) . fill ( CategoryType . DATE ) ,
233229 nature : Array ( items . length ) . fill ( SearchBarTokenNature . OPERATOR ) ,
234- hideSuggestion : Array ( items . length ) . fill (
235- previousToken . hideSuggestion ,
236- ) ,
237230 } ;
238231 case CategoryType . CUSTOM :
239232 items = Operators . getDefaultOperators ( ) . map ( ( op ) => op . getDisplay ( ) ) ;
240233 return {
241234 items : items ,
242235 nature : Array ( items . length ) . fill ( SearchBarTokenNature . OPERATOR ) ,
243236 type : Array ( items . length ) . fill ( CategoryType . CUSTOM ) ,
244- hideSuggestion : Array ( items . length ) . fill (
245- previousToken . hideSuggestion ,
246- ) ,
247237 } ;
248238
249- // We don't want suggestions for the number and in case of a custom token
250239 default :
251240 return {
252241 items : [ ] ,
253242 nature : [ ] ,
254243 type : [ ] ,
255- hideSuggestion : [ ] ,
256244 } ;
257245 }
258246 }
@@ -261,6 +249,5 @@ async function createSuggestions({
261249 items : [ ] ,
262250 nature : [ ] ,
263251 type : [ ] ,
264- hideSuggestion : [ ] ,
265252 } ;
266253}
0 commit comments