Skip to content

Commit

Permalink
Refactor adding filters to handle array values efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
guidomodarelli committed Oct 17, 2024
1 parent 13bd581 commit 81862f9
Showing 1 changed file with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,29 @@ export const onFilterCellActions = (
setFilters: (filters: Filter[]) => void,
) => {
return (field: string, operation: FILTER_OPERATOR, value?: any) => {
const newFilter = PatternDataSourceFilterManager.createFilter(
operation,
field,
value,
indexPatternId,
);
setFilters([...filters, newFilter]);
const newFilters: Filter[] = [];
if (Array.isArray(value)) {
value.forEach(item => {
newFilters.push(
PatternDataSourceFilterManager.createFilter(
operation,
field,
item,
indexPatternId,
),
);
});
} else {
newFilters.push(
PatternDataSourceFilterManager.createFilter(
operation,
field,
value,
indexPatternId,
),
);
}
setFilters([...filters, ...newFilters]);
};
};

Expand Down

0 comments on commit 81862f9

Please sign in to comment.