@@ -31,6 +31,7 @@ import type { DimensionThresholdFilter } from "../../dashboards/stores/explore-s
3131import { convertExpressionToFilterParam } from "../../dashboards/url-state/filters/converters" ;
3232import { FilterManager , type UIFilters } from "./filter-manager" ;
3333import { getDimensionDisplayName } from "../../dashboards/filters/getDisplayName" ;
34+ import { eventBus } from "@rilldata/web-common/lib/event-bus/event-bus" ;
3435
3536export type ParsedFilters = ReturnType < typeof initFilterBase > ;
3637
@@ -280,27 +281,46 @@ export class FilterState {
280281 ) ?? - 1 ;
281282 let expr = wf . cond ?. exprs ?. [ exprIndex ] ;
282283
283- const wasLikeFilter =
284- expr ?. cond ?. op === V1Operation . OPERATION_LIKE ||
285- expr ?. cond ?. op === V1Operation . OPERATION_NLIKE ;
286-
287- if ( ! expr ?. cond ?. exprs || wasLikeFilter ) {
288- expr = createInExpression ( dimensionName , [ ] , exclude ) ;
284+ if ( ! expr ?. cond ?. exprs ) {
285+ expr = createInExpression ( dimensionName , dimensionValues , exclude ) ;
289286 wf . cond ?. exprs ?. push ( expr ) ;
290287 exprIndex = wf . cond ! . exprs ! . length - 1 ;
291- }
292-
293- const wasInListFilter = dimensionsWithInListFilter . includes ( dimensionName ) ;
294- if ( wasInListFilter ) {
295- dimensionsWithInListFilter . filter ( ( d ) => d !== dimensionName ) ;
296- }
297-
298- dimensionValues . forEach ( ( dimensionValue ) => {
299- toggleDimensionFilterValue ( expr , dimensionValue , ! ! isExclusiveFilter ) ;
300- } ) ;
301-
302- if ( expr ?. cond ?. exprs ?. length === 1 ) {
303- wf . cond ?. exprs ?. splice ( exprIndex , 1 ) ;
288+ } else {
289+ const wasLikeFilter =
290+ expr ?. cond ?. op === V1Operation . OPERATION_LIKE ||
291+ expr ?. cond ?. op === V1Operation . OPERATION_NLIKE ;
292+
293+ const wasInListFilter =
294+ dimensionsWithInListFilter . includes ( dimensionName ) ;
295+
296+ if ( wasLikeFilter || wasInListFilter ) {
297+ eventBus . emit ( "notification" , {
298+ message : "Converted filter type to Select" ,
299+ link : {
300+ text : "Undo" ,
301+ href : window . location . href ,
302+ } ,
303+ } ) ;
304+
305+ expr = createInExpression ( dimensionName , dimensionValues , exclude ) ;
306+ wf . cond ?. exprs ?. splice ( exprIndex , 1 , expr ) ;
307+
308+ if ( wasInListFilter ) {
309+ dimensionsWithInListFilter . filter ( ( d ) => d !== dimensionName ) ;
310+ }
311+ } else if ( expr ) {
312+ dimensionValues . forEach ( ( dimensionValue ) => {
313+ toggleDimensionFilterValue (
314+ expr ! ,
315+ dimensionValue ,
316+ ! ! isExclusiveFilter ,
317+ ) ;
318+ } ) ;
319+
320+ if ( expr ?. cond ?. exprs ?. length === 1 ) {
321+ wf . cond ?. exprs ?. splice ( exprIndex , 1 ) ;
322+ }
323+ }
304324 }
305325
306326 return getFilterParam (
0 commit comments