trithuc-mvc-react 1.5.3 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/DataManagement/EditorDialog.jsx +2 -2
- package/components/DataManagement/EditorForm.jsx +6 -4
- package/components/DataManagement/FilterGod.jsx +73 -74
- package/components/DataManagement/FormField.jsx +2 -1
- package/components/DataManagement/TableHead.jsx +7 -8
- package/components/DataManagement/TableRowRender.jsx +11 -6
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ function EditorDialog({ open, onClose = () => {}, defaultValues = {}, fields = [
|
|
|
31
31
|
};
|
|
32
32
|
const submitRef = useRef();
|
|
33
33
|
return (
|
|
34
|
-
<Dialog open={open} onClose={onClose} maxWidth="
|
|
34
|
+
<Dialog open={open} onClose={onClose} maxWidth="md" fullWidth={true} scroll={'body'}>
|
|
35
35
|
<DialogTitle>
|
|
36
36
|
{defaultValues?.Id ? "Cập nhật" : "Thêm mới"}
|
|
37
37
|
<IconButton
|
|
@@ -48,7 +48,7 @@ function EditorDialog({ open, onClose = () => {}, defaultValues = {}, fields = [
|
|
|
48
48
|
</IconButton>
|
|
49
49
|
</DialogTitle>
|
|
50
50
|
<DialogContent dividers={true}>
|
|
51
|
-
<EditorForm fields={fields} submitRef={submitRef}
|
|
51
|
+
<EditorForm fields={fields} submitRef={submitRef} />
|
|
52
52
|
</DialogContent>
|
|
53
53
|
<DialogActions>
|
|
54
54
|
<Button onClick={onClose}>Đóng</Button>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box } from "@mui/material";
|
|
1
|
+
import { Box, useTheme, useMediaQuery } from "@mui/material";
|
|
2
2
|
import { FormProvider, useForm } from "react-hook-form";
|
|
3
3
|
import Grid from "@mui/material/Unstable_Grid2"; // Grid version 2
|
|
4
4
|
import PropTypes from "prop-types";
|
|
@@ -15,12 +15,14 @@ import { yupResolver } from "@hookform/resolvers/yup";
|
|
|
15
15
|
EditorForm.propTypes = {
|
|
16
16
|
fields: PropTypes.array
|
|
17
17
|
};
|
|
18
|
-
function EditorForm({ fields,
|
|
18
|
+
function EditorForm({ fields, submitRef }) {
|
|
19
19
|
const queryClient = useQueryClient();
|
|
20
20
|
const { tableName, selectedEditItem, setOpenEditorDialog, validationSchema } = useDataTable();
|
|
21
21
|
|
|
22
22
|
const methods = useForm({ defaultValues: {}, resolver: yupResolver(validationSchema) });
|
|
23
|
-
|
|
23
|
+
const theme = useTheme();
|
|
24
|
+
const downXl = useMediaQuery(theme.breakpoints.down("xl"));
|
|
25
|
+
const elementSize = downXl ? "small": "medium";
|
|
24
26
|
useEffect(() => {
|
|
25
27
|
if (selectedEditItem) {
|
|
26
28
|
methods.setValue("Id", selectedEditItem.Id);
|
|
@@ -90,7 +92,7 @@ function EditorForm({ fields, elementSize = "medium", submitRef }) {
|
|
|
90
92
|
};
|
|
91
93
|
return (
|
|
92
94
|
<FormProvider {...methods}>
|
|
93
|
-
<Box component={"form"}
|
|
95
|
+
<Box component={"form"} onSubmit={methods.handleSubmit(onSubmit)}>
|
|
94
96
|
<Grid container spacing={2}>
|
|
95
97
|
{fields.map(
|
|
96
98
|
({
|
|
@@ -1,92 +1,91 @@
|
|
|
1
|
-
import { Slider, Toolbar } from "@mui/material";
|
|
1
|
+
import { Accordion, AccordionSummary, Box, FormControl, InputLabel, MenuItem, Select, Slider, Toolbar, Typography } from "@mui/material";
|
|
2
2
|
import { useFormContext } from "react-hook-form";
|
|
3
3
|
import Grid from "@mui/material/Unstable_Grid2";
|
|
4
4
|
import DateRangePicker from "../date/DateRangePicker";
|
|
5
5
|
import { FilterElement } from "./FilterElement";
|
|
6
6
|
import { useDataTable } from "./hooks";
|
|
7
7
|
|
|
8
|
+
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
9
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
10
|
+
|
|
8
11
|
export const FilterGod = ({ filters, elementSize = "small" }) => {
|
|
9
12
|
const { handleSubmit } = useFormContext();
|
|
10
13
|
const onSubmit = (data) => console.log(data);
|
|
11
14
|
const { setDataSearch, dataSearch } = useDataTable();
|
|
12
15
|
|
|
13
16
|
return (
|
|
14
|
-
<
|
|
17
|
+
<Box
|
|
15
18
|
component={"form"}
|
|
16
|
-
disableGutters
|
|
17
19
|
onSubmit={handleSubmit(onSubmit)}
|
|
18
|
-
sx={{
|
|
19
|
-
px: 1,
|
|
20
|
-
my: elementSize == "small" ? 0 : 2,
|
|
21
|
-
display: "flex",
|
|
22
|
-
alignItems: "center"
|
|
23
|
-
}}
|
|
24
20
|
>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
21
|
+
<Accordion>
|
|
22
|
+
<AccordionSummary
|
|
23
|
+
sx={{
|
|
24
|
+
minHeight: 40,
|
|
25
|
+
'& .MuiAccordionSummary-content': {
|
|
26
|
+
my: 1
|
|
27
|
+
}
|
|
28
|
+
}}
|
|
29
|
+
expandIcon={<ExpandMoreIcon />}
|
|
30
|
+
aria-controls="panel1a-content"
|
|
31
|
+
id="panel1a-header"
|
|
32
|
+
>
|
|
33
|
+
<Typography variant="h6">Tìm kiếm</Typography>
|
|
34
|
+
</AccordionSummary>
|
|
35
|
+
<AccordionDetails>
|
|
36
|
+
<Grid container spacing={1}>
|
|
37
|
+
{filters.map(({ field, size, ...rest }) => {
|
|
38
|
+
if (rest.type === "date-range") {
|
|
39
|
+
return (
|
|
40
|
+
<Grid key={field.toString()} md={size?.md} xs={size?.xs} sm={size?.sm}>
|
|
41
|
+
<DateRangePicker
|
|
42
|
+
onChange={(value) => {
|
|
43
|
+
setDataSearch(({ previousState }) => ({
|
|
44
|
+
...previousState,
|
|
45
|
+
[field[0]]: value[0],
|
|
46
|
+
[field[1]]: value[1]
|
|
47
|
+
}));
|
|
48
|
+
}}
|
|
49
|
+
size={elementSize}
|
|
50
|
+
value={[dataSearch?.[field[0]], dataSearch?.[field[1]]]}
|
|
51
|
+
/>
|
|
52
|
+
</Grid>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
);
|
|
88
|
-
})}
|
|
89
|
-
</Grid>
|
|
90
|
-
</Toolbar>
|
|
56
|
+
if (rest.type === "slider-range") {
|
|
57
|
+
return (
|
|
58
|
+
<Grid
|
|
59
|
+
key={field.toString()}
|
|
60
|
+
md={size?.md} xs={size?.xs} sm={size?.sm}
|
|
61
|
+
>
|
|
62
|
+
<Slider
|
|
63
|
+
onChange={(e, value) => {
|
|
64
|
+
setDataSearch({
|
|
65
|
+
...dataSearch,
|
|
66
|
+
[field[0]]: value[0],
|
|
67
|
+
[field[1]]: value[1]
|
|
68
|
+
});
|
|
69
|
+
}}
|
|
70
|
+
size={elementSize}
|
|
71
|
+
marks={rest.marks}
|
|
72
|
+
defaultValue={rest.defaultValue}
|
|
73
|
+
valueLabelDisplay="auto"
|
|
74
|
+
max={rest.marks[rest.marks.length - 1]?.value}
|
|
75
|
+
step={null}
|
|
76
|
+
/>
|
|
77
|
+
</Grid>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return (
|
|
81
|
+
<Grid key={field} md={size?.md} xs={size?.xs} sm={size?.sm} >
|
|
82
|
+
<FilterElement name={field} {...rest} size={elementSize} />
|
|
83
|
+
</Grid>
|
|
84
|
+
);
|
|
85
|
+
})}
|
|
86
|
+
</Grid>
|
|
87
|
+
</AccordionDetails>
|
|
88
|
+
</Accordion>
|
|
89
|
+
</Box>
|
|
91
90
|
);
|
|
92
91
|
};
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { Checkbox, TableRow, TableCell, TableHead as MuiTableHead } from "@mui/material";
|
|
1
|
+
import { Checkbox, TableRow, TableCell, TableHead as MuiTableHead, useTheme, useMediaQuery } from "@mui/material";
|
|
2
2
|
import { useDataTable, usePermission } from "./hooks";
|
|
3
3
|
export function TableHead({ numSelected, rowCount, onSelectAllClick, headLabel }) {
|
|
4
4
|
const { canEdit } = usePermission();
|
|
5
5
|
const { disableStatus } = useDataTable();
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
const downXl = useMediaQuery(theme.breakpoints.down("xl"));
|
|
6
8
|
return (
|
|
7
9
|
<MuiTableHead sx={{ height: 56, visibility: numSelected > 0 ? "hidden" : "visible" }}>
|
|
8
10
|
<TableRow>
|
|
9
11
|
<TableCell padding="checkbox">
|
|
10
12
|
<Checkbox
|
|
11
13
|
indeterminate={numSelected > 0 && numSelected < rowCount}
|
|
14
|
+
size={downXl?"small":"medium"}
|
|
12
15
|
checked={rowCount > 0 && numSelected === rowCount}
|
|
13
16
|
onChange={onSelectAllClick}
|
|
14
17
|
/>
|
|
15
18
|
</TableCell>
|
|
16
19
|
<TableCell sx={{ textAlign: "center" }}>STT</TableCell>
|
|
17
20
|
{headLabel.map((headCell) => (
|
|
18
|
-
<TableCell
|
|
19
|
-
key={headCell.field}
|
|
20
|
-
align={headCell.alignRight ? "right" : "left"}
|
|
21
|
-
sx={{ textAlign: "center" }}
|
|
22
|
-
>
|
|
21
|
+
<TableCell key={headCell.field} align={headCell.alignRight ? "right" : "left"} sx={{ textAlign: "center" }}>
|
|
23
22
|
{headCell.label}
|
|
24
23
|
</TableCell>
|
|
25
24
|
))}
|
|
26
|
-
{!disableStatus && canEdit && <TableCell sx={{ textAlign: "center"
|
|
27
|
-
<TableCell sx={{ minWidth: "136px", textAlign: "center" }}
|
|
25
|
+
{!disableStatus && canEdit && <TableCell sx={{ textAlign: "center" }}>Kích hoạt</TableCell>}
|
|
26
|
+
<TableCell sx={{ minWidth: "136px", textAlign: "center" }}>Thao tác</TableCell>
|
|
28
27
|
</TableRow>
|
|
29
28
|
</MuiTableHead>
|
|
30
29
|
);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Checkbox, IconButton, Switch, TableCell, TableRow, Tooltip, Toolbar } from "@mui/material";
|
|
1
|
+
import { Checkbox, IconButton, Switch, TableCell, TableRow, Tooltip, Toolbar, useMediaQuery } from "@mui/material";
|
|
2
2
|
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
|
3
3
|
import { EditOutlined } from "@mui/icons-material";
|
|
4
4
|
import { useDataTable, usePermission } from "./hooks";
|
|
5
5
|
|
|
6
6
|
// material
|
|
7
|
-
import { styled } from "@mui/material/styles";
|
|
7
|
+
import { styled, useTheme } from "@mui/material/styles";
|
|
8
8
|
import MoreMenu from "../MoreMenu";
|
|
9
9
|
import { useMemo } from "react";
|
|
10
10
|
|
|
@@ -26,24 +26,29 @@ export const TableRowRender = ({ index, row, selected, onSelect, onChangeStatus,
|
|
|
26
26
|
const tableActionsOnMoreMenu = tableActionsAfterFilter.filter(({ isOnTable = false }) => !isOnTable);
|
|
27
27
|
return { tableActionsOnTable, tableActionsOnMoreMenu };
|
|
28
28
|
}, [canView, canAction, tableActions]);
|
|
29
|
-
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const downXl = useMediaQuery(theme.breakpoints.down("xl"));
|
|
30
31
|
return (
|
|
31
32
|
<TableRow hover key={row[selectedField]} selected={selected}>
|
|
32
33
|
<TableCell padding="checkbox">
|
|
33
|
-
<Checkbox
|
|
34
|
+
<Checkbox
|
|
35
|
+
checked={selected}
|
|
36
|
+
size={downXl ? "small" : "medium"}
|
|
37
|
+
onChange={(event) => onSelect(event, row[selectedField])}
|
|
38
|
+
/>
|
|
34
39
|
</TableCell>
|
|
35
40
|
<TableCell align="center">{index + 1}</TableCell>
|
|
36
41
|
{columns.map(
|
|
37
42
|
({
|
|
38
43
|
field,
|
|
39
|
-
type="text",
|
|
44
|
+
type = "text",
|
|
40
45
|
valueGetter = (row) => {
|
|
41
46
|
return row[field];
|
|
42
47
|
},
|
|
43
48
|
renderCell,
|
|
44
49
|
valueFormat = (e) => e
|
|
45
50
|
}) => {
|
|
46
|
-
let align =
|
|
51
|
+
let align = type == "image" || type == "number" || type == "date" || type == "datetime" ? "right" : "left";
|
|
47
52
|
return (
|
|
48
53
|
<TableCell key={`${row[selectedField]}-${field}`} align={align}>
|
|
49
54
|
{renderCell ? renderCell(row) : valueFormat(valueGetter(row))}
|