You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought it would be nice to add this feature to the filter manager to keep track of selected filters.
One use case is to be able to add a list of selected filters somewhere on the page.
It could also be used to refactor some other methods that are doing calculations to see which filters are selected.
I am doing it this way, as a sample
// add a getter method for selected filters to manager prototypeObject.defineProperty(manager,'selectedFilters',{get: function(){constselectedFilters=[];this.filters.forEach(filter=>{if(FilterManager.isKlevuFilterResultOptions(filter)||FilterManager.isKlevuFilterResultRating(filter)){constselected=filter.options.filter(subOption=>subOption.selected===true);if(selected.length===0){return;}for(constoptionofselected){selectedFilters.push({key: filter.key,label: filter.label,type: filter.type,value: option.value,});}}elseif(FilterManager.isKlevuFilterResultSlider(filter)){if(!filter.start||!filter.end){return;}selectedFilters.push({key: filter.key,label: filter.label,type: filter.type,value: `${filter.start}-${filter.end}`});}});returnselectedFilters;}});
I thought it would be nice to add this feature to the filter manager to keep track of selected filters.
One use case is to be able to add a list of selected filters somewhere on the page.
It could also be used to refactor some other methods that are doing calculations to see which filters are selected.
I am doing it this way, as a sample
Then we can use it like
The text was updated successfully, but these errors were encountered: