Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Exclusion filter does not filter out 'null' #869

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import { Binary } from "../../../common/utils/functional/functional";
import { StringValue } from "./string-value";
import "./string-values-list.scss";

function filterRows(rows: string[], searchText: string): string[] {
function filterRows(rows: Array<unknown>, searchText: string): Array<unknown> {
if (!searchText) return rows;
const searchTextLower = searchText.toLowerCase();
return rows.filter(d => d.toLowerCase().indexOf(searchTextLower) !== -1);
return rows.filter(d => String(d).toLowerCase().indexOf(searchTextLower) !== -1);
}

function prependPromotedValues(rows: string[], promoted: Set<string>): string[] {
function prependPromotedValues(rows: Array<unknown>, promoted: Set<unknown>): Array<unknown> {
return [
...promoted,
...rows.filter(value => !promoted.contains(value))
Expand All @@ -40,15 +40,15 @@ interface RowsListProps {
dimension: Dimension;
dataset: Dataset;
searchText: string;
selectedValues: Set<string>;
promotedValues: Set<string>;
selectedValues: Set<unknown>;
promotedValues: Set<unknown>;
filterMode: FilterMode;
onRowSelect: Binary<unknown, boolean, void>;
}

export const StringValuesList: React.SFC<RowsListProps> = props => {
const { onRowSelect, filterMode, dataset, dimension, searchText, promotedValues, selectedValues } = props;
const rowValues = dataset.data.map(d => String(d[dimension.name]));
const rowValues: Array<unknown> = dataset.data.map(d => d[dimension.name]);
const values = prependPromotedValues(rowValues, promotedValues);
const matchingValues = filterRows(values, searchText);
if (searchText && matchingValues.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/formatter/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function getFormattedStringClauseValues({ values, action }: StringFilterClause):
case StringFilterAction.CONTAINS:
return `"${values.first()}"`;
case StringFilterAction.IN:
return values.count() > 1 ? `(${values.count()})` : values.first();
return values.count() > 1 ? `(${values.count()})` : String(values.first());
}
}

Expand Down