@@ -54,6 +54,7 @@ import { InteractionHandler } from '../../interaction/interaction-handler';
5454import { TableWidgetRowInteractionModel } from './selections/table-widget-row-interaction.model' ;
5555import { TableWidgetBaseModel } from './table-widget-base.model' ;
5656import { SpecificationBackedTableColumnDef } from './table-widget-column.model' ;
57+ import { TableWidgetControlSelectOptionModel } from './table-widget-control-select-option.model' ;
5758import { TableWidgetViewToggleModel } from './table-widget-view-toggle.model' ;
5859import { TableWidgetModel } from './table-widget.model' ;
5960
@@ -232,39 +233,51 @@ export class TableWidgetRendererComponent
232233 . filter ( selectControlModel => selectControlModel . visible )
233234 . map ( selectControlModel => {
234235 if ( selectControlModel . placeholder === changed ?. placeholder ) {
235- return of ( changed ) ;
236+ return this . buildTableSelectControl ( selectControlModel , changed ) ;
236237 }
237238
238- // Fetch the values for the selectFilter dropdown
239- return selectControlModel . getOptions ( ) . pipe (
240- take ( 1 ) ,
241- withLatestFrom ( this . selectFilterSubject ) ,
242- map ( ( [ options , filters ] ) => {
243- const foundPreferences = preferences . selections
244- ? preferences . selections . find (
245- preferencesSelectionControl =>
246- selectControlModel . placeholder === preferencesSelectionControl . placeholder
247- )
248- : undefined ;
239+ const foundPreferences = preferences . selections
240+ ? preferences . selections . find (
241+ preferencesSelectionControl =>
242+ selectControlModel . placeholder === preferencesSelectionControl . placeholder
243+ )
244+ : undefined ;
249245
250- return (
251- foundPreferences ?? {
252- placeholder : selectControlModel . placeholder ,
253- isMultiSelect : selectControlModel . isMultiselect ,
254- options : options . map ( option => ( {
255- ...option ,
256- applied : this . isFilterApplied ( option . metaValue , filters )
257- } ) )
258- }
259- ) ;
260- } )
261- ) ;
246+ // Fetch the values for the selectFilter dropdown
247+ return this . buildTableSelectControl ( selectControlModel , foundPreferences ) ;
262248 } )
263249 )
264250 )
265251 ) ;
266252 }
267253
254+ private buildTableSelectControl (
255+ model : TableWidgetControlSelectOptionModel ,
256+ override ?: TableSelectControl
257+ ) : Observable < TableSelectControl > {
258+ return model . getOptions ( ) . pipe (
259+ take ( 1 ) ,
260+ withLatestFrom ( this . selectFilterSubject ) ,
261+ map ( ( [ options , filters ] ) => {
262+ const mergedOptions = options . map ( option => {
263+ const found = override ?. options . find ( o => o . label === option . label ) ;
264+
265+ return {
266+ ...option ,
267+ applied : found ?. applied || this . isFilterApplied ( option . metaValue , filters )
268+ } ;
269+ } ) ;
270+
271+ return {
272+ placeholder : model . placeholder ,
273+ prefix : `${ model . placeholder } : ` ,
274+ isMultiSelect : model . isMultiselect ,
275+ options : mergedOptions
276+ } ;
277+ } )
278+ ) ;
279+ }
280+
268281 private isFilterApplied ( filterOption : TableFilter , appliedFilters : TableFilter [ ] ) : boolean {
269282 // This gets just a little tricky because multiple options for a single select could be IN filtered together
270283 return (
0 commit comments