@visns-studio/visns-components 3.9.0 → 3.9.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.
- package/components/crm/DataGrid.jsx +14 -47
- package/package.json +1 -1
|
@@ -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,11 @@ 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
161
|
const [dataReload, setDataReload] = useState(0);
|
|
167
162
|
const [dSearch, setDSearch] = useState('');
|
|
168
|
-
const
|
|
163
|
+
const dataSource = useCallback(
|
|
169
164
|
(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
|
-
);
|
|
165
|
+
const sqlResult = loadData(params, dSearch, ajaxSetting);
|
|
189
166
|
if (setFilterData && params.filterValue) {
|
|
190
167
|
setFilterData(params.filterValue);
|
|
191
168
|
}
|
|
@@ -571,13 +548,15 @@ const DataGrid = forwardRef(
|
|
|
571
548
|
};
|
|
572
549
|
|
|
573
550
|
const handleReload = () => {
|
|
574
|
-
const min = 0;
|
|
575
|
-
const max = 999999999;
|
|
576
|
-
const randomNumber = Math.floor(
|
|
577
|
-
|
|
578
|
-
);
|
|
551
|
+
// const min = 0;
|
|
552
|
+
// const max = 999999999;
|
|
553
|
+
// const randomNumber = Math.floor(
|
|
554
|
+
// Math.random() * (max - min + 1) + min
|
|
555
|
+
// );
|
|
579
556
|
|
|
580
|
-
setDataReload(randomNumber);
|
|
557
|
+
// setDataReload(randomNumber);
|
|
558
|
+
|
|
559
|
+
gridRef.current.paginationProps.reload();
|
|
581
560
|
};
|
|
582
561
|
|
|
583
562
|
const handleSort = (value) => {
|
|
@@ -856,18 +835,6 @@ const DataGrid = forwardRef(
|
|
|
856
835
|
[form]
|
|
857
836
|
);
|
|
858
837
|
|
|
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
838
|
const handleCoding = (c, data) => {
|
|
872
839
|
const icons = [];
|
|
873
840
|
const assetPath =
|
|
@@ -2522,7 +2489,7 @@ const DataGrid = forwardRef(
|
|
|
2522
2489
|
<ReactDataGrid
|
|
2523
2490
|
{...tableSetting}
|
|
2524
2491
|
columns={gridColumns}
|
|
2525
|
-
dataSource={
|
|
2492
|
+
dataSource={dataSource}
|
|
2526
2493
|
filterValue={filterValue}
|
|
2527
2494
|
limit={limit}
|
|
2528
2495
|
enableColumnAutosize={false}
|
|
@@ -2543,7 +2510,6 @@ const DataGrid = forwardRef(
|
|
|
2543
2510
|
pagination
|
|
2544
2511
|
renderRowContextMenu={renderRowContextMenu}
|
|
2545
2512
|
renderColumnContextMenu={renderColumnContextMenu}
|
|
2546
|
-
renderPaginationToolbar={renderPaginationToolbar}
|
|
2547
2513
|
rowClassName="vs-datagrid--row"
|
|
2548
2514
|
rowHeight={null}
|
|
2549
2515
|
selected={selected}
|
|
@@ -2578,6 +2544,7 @@ const DataGrid = forwardRef(
|
|
|
2578
2544
|
fetchTable={handleReload}
|
|
2579
2545
|
formSettings={formData}
|
|
2580
2546
|
formType={formType}
|
|
2547
|
+
gridRef={gridRef}
|
|
2581
2548
|
mapbox={mapbox}
|
|
2582
2549
|
paramValue={paramValue}
|
|
2583
2550
|
style={style}
|
package/package.json
CHANGED