authscape 1.0.258 → 1.0.259
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/index.js +27 -10
- package/package.json +1 -1
- package/src/components/EditableDatagrid.js +20 -9
package/index.js
CHANGED
|
@@ -974,6 +974,8 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
974
974
|
columns = _ref.columns,
|
|
975
975
|
_ref$isCellEditable = _ref.isCellEditable,
|
|
976
976
|
_isCellEditable = _ref$isCellEditable === void 0 ? null : _ref$isCellEditable,
|
|
977
|
+
_ref$params = _ref.params,
|
|
978
|
+
params = _ref$params === void 0 ? null : _ref$params,
|
|
977
979
|
_ref$onCellEdited = _ref.onCellEdited,
|
|
978
980
|
onCellEdited = _ref$onCellEdited === void 0 ? null : _ref$onCellEdited,
|
|
979
981
|
_ref$sx = _ref.sx,
|
|
@@ -1010,28 +1012,43 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
1010
1012
|
while (1) switch (_context.prev = _context.next) {
|
|
1011
1013
|
case 0:
|
|
1012
1014
|
if (!(url != null)) {
|
|
1013
|
-
_context.next =
|
|
1015
|
+
_context.next = 16;
|
|
1014
1016
|
break;
|
|
1015
1017
|
}
|
|
1016
|
-
|
|
1018
|
+
response = null;
|
|
1019
|
+
if (!(params == null)) {
|
|
1020
|
+
_context.next = 8;
|
|
1021
|
+
break;
|
|
1022
|
+
}
|
|
1023
|
+
_context.next = 5;
|
|
1017
1024
|
return apiService().post(url, {
|
|
1018
1025
|
offset: offset,
|
|
1019
1026
|
length: pageSize
|
|
1020
1027
|
});
|
|
1021
|
-
case
|
|
1028
|
+
case 5:
|
|
1022
1029
|
response = _context.sent;
|
|
1030
|
+
_context.next = 13;
|
|
1031
|
+
break;
|
|
1032
|
+
case 8:
|
|
1033
|
+
params.offset = offset;
|
|
1034
|
+
params.length = pageSize;
|
|
1035
|
+
_context.next = 12;
|
|
1036
|
+
return apiService().post(url, params);
|
|
1037
|
+
case 12:
|
|
1038
|
+
response = _context.sent;
|
|
1039
|
+
case 13:
|
|
1023
1040
|
if (response != null && response.status == 200) {
|
|
1024
1041
|
setTotalRows(response.data.recordsTotal);
|
|
1025
1042
|
setRows(response.data.data);
|
|
1026
1043
|
}
|
|
1027
|
-
_context.next =
|
|
1044
|
+
_context.next = 17;
|
|
1028
1045
|
break;
|
|
1029
|
-
case
|
|
1046
|
+
case 16:
|
|
1030
1047
|
if (rows != null) {
|
|
1031
1048
|
setTotalRows(eRows.length);
|
|
1032
1049
|
setRows(eRows);
|
|
1033
1050
|
}
|
|
1034
|
-
case
|
|
1051
|
+
case 17:
|
|
1035
1052
|
case "end":
|
|
1036
1053
|
return _context.stop();
|
|
1037
1054
|
}
|
|
@@ -1043,12 +1060,12 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
1043
1060
|
}();
|
|
1044
1061
|
var handleCellEditCommit = _react["default"].useCallback(function () {
|
|
1045
1062
|
return /*#__PURE__*/function () {
|
|
1046
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(
|
|
1063
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(dataParams) {
|
|
1047
1064
|
var id, field, value, editedRow;
|
|
1048
1065
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1049
1066
|
while (1) switch (_context2.prev = _context2.next) {
|
|
1050
1067
|
case 0:
|
|
1051
|
-
id =
|
|
1068
|
+
id = dataParams.id, field = dataParams.field, value = dataParams.value;
|
|
1052
1069
|
editedRow = {
|
|
1053
1070
|
id: id,
|
|
1054
1071
|
field: field,
|
|
@@ -1086,9 +1103,9 @@ var EditableDatagrid = function EditableDatagrid(_ref) {
|
|
|
1086
1103
|
rowsPerPageOptions: rowsPerPage,
|
|
1087
1104
|
disableSelectionOnClick: true,
|
|
1088
1105
|
onCellEditCommit: handleCellEditCommit(),
|
|
1089
|
-
isCellEditable: function isCellEditable(
|
|
1106
|
+
isCellEditable: function isCellEditable(data) {
|
|
1090
1107
|
if (_isCellEditable != null) {
|
|
1091
|
-
_isCellEditable(
|
|
1108
|
+
_isCellEditable(data);
|
|
1092
1109
|
}
|
|
1093
1110
|
return true;
|
|
1094
1111
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import React, {useEffect, useState} from 'react';
|
|
|
2
2
|
import { DataGrid, GridActionsCellItem } from "@mui/x-data-grid";
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
export const EditableDatagrid = ({loadedUser, url = null, eRows = null, columns, isCellEditable = null, onCellEdited = null, sx = {}, height="50vh", pageSize = 50, rowsPerPage = [25, 50, 100], rowHeight = 70}) => {
|
|
5
|
+
export const EditableDatagrid = ({loadedUser, url = null, eRows = null, columns, isCellEditable = null, params = null, onCellEdited = null, sx = {}, height="50vh", pageSize = 50, rowsPerPage = [25, 50, 100], rowHeight = 70}) => {
|
|
6
6
|
|
|
7
7
|
const [rows, setRows] = useState([]);
|
|
8
8
|
const [totalRows, setTotalRows] = useState(0);
|
|
@@ -22,11 +22,22 @@ export const EditableDatagrid = ({loadedUser, url = null, eRows = null, columns,
|
|
|
22
22
|
|
|
23
23
|
if (url != null)
|
|
24
24
|
{
|
|
25
|
-
let response =
|
|
25
|
+
let response = null;
|
|
26
|
+
if (params == null)
|
|
26
27
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
response = await apiService().post(url,
|
|
29
|
+
{
|
|
30
|
+
offset: offset,
|
|
31
|
+
length: pageSize
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else
|
|
35
|
+
{
|
|
36
|
+
params.offset = offset;
|
|
37
|
+
params.length = pageSize;
|
|
38
|
+
|
|
39
|
+
response = await apiService().post(url, params);
|
|
40
|
+
}
|
|
30
41
|
|
|
31
42
|
if (response != null && response.status == 200)
|
|
32
43
|
{
|
|
@@ -41,9 +52,9 @@ export const EditableDatagrid = ({loadedUser, url = null, eRows = null, columns,
|
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
const handleCellEditCommit = React.useCallback(() => async (
|
|
55
|
+
const handleCellEditCommit = React.useCallback(() => async (dataParams) => {
|
|
45
56
|
|
|
46
|
-
const { id, field, value } =
|
|
57
|
+
const { id, field, value } = dataParams;
|
|
47
58
|
const editedRow = { id, field, value };
|
|
48
59
|
|
|
49
60
|
onCellEdited(editedRow);
|
|
@@ -66,11 +77,11 @@ export const EditableDatagrid = ({loadedUser, url = null, eRows = null, columns,
|
|
|
66
77
|
rowsPerPageOptions={rowsPerPage}
|
|
67
78
|
disableSelectionOnClick={true}
|
|
68
79
|
onCellEditCommit={handleCellEditCommit()}
|
|
69
|
-
isCellEditable={(
|
|
80
|
+
isCellEditable={(data) => {
|
|
70
81
|
|
|
71
82
|
if (isCellEditable != null)
|
|
72
83
|
{
|
|
73
|
-
isCellEditable(
|
|
84
|
+
isCellEditable(data);
|
|
74
85
|
}
|
|
75
86
|
return true;
|
|
76
87
|
}}
|