trithuc-mvc-react 2.5.0 → 2.5.1

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.
@@ -13,7 +13,7 @@ import { TableRowRender } from "./TableRowRender";
13
13
  import TableToolbar from "./TableToolbar";
14
14
  import { useDataTable } from "./hooks";
15
15
  import { usePermission } from "../../hooks";
16
- const DataTable = ({ multipleActions = [],page, setPage = () => { }, disableEdit }) => {
16
+ const DataTable = ({ multipleActions = [],page, setPage = () => { }, disableEdit, disableDelete }) => {
17
17
  const {
18
18
  tableName,
19
19
  selectedField,
@@ -210,6 +210,7 @@ const DataTable = ({ multipleActions = [],page, setPage = () => { }, disableEdit
210
210
  onSelect={handleSelect}
211
211
  onEdit={handlEdit}
212
212
  disableEdit={disableEdit}
213
+ disableDelete={disableDelete}
213
214
  onView={handlViewDetail}
214
215
  onChangeStatus={handleChangeStatus}
215
216
  onDelete={handleDelete}
@@ -1,10 +1,19 @@
1
- import { Autocomplete, FormControl, InputAdornment, InputLabel, MenuItem, OutlinedInput, Select, TextField } from "@mui/material";
2
- import { useCallback, useMemo } from "react";
1
+ import {
2
+ Autocomplete,
3
+ FormControl,
4
+ IconButton,
5
+ InputAdornment,
6
+ InputLabel,
7
+ MenuItem,
8
+ Select,
9
+ TextField
10
+ } from "@mui/material";
11
+ import { useCallback } from "react";
3
12
  import { SearchOutlined } from "@mui/icons-material";
4
13
  import { useController, useFormContext } from "react-hook-form";
5
14
  import { debounce } from "lodash";
6
15
  import { useDataTable } from "./hooks";
7
-
16
+ import ClearIcon from "@mui/icons-material/Clear";
8
17
  export function FilterElement({
9
18
  name,
10
19
  type,
@@ -14,10 +23,10 @@ export function FilterElement({
14
23
  childrenFields,
15
24
  datas,
16
25
  loading = false,
17
- onChange = () => { },
26
+ onChange = () => {},
18
27
  size = "small",
19
- handleChange = () => { },
20
- setPage = () => { },
28
+ handleChange = () => {},
29
+ setPage = () => {}
21
30
  }) {
22
31
  const { control, setValue } = useFormContext();
23
32
 
@@ -33,7 +42,11 @@ export function FilterElement({
33
42
  }, 500),
34
43
  [dataSearch]
35
44
  );
36
-
45
+ const handleClearIconClick = () => {
46
+ onFieldChange(""); // Clear the field value
47
+ handleFilterChangeDebounce(name, ""); // Clear the filter value
48
+ setPage(0);
49
+ };
37
50
  switch (type) {
38
51
  case "search":
39
52
  return (
@@ -53,6 +66,15 @@ export function FilterElement({
53
66
  <InputAdornment position="start">
54
67
  <SearchOutlined />
55
68
  </InputAdornment>
69
+ ),
70
+ endAdornment: (
71
+ <InputAdornment position="end">
72
+ {value && (
73
+ <IconButton onClick={handleClearIconClick}>
74
+ <ClearIcon />
75
+ </IconButton>
76
+ )}
77
+ </InputAdornment>
56
78
  )
57
79
  }}
58
80
  />
@@ -71,7 +93,7 @@ export function FilterElement({
71
93
  noOptionsText="Không có dữ liệu"
72
94
  fullWidth
73
95
  options={datas ?? []}
74
- onChange={(event, newValue, reason) => {
96
+ onChange={(event, newValue) => {
75
97
  let updateObject = { [name]: newValue?.[keyValue] };
76
98
  onFieldChange(newValue?.[keyValue]);
77
99
  onChange(newValue);
@@ -23,6 +23,7 @@ export const TableRowRender = ({
23
23
  onEdit,
24
24
  onView,
25
25
  disableEdit,
26
+ disableDelete
26
27
  }) => {
27
28
  const { selectedField, columns, statusKey, disableStatus, tableActions, disableCellThaoTac, tableName, sttLuyKe } =
28
29
  useDataTable();
@@ -111,7 +112,7 @@ export const TableRowRender = ({
111
112
  </IconButton>
112
113
  </Tooltip>
113
114
  )}
114
- {canDelete && (
115
+ {!disableDelete && (
115
116
  <Tooltip title="Xóa">
116
117
  <IconButton
117
118
  size={downXl ? "small" : "medium"}
@@ -210,7 +210,7 @@ function DataManagement({
210
210
  {tabPanel}
211
211
  <FilterGod filters={filters} elementSize={elementSize} setPage={setPage} />
212
212
  {backParentNavigator}
213
- <DataTable multipleActions={multipleActions} page={page} setPage={setPage} disableEdit={disableEditor}/>
213
+ <DataTable multipleActions={multipleActions} page={page} setPage={setPage} disableEdit={disableEditor} disableDelete = {disableEditor}/>
214
214
  </Card>
215
215
  </FormProvider>
216
216
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trithuc-mvc-react",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"