trithuc-mvc-react 2.3.1 → 2.3.3
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.
|
@@ -10,19 +10,32 @@ import MoreMenu from "../MoreMenu";
|
|
|
10
10
|
import { useMemo } from "react";
|
|
11
11
|
|
|
12
12
|
export const TableRowRender = ({ index, row, selected, onSelect, onChangeStatus, onDelete, onEdit, onView }) => {
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
selectedField,
|
|
15
|
+
columns,
|
|
16
|
+
statusKey,
|
|
17
|
+
disableStatus,
|
|
18
|
+
tableActions,
|
|
19
|
+
disableCellThaoTac,
|
|
20
|
+
tableName,
|
|
21
|
+
sttLuyKe,
|
|
22
|
+
backParentNavigator
|
|
23
|
+
} = useDataTable();
|
|
14
24
|
const { canEdit, canDelete, canView, canAction } = usePermission(tableName);
|
|
15
25
|
|
|
26
|
+
console.log(">>> tnduc TableRowRender backParentNavigator", backParentNavigator);
|
|
16
27
|
const { tableActionsOnTable, tableActionsOnMoreMenu } = useMemo(() => {
|
|
17
|
-
const tableActionsAfterFilter = [...tableActions]
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const tableActionsAfterFilter = [...tableActions]
|
|
29
|
+
.filter((x) => x)
|
|
30
|
+
.filter(({ permissionType }) => {
|
|
31
|
+
if (permissionType == "view" && !canView) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (permissionType == "action" && !canAction) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
26
39
|
const tableActionsOnTable = tableActionsAfterFilter.filter(({ isOnTable = false }) => isOnTable);
|
|
27
40
|
const tableActionsOnMoreMenu = tableActionsAfterFilter.filter(({ isOnTable = false }) => !isOnTable);
|
|
28
41
|
return { tableActionsOnTable, tableActionsOnMoreMenu };
|
|
@@ -38,7 +51,7 @@ export const TableRowRender = ({ index, row, selected, onSelect, onChangeStatus,
|
|
|
38
51
|
onChange={(event) => onSelect(event, row[selectedField])}
|
|
39
52
|
/>
|
|
40
53
|
</TableCell>
|
|
41
|
-
<TableCell align="center">{index + 1}</TableCell>
|
|
54
|
+
<TableCell align="center">{sttLuyKe ? index + 1 : index + 1}</TableCell>
|
|
42
55
|
{columns.map(
|
|
43
56
|
({
|
|
44
57
|
field,
|
|
@@ -18,6 +18,7 @@ import { usePermission } from "../../hooks";
|
|
|
18
18
|
DataManagement.propTypes = {
|
|
19
19
|
columns: PropTypes.array,
|
|
20
20
|
title: PropTypes.string,
|
|
21
|
+
titleButtons: PropTypes.array,
|
|
21
22
|
tableName: PropTypes.string,
|
|
22
23
|
selectedField: PropTypes.string,
|
|
23
24
|
filters: PropTypes.arrayOf(
|
|
@@ -50,8 +51,10 @@ const getDefaultValues = (filters = []) => {
|
|
|
50
51
|
return defaultValues;
|
|
51
52
|
};
|
|
52
53
|
function DataManagement({
|
|
54
|
+
sttLuyKe = false,
|
|
53
55
|
columns = [],
|
|
54
56
|
title,
|
|
57
|
+
titleButtons = [],
|
|
55
58
|
tableName,
|
|
56
59
|
selectedField = "Id",
|
|
57
60
|
filters: tableFilters = [],
|
|
@@ -108,8 +111,10 @@ function DataManagement({
|
|
|
108
111
|
const values = useMemo(() => {
|
|
109
112
|
const hasTabpanel = !!tabPanel;
|
|
110
113
|
return {
|
|
114
|
+
sttLuyKe,
|
|
111
115
|
tableName,
|
|
112
116
|
selectedField,
|
|
117
|
+
titleButtons,
|
|
113
118
|
columns,
|
|
114
119
|
selectedEditItem,
|
|
115
120
|
setSelectedEditItem,
|
|
@@ -125,11 +130,14 @@ function DataManagement({
|
|
|
125
130
|
tableActions,
|
|
126
131
|
onEditClick,
|
|
127
132
|
hasTabpanel,
|
|
133
|
+
backParentNavigator,
|
|
128
134
|
defaultRowsPerPage
|
|
129
135
|
};
|
|
130
136
|
}, [
|
|
137
|
+
sttLuyKe,
|
|
131
138
|
tableName,
|
|
132
139
|
selectedField,
|
|
140
|
+
titleButtons,
|
|
133
141
|
columns,
|
|
134
142
|
selectedEditItem,
|
|
135
143
|
dataSearch,
|
|
@@ -139,12 +147,13 @@ function DataManagement({
|
|
|
139
147
|
openViewDialog,
|
|
140
148
|
setOpenViewDialog,
|
|
141
149
|
onEditClick,
|
|
150
|
+
backParentNavigator,
|
|
142
151
|
defaultRowsPerPage
|
|
143
152
|
]);
|
|
144
153
|
|
|
145
154
|
const methods = useForm({ defaultValues: getDefaultValues(filters) });
|
|
146
155
|
const { reset, setValue } = methods;
|
|
147
|
-
|
|
156
|
+
console.log("tnduc", backParentNavigator);
|
|
148
157
|
return (
|
|
149
158
|
<>
|
|
150
159
|
<DataTableContext.Provider value={values}>
|
|
@@ -170,6 +179,12 @@ function DataManagement({
|
|
|
170
179
|
</IconButton>
|
|
171
180
|
</Tooltip>
|
|
172
181
|
|
|
182
|
+
{titleButtons?.map((button, index) => (
|
|
183
|
+
<div key={index}>
|
|
184
|
+
{button}
|
|
185
|
+
{/* Các phần tử khác có thể được thêm ở đây nếu cần */}
|
|
186
|
+
</div>
|
|
187
|
+
))}
|
|
173
188
|
<ExportExcelButton tableName={tableName} data={dataSearch} size={elementSize} />
|
|
174
189
|
{canCreate && !disableAdd && (
|
|
175
190
|
<Button
|
|
@@ -199,6 +214,7 @@ function DataManagement({
|
|
|
199
214
|
</Card>
|
|
200
215
|
</FormProvider>
|
|
201
216
|
|
|
217
|
+
{/* nôi dung form */}
|
|
202
218
|
{disableEditor || (
|
|
203
219
|
<EditorDialog
|
|
204
220
|
open={openEditorDialog}
|
|
@@ -207,6 +223,7 @@ function DataManagement({
|
|
|
207
223
|
fields={editorFields}
|
|
208
224
|
/>
|
|
209
225
|
)}
|
|
226
|
+
{/* nôi dung view */}
|
|
210
227
|
<ViewDetailDialog open={openViewDialog} onClose={() => setOpenViewDialog(false)} fields={editorFields} />
|
|
211
228
|
</DataTableContext.Provider>
|
|
212
229
|
</>
|
package/package.json
CHANGED
|
@@ -6,7 +6,6 @@ const PermissionProvider = ({ children }) => {
|
|
|
6
6
|
const value = useMemo(() => {
|
|
7
7
|
return { permissionMap, setPermission };
|
|
8
8
|
}, [permissionMap, setPermission]);
|
|
9
|
-
console.log("PermissionProvider: permissionMap", permissionMap);
|
|
10
9
|
return <PermissionContext.Provider value={value}>{children}</PermissionContext.Provider>;
|
|
11
10
|
};
|
|
12
11
|
export default PermissionProvider;
|