@visns-studio/visns-components 3.9.0 → 3.9.2
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/crm/DataGrid.jsx +12 -82
- package/package.json +2 -2
|
@@ -18,7 +18,6 @@ import NumberFilter from '@inovua/reactdatagrid-community/NumberFilter';
|
|
|
18
18
|
import SelectFilter from '@inovua/reactdatagrid-community/SelectFilter';
|
|
19
19
|
import DateFilter from '@inovua/reactdatagrid-community/DateFilter';
|
|
20
20
|
import ReactDataGrid from '@inovua/reactdatagrid-community';
|
|
21
|
-
import PaginationToolbar from '@inovua/reactdatagrid-community/packages/PaginationToolbar';
|
|
22
21
|
import { confirmAlert } from 'react-confirm-alert';
|
|
23
22
|
import { toast } from 'react-toastify';
|
|
24
23
|
import {
|
|
@@ -54,11 +53,10 @@ import _ from 'lodash';
|
|
|
54
53
|
const loadData = async (
|
|
55
54
|
{ skip, limit, sortInfo, filterValue },
|
|
56
55
|
search,
|
|
57
|
-
ajaxSetting
|
|
58
|
-
currentPage
|
|
56
|
+
ajaxSetting
|
|
59
57
|
) => {
|
|
60
58
|
const url = ajaxSetting.url;
|
|
61
|
-
const page =
|
|
59
|
+
const page = Math.floor(skip / limit) + 1;
|
|
62
60
|
const params = { page, sortInfo, take: limit, search: search, where: [] };
|
|
63
61
|
|
|
64
62
|
if (sortInfo) {
|
|
@@ -160,32 +158,10 @@ const DataGrid = forwardRef(
|
|
|
160
158
|
setFormData(form);
|
|
161
159
|
}, [form]);
|
|
162
160
|
/** Table States */
|
|
163
|
-
const currentPageRef = useRef(1); // Initialize with default value
|
|
164
|
-
const previousDataReloadRef = useRef(0);
|
|
165
|
-
|
|
166
|
-
const [dataReload, setDataReload] = useState(0);
|
|
167
161
|
const [dSearch, setDSearch] = useState('');
|
|
168
|
-
const
|
|
162
|
+
const dataSource = useCallback(
|
|
169
163
|
(params) => {
|
|
170
|
-
|
|
171
|
-
// Preserve the last currentPage value
|
|
172
|
-
const previousDataReload = previousDataReloadRef.current;
|
|
173
|
-
|
|
174
|
-
if (dataReload !== previousDataReload) {
|
|
175
|
-
currentPage = currentPageRef.current;
|
|
176
|
-
previousDataReloadRef.current = dataReload;
|
|
177
|
-
} else {
|
|
178
|
-
// Update the currentPageRef with the new value
|
|
179
|
-
currentPage = currentPageRef.current =
|
|
180
|
-
Math.floor(params.skip / params.limit) + 1;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const sqlResult = loadData(
|
|
184
|
-
params,
|
|
185
|
-
dSearch,
|
|
186
|
-
ajaxSetting,
|
|
187
|
-
currentPage
|
|
188
|
-
);
|
|
164
|
+
const sqlResult = loadData(params, dSearch, ajaxSetting);
|
|
189
165
|
if (setFilterData && params.filterValue) {
|
|
190
166
|
setFilterData(params.filterValue);
|
|
191
167
|
}
|
|
@@ -199,7 +175,7 @@ const DataGrid = forwardRef(
|
|
|
199
175
|
|
|
200
176
|
return sqlResult;
|
|
201
177
|
},
|
|
202
|
-
[ajaxSetting,
|
|
178
|
+
[ajaxSetting, dSearch]
|
|
203
179
|
);
|
|
204
180
|
const [filterDataSource, setFilterDataSource] = useState([]);
|
|
205
181
|
const [filterValue, setFilterValue] = useState([]);
|
|
@@ -258,13 +234,7 @@ const DataGrid = forwardRef(
|
|
|
258
234
|
if (res.data.error === '') {
|
|
259
235
|
toast.success('Timer has been updated.');
|
|
260
236
|
|
|
261
|
-
|
|
262
|
-
const max = 999999999;
|
|
263
|
-
const randomNumber = Math.floor(
|
|
264
|
-
Math.random() * (max - min + 1) + min
|
|
265
|
-
);
|
|
266
|
-
|
|
267
|
-
setDataReload(randomNumber);
|
|
237
|
+
handleReload();
|
|
268
238
|
} else {
|
|
269
239
|
toast.error(res.data.error);
|
|
270
240
|
}
|
|
@@ -437,15 +407,7 @@ const DataGrid = forwardRef(
|
|
|
437
407
|
deleteForm.payload,
|
|
438
408
|
(result) => {
|
|
439
409
|
if (result.error === '') {
|
|
440
|
-
|
|
441
|
-
const max = 999999999;
|
|
442
|
-
const randomNumber = Math.floor(
|
|
443
|
-
Math.random() *
|
|
444
|
-
(max - min + 1) +
|
|
445
|
-
min
|
|
446
|
-
);
|
|
447
|
-
|
|
448
|
-
setDataReload(randomNumber);
|
|
410
|
+
handleReload();
|
|
449
411
|
|
|
450
412
|
toast.success(
|
|
451
413
|
`The selected item has been deleted.`
|
|
@@ -529,15 +491,7 @@ const DataGrid = forwardRef(
|
|
|
529
491
|
{},
|
|
530
492
|
function (result) {
|
|
531
493
|
if (result.error === '') {
|
|
532
|
-
|
|
533
|
-
const max = 999999999;
|
|
534
|
-
const randomNumber = Math.floor(
|
|
535
|
-
Math.random() *
|
|
536
|
-
(max - min + 1) +
|
|
537
|
-
min
|
|
538
|
-
);
|
|
539
|
-
|
|
540
|
-
setDataReload(randomNumber);
|
|
494
|
+
handleReload();
|
|
541
495
|
|
|
542
496
|
toast.success(String(s.title));
|
|
543
497
|
} else {
|
|
@@ -571,13 +525,7 @@ const DataGrid = forwardRef(
|
|
|
571
525
|
};
|
|
572
526
|
|
|
573
527
|
const handleReload = () => {
|
|
574
|
-
|
|
575
|
-
const max = 999999999;
|
|
576
|
-
const randomNumber = Math.floor(
|
|
577
|
-
Math.random() * (max - min + 1) + min
|
|
578
|
-
);
|
|
579
|
-
|
|
580
|
-
setDataReload(randomNumber);
|
|
528
|
+
gridRef.current.paginationProps.reload();
|
|
581
529
|
};
|
|
582
530
|
|
|
583
531
|
const handleSort = (value) => {
|
|
@@ -856,18 +804,6 @@ const DataGrid = forwardRef(
|
|
|
856
804
|
[form]
|
|
857
805
|
);
|
|
858
806
|
|
|
859
|
-
const renderPaginationToolbar = useCallback((paginationProps) => {
|
|
860
|
-
let pageProps = paginationProps;
|
|
861
|
-
let newSkip = (currentPageRef.current - 1) * pageProps.limit;
|
|
862
|
-
pageProps.skip = newSkip;
|
|
863
|
-
|
|
864
|
-
return (
|
|
865
|
-
<div style={{ height: 89 }}>
|
|
866
|
-
<PaginationToolbar {...pageProps} bordered={false} />
|
|
867
|
-
</div>
|
|
868
|
-
);
|
|
869
|
-
}, []);
|
|
870
|
-
|
|
871
807
|
const handleCoding = (c, data) => {
|
|
872
808
|
const icons = [];
|
|
873
809
|
const assetPath =
|
|
@@ -1092,13 +1028,7 @@ const DataGrid = forwardRef(
|
|
|
1092
1028
|
});
|
|
1093
1029
|
|
|
1094
1030
|
if (res.data.error === '') {
|
|
1095
|
-
|
|
1096
|
-
const max = 999999999;
|
|
1097
|
-
const randomNumber = Math.floor(
|
|
1098
|
-
Math.random() * (max - min + 1) + min
|
|
1099
|
-
);
|
|
1100
|
-
|
|
1101
|
-
setDataReload(randomNumber);
|
|
1031
|
+
handleReload();
|
|
1102
1032
|
} else {
|
|
1103
1033
|
toast.error(res.data.error);
|
|
1104
1034
|
}
|
|
@@ -2522,7 +2452,7 @@ const DataGrid = forwardRef(
|
|
|
2522
2452
|
<ReactDataGrid
|
|
2523
2453
|
{...tableSetting}
|
|
2524
2454
|
columns={gridColumns}
|
|
2525
|
-
dataSource={
|
|
2455
|
+
dataSource={dataSource}
|
|
2526
2456
|
filterValue={filterValue}
|
|
2527
2457
|
limit={limit}
|
|
2528
2458
|
enableColumnAutosize={false}
|
|
@@ -2543,7 +2473,6 @@ const DataGrid = forwardRef(
|
|
|
2543
2473
|
pagination
|
|
2544
2474
|
renderRowContextMenu={renderRowContextMenu}
|
|
2545
2475
|
renderColumnContextMenu={renderColumnContextMenu}
|
|
2546
|
-
renderPaginationToolbar={renderPaginationToolbar}
|
|
2547
2476
|
rowClassName="vs-datagrid--row"
|
|
2548
2477
|
rowHeight={null}
|
|
2549
2478
|
selected={selected}
|
|
@@ -2578,6 +2507,7 @@ const DataGrid = forwardRef(
|
|
|
2578
2507
|
fetchTable={handleReload}
|
|
2579
2508
|
formSettings={formData}
|
|
2580
2509
|
formType={formType}
|
|
2510
|
+
gridRef={gridRef}
|
|
2581
2511
|
mapbox={mapbox}
|
|
2582
2512
|
paramValue={paramValue}
|
|
2583
2513
|
style={style}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"awesome-debounce-promise": "^2.1.0",
|
|
13
13
|
"axios": "^1.6.8",
|
|
14
14
|
"file-saver": "^2.0.5",
|
|
15
|
-
"framer-motion": "^11.1.
|
|
15
|
+
"framer-motion": "^11.1.8",
|
|
16
16
|
"html-react-parser": "^5.1.10",
|
|
17
17
|
"lodash": "^4.17.21",
|
|
18
18
|
"lodash.debounce": "^4.0.8",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"react-dom": "^17.0.1"
|
|
55
55
|
},
|
|
56
56
|
"name": "@visns-studio/visns-components",
|
|
57
|
-
"version": "3.9.
|
|
57
|
+
"version": "3.9.2",
|
|
58
58
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
59
59
|
"main": "index.js",
|
|
60
60
|
"scripts": {
|