Skip to content

Commit

Permalink
Rename FilterModel to GridFilterModel
Browse files Browse the repository at this point in the history
  • Loading branch information
DanailH committed Mar 26, 2021
1 parent 5ec0ff4 commit 094feb1
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import { DataGrid, FilterModel, GridToolbar } from '@material-ui/data-grid';
import { DataGrid, GridFilterModel, GridToolbar } from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

const riceFilterModel: FilterModel = {
const riceFilterModel: GridFilterModel = {
items: [{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' }],
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FilterModel, GridLinkOperator, XGrid } from '@material-ui/x-grid';
import { GridFilterModel, GridLinkOperator, XGrid } from '@material-ui/x-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';
import * as React from 'react';

const filterModel: FilterModel = {
const filterModel: GridFilterModel = {
items: [
{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ columnField: 'commodity', operatorValue: 'startsWith', value: 'soy' },
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/data-grid/filtering/filtering.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ The default operator that will be applied between filters is an And.
To change the default operator, you should set the 'linkOperator' property of the filterModel like below.

```ts
const filterModel: FilterModel = {
const filterModel: GridFilterModel = {
items: [
{ columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ columnField: 'commodity', operatorValue: 'startsWith', value: 'Soy' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export interface GridFilterModelState {
linkOperator?: GridLinkOperator;
}

export type FilterModel = GridFilterModelState;
export type GridFilterModel = GridFilterModelState;

export const getInitialGridFilterState: () => GridFilterModelState = () => ({
items: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useGridState } from '../core/useGridState';
import { GridPreferencePanelsValue } from '../preferencesPanel/gridPreferencePanelsValue';
import { sortedGridRowsSelector } from '../sorting/gridSortingSelector';
import {
FilterModel,
GridFilterModel,
GridFilterModelState,
getInitialGridFilterState,
} from './gridFilterModelState';
Expand Down Expand Up @@ -250,7 +250,7 @@ export const useGridFilter = (apiRef: GridApiRef, rowsProp: GridRowsProp): void
}, [clearFilteredRows, logger, setGridState]);

const setFilterModel = React.useCallback(
(model: FilterModel) => {
(model: GridFilterModel) => {
clearFilterModel();
logger.debug('Setting filter model');
applyFilterLinkOperator(model.linkOperator);
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/_modules_/grid/models/api/filterApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FilterModel } from '../../hooks/features/filter/gridFilterModelState';
import { GridFilterModel } from '../../hooks/features/filter/gridFilterModelState';
import { GridFilterItem, GridLinkOperator } from '../gridFilterItem';
import { GridRowModel } from '../gridRows';
import { GridFilterModelParams } from '../params/gridFilterModelParams';
Expand All @@ -12,6 +12,6 @@ export interface FilterApi {
deleteFilter: (item: GridFilterItem) => void;
applyFilterLinkOperator: (operator: GridLinkOperator) => void;
onFilterModelChange: (handler: (params: GridFilterModelParams) => void) => void;
setFilterModel: (model: FilterModel) => void;
setFilterModel: (model: GridFilterModel) => void;
getVisibleRowModels: () => GridRowModel[];
}
4 changes: 2 additions & 2 deletions packages/grid/_modules_/grid/models/gridOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { GRID_DEFAULT_LOCALE_TEXT } from '../constants/localeTextConstants';
import { FilterModel } from '../hooks/features/filter/gridFilterModelState';
import { GridFilterModel } from '../hooks/features/filter/gridFilterModelState';
import { Logger } from '../hooks/utils/useLogger';
import { GridLocaleText } from './api/gridLocaleTextApi';
import { GridColumnTypesRecord } from './colDef/gridColTypeDef';
Expand Down Expand Up @@ -133,7 +133,7 @@ export interface GridOptions {
/**
* Set the filter model of the grid.
*/
filterModel?: FilterModel;
filterModel?: GridFilterModel;
/**
* Set the height in pixel of the column headers in the grid.
* @default 56
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FilterModel } from '../../hooks/features/filter/gridFilterModelState';
import { GridFilterModel } from '../../hooks/features/filter/gridFilterModelState';
import { GridColumns } from '../colDef/gridColDef';
import { GridRowModel } from '../gridRows';

Expand All @@ -9,7 +9,7 @@ export interface GridFilterModelParams {
/**
* The filter model.
*/
filterModel: FilterModel;
filterModel: GridFilterModel;
/**
* The full set of columns.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/grid/x-grid/src/tests/filtering.XGrid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from 'chai';
import { useFakeTimers } from 'sinon';
import {
GridApiRef,
FilterModel,
GridFilterModel,
GridComponentProps,
GridLinkOperator,
GridPreferencePanelsValue,
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('<XGrid /> - Filter', () => {
});

it('should allow multiple filter and changing the linkOperator', () => {
const newModel: FilterModel = {
const newModel: GridFilterModel = {
items: [
{
columnField: 'brand',
Expand All @@ -198,7 +198,7 @@ describe('<XGrid /> - Filter', () => {
});

it('should only select visible rows', () => {
const newModel: FilterModel = {
const newModel: GridFilterModel = {
items: [
{
columnField: 'brand',
Expand All @@ -215,7 +215,7 @@ describe('<XGrid /> - Filter', () => {
});

it('should allow to clear filters by passing an empty filter model', () => {
const newModel: FilterModel = {
const newModel: GridFilterModel = {
items: [
{
columnField: 'brand',
Expand Down
6 changes: 3 additions & 3 deletions packages/storybook/src/stories/grid-filter.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GridColTypeDef,
GridFilterInputValueProps,
GridFilterItem,
FilterModel,
GridFilterModel,
GridFilterModelParams,
getGridNumericColumnOperators,
GridLinkOperator,
Expand Down Expand Up @@ -221,7 +221,7 @@ export function CommodityNoToolbar() {
export function ServerFilterViaProps() {
const demoServer = useDemoData({ dataSet: 'Commodity', rowLength: 100 });
const [rows, setRows] = React.useState<GridRowModel[]>(demoServer.data.rows);
const [filterModel, setFilterModel] = React.useState<FilterModel>({
const [filterModel, setFilterModel] = React.useState<GridFilterModel>({
items: [{ id: 123, columnField: 'commodity', value: 'soy', operatorValue: 'contains' }],
});
const [loading, setLoading] = React.useState(false);
Expand Down Expand Up @@ -623,7 +623,7 @@ export function DemoCustomRatingFilterOperator() {
);
}

const demoFilterModel: FilterModel = {
const demoFilterModel: GridFilterModel = {
items: [
{ id: 123, columnField: 'commodity', operatorValue: 'contains', value: 'rice' },
{ id: 12, columnField: 'quantity', operatorValue: '>=', value: '20000' },
Expand Down

0 comments on commit 094feb1

Please sign in to comment.