improve some option in reset table

This commit is contained in:
2024-05-06 17:19:11 +03:30
parent b40c19fb34
commit 3ccd198a72
7 changed files with 71 additions and 15 deletions

View File

@@ -1,6 +1,17 @@
import { Popper, Paper, List, ListItem, ListItemText, ClickAwayListener } from '@mui/material';
import {ClickAwayListener, List, ListItem, ListItemText, Paper, Popper} from '@mui/material';
function FilterBox({anchorEl , open = false, handleClose = () => {} , columnFilterModeOptions , onSelectFilter , defaultFilter}) {
const columnFilterModeOptionFa = {
equals: "برابر",
notEquals: "نابرابر",
contains: "شامل",
lessThan: "کوچکتر",
greaterThan: "بزرگتر",
}
function FilterBox({
anchorEl, open = false, handleClose = () => {
}, columnFilterModeOptions, onSelectFilter, defaultFilter
}) {
const id = open ? 'simple-popper' : undefined;
const handleSelectFilter = (filterFn) => {
@@ -10,13 +21,14 @@ function FilterBox({anchorEl , open = false, handleClose = () => {} , columnFilt
return (
<div>
<Popper id={id} open={open} anchorEl={anchorEl} placement="bottom" style={{ zIndex: 1301 }}>
<Popper id={id} open={open} anchorEl={anchorEl} placement="bottom" style={{zIndex: 1301}}>
<ClickAwayListener onClickAway={handleClose}>
<Paper>
<List>
{columnFilterModeOptions.map((option, index) => (
<ListItem key={index} onClick={() => handleSelectFilter(option)} selected={option === defaultFilter} sx={{ cursor: 'pointer' }}>
<ListItemText primary={option} />
<ListItem key={index} onClick={() => handleSelectFilter(option)}
selected={option === defaultFilter} sx={{cursor: 'pointer'}}>
<ListItemText primary={columnFilterModeOptionFa[option]}/>
</ListItem>
))}
</List>

View File

@@ -19,7 +19,7 @@ const DataTable_TableHeadRow = ({
const {virtualColumns, virtualPaddingLeft, virtualPaddingRight} =
columnVirtualizer ?? {};
const backgroundColor = index % 2 === 0 ? '#2070af' : '#ff5c0f';
const backgroundColor = index % 2 === 0 ? '#015688' : '#ff5c0f';
const tableRowProps = {
...parseFromValuesOrFunc(muiTableHeadRowProps, {

View File

@@ -0,0 +1,28 @@
"use client"
import {IconButton, Tooltip} from '@mui/material';
import RestartAltIcon from '@mui/icons-material/RestartAlt';
import useTableSetting from "@/lib/hooks/useTableSetting";
import {useState} from "react";
function RefactorTable() {
const {refactorAction} = useTableSetting();
const [userId, setUserId] = useState(2);
const [pageName, setPageName] = useState('loan');
const [tableName, setTableName] = useState('loan_table');
const refactor = () => {
refactorAction(userId, pageName, tableName);
};
return (
<Tooltip title="بازنشانی اطلاعات">
<IconButton onClick={refactor} aria-label="refactor table">
<RestartAltIcon/>
</IconButton>
</Tooltip>
);
}
export default RefactorTable;

View File

@@ -4,6 +4,7 @@ import DataTable_LinearProgressBar from "./LinearProgressBar";
import DataTable_TablePagination from "./TablePagination";
import DataTable_ToolbarInternalButtons from "./ToolbarInternalButtons";
import FilterColumn from "@/core/components/DataTable/filter/FilterColumn";
import RefactorTable from "@/core/components/DataTable/refactor/RefactorTable";
const DataTable_TopToolbar = ({table, columns}) => {
const {
@@ -71,6 +72,7 @@ const DataTable_TopToolbar = ({table, columns}) => {
justifyContent: 'flex-end',
}}
>
<RefactorTable/>
<FilterColumn columns={columns}/>
<DataTable_ToolbarInternalButtons table={table}/>
</Box>