Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk committed May 29, 2023
1 parent 8183aaa commit aa90c79
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
GridQuickFilterValueResult,
} from './gridFilterState';
import { buildWarning } from '../../../utils/warning';
import { gridColumnFieldsSelector, gridColumnLookupSelector } from '../columns';
import { gridFilterableColumnLookupSelector, gridColumnLookupSelector } from '../columns';

type GridFilterItemApplier =
| {
Expand Down Expand Up @@ -281,25 +281,22 @@ const buildAggregatedQuickFilterApplier = (
return null;
}

const columnsFields = gridColumnFieldsSelector(apiRef);
const columnsByField = gridFilterableColumnLookupSelector(apiRef);

const appliersPerField = [] as {
field: string;
column: GridColDef;
appliers: {
v7: boolean;
fn: null | ((...args: any[]) => boolean);
}[];
}[];

columnsFields.forEach((field) => {
const column = apiRef.current.getColumn(field);
Object.values(columnsByField).forEach((column) => {
const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
const getApplyQuickFilterFnV7 = column?.getApplyQuickFilterFnV7;

if (getApplyQuickFilterFnV7) {
appliersPerField.push({
field,
column,
appliers: quickFilterValues.map((value) => ({
v7: true,
Expand All @@ -308,7 +305,6 @@ const buildAggregatedQuickFilterApplier = (
});
} else if (getApplyQuickFilterFn) {
appliersPerField.push({
field,
column,
appliers: quickFilterValues.map((value) => ({
v7: false,
Expand All @@ -318,15 +314,16 @@ const buildAggregatedQuickFilterApplier = (
}
});

return (row, shouldApplyFilter) => {
return function isRowMatchingQuickFilter(row, shouldApplyFilter) {
const result = {} as GridQuickFilterValueResult;
const usedCellParams = {} as { [field: string]: GridCellParams };

outer: for (let v = 0; v < quickFilterValues.length; v += 1) {
const filterValue = quickFilterValues[v];

for (let i = 0; i < appliersPerField.length; i += 1) {
const { field, column, appliers } = appliersPerField[i];
const { column, appliers } = appliersPerField[i];
const { field } = column;

if (shouldApplyFilter && !shouldApplyFilter(field)) {
continue;
Expand Down

0 comments on commit aa90c79

Please sign in to comment.