-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added badge and toolti[ * refactor on filters and columns * add disableMultipleColumnsFiltering * fix double click on switch * fix classname * cleanup * review * public component * fix toolbar style * yarn prettier * added icon column reorder * fix transition in column menu * fix scroll issue on doc * Refactor panel, fix opening Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
- Loading branch information
1 parent
52d39e2
commit d523270
Showing
30 changed files
with
380 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/grid/_modules_/grid/components/menu/columnMenu/FilterMenuItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/grid/_modules_/grid/components/menu/columnMenu/SortMenuItems.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/grid/_modules_/grid/components/toolbar/FilterToolbarButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Badge from '@material-ui/core/Badge'; | ||
import Button from '@material-ui/core/Button'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
import * as React from 'react'; | ||
import { columnLookupSelector } from '../../hooks/features/columns/columnsSelector'; | ||
import { useGridSelector } from '../../hooks/features/core/useGridSelector'; | ||
import { | ||
activeFilterItemsSelector, | ||
filterItemsCounterSelector, | ||
} from '../../hooks/features/filter/filterSelector'; | ||
import { useIcons } from '../../hooks/utils/useIcons'; | ||
import { optionsSelector } from '../../hooks/utils/useOptionsProp'; | ||
import { ApiContext } from '../api-context'; | ||
|
||
export const FilterToolbarButton: React.FC<{}> = () => { | ||
const apiRef = React.useContext(ApiContext); | ||
const options = useGridSelector(apiRef, optionsSelector); | ||
const counter = useGridSelector(apiRef, filterItemsCounterSelector); | ||
const activeFilters = useGridSelector(apiRef, activeFilterItemsSelector); | ||
const lookup = useGridSelector(apiRef, columnLookupSelector); | ||
const tooltipContentNode = React.useMemo(() => { | ||
if (counter === 0) { | ||
return 'Show Filters'; | ||
} | ||
return ( | ||
<div> | ||
{counter} active filter(s) | ||
<ul> | ||
{activeFilters.map((item) => ( | ||
<li key={item.id}> | ||
{lookup[item.columnField!].headerName || item.columnField} {item.operatorValue}{' '} | ||
{item.value} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}, [counter, activeFilters, lookup]); | ||
|
||
const icons = useIcons(); | ||
const filterIconElement = React.createElement(icons.ColumnFiltering!, {}); | ||
const showFilter = React.useCallback(() => { | ||
apiRef!.current.showFilterPanel(); | ||
}, [apiRef]); | ||
|
||
if (options.disableColumnFilter) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Tooltip title={tooltipContentNode} enterDelay={1000}> | ||
<Button | ||
onClick={showFilter} | ||
color="primary" | ||
aria-label="Show Filters" | ||
startIcon={ | ||
<Badge badgeContent={counter} color="primary"> | ||
{filterIconElement} | ||
</Badge> | ||
} | ||
> | ||
Filters | ||
</Button> | ||
</Tooltip> | ||
); | ||
}; |
28 changes: 0 additions & 28 deletions
28
packages/grid/_modules_/grid/components/toolbar/filterToolbarButton.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.