@visns-studio/visns-components 3.8.12 → 3.9.0

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.
@@ -158,13 +158,6 @@ const DataGrid = ({
158
158
  const [gridColumns, setGridColumns] = useState([]);
159
159
  const [limit, setLimit] = useState(ajaxSetting.take || 10);
160
160
  const [search, setSearch] = useState('');
161
- const sortInfo =
162
- ajaxSetting.sortBy && ajaxSetting.sort
163
- ? {
164
- name: ajaxSetting.sortBy,
165
- dir: ajaxSetting.sort === 'asc' ? 1 : -1,
166
- }
167
- : null;
168
161
 
169
162
  /** Table Functions */
170
163
  const handleChangeSearch = (e) => {
@@ -18,6 +18,7 @@ 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';
21
22
  import { confirmAlert } from 'react-confirm-alert';
22
23
  import { toast } from 'react-toastify';
23
24
  import {
@@ -51,12 +52,13 @@ import Form from './Form';
51
52
  import _ from 'lodash';
52
53
 
53
54
  const loadData = async (
54
- { skip, limit, sortInfo, currentData, filterValue, groupBy },
55
+ { skip, limit, sortInfo, filterValue },
55
56
  search,
56
- ajaxSetting
57
+ ajaxSetting,
58
+ currentPage
57
59
  ) => {
58
60
  const url = ajaxSetting.url;
59
- const page = Math.floor(skip / limit) + 1;
61
+ const page = currentPage;
60
62
  const params = { page, sortInfo, take: limit, search: search, where: [] };
61
63
 
62
64
  if (sortInfo) {
@@ -157,13 +159,33 @@ const DataGrid = forwardRef(
157
159
  useEffect(() => {
158
160
  setFormData(form);
159
161
  }, [form]);
160
-
161
162
  /** Table States */
163
+ const currentPageRef = useRef(1); // Initialize with default value
164
+ const previousDataReloadRef = useRef(0);
165
+
162
166
  const [dataReload, setDataReload] = useState(0);
163
167
  const [dSearch, setDSearch] = useState('');
164
168
  const data = useCallback(
165
169
  (params) => {
166
- const sqlResult = loadData(params, dSearch, ajaxSetting);
170
+ let currentPage;
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
+ );
167
189
  if (setFilterData && params.filterValue) {
168
190
  setFilterData(params.filterValue);
169
191
  }
@@ -834,6 +856,18 @@ const DataGrid = forwardRef(
834
856
  [form]
835
857
  );
836
858
 
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
+
837
871
  const handleCoding = (c, data) => {
838
872
  const icons = [];
839
873
  const assetPath =
@@ -2509,6 +2543,7 @@ const DataGrid = forwardRef(
2509
2543
  pagination
2510
2544
  renderRowContextMenu={renderRowContextMenu}
2511
2545
  renderColumnContextMenu={renderColumnContextMenu}
2546
+ renderPaginationToolbar={renderPaginationToolbar}
2512
2547
  rowClassName="vs-datagrid--row"
2513
2548
  rowHeight={null}
2514
2549
  selected={selected}
@@ -7,6 +7,7 @@ import Download from '../Download';
7
7
  import Field from '../Field';
8
8
  import Table from '../DataGrid';
9
9
  import TableFilter from '../TableFilter';
10
+ import _ from 'lodash';
10
11
 
11
12
  function useWindowHeight() {
12
13
  const [windowHeight, setWindowHeight] = useState(window.innerHeight);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@inovua/reactdatagrid-community": "^5.10.2",
4
- "@nivo/bar": "^0.85.1",
5
- "@nivo/core": "^0.85.1",
6
- "@nivo/line": "^0.85.1",
7
- "@nivo/pie": "^0.85.1",
4
+ "@nivo/bar": "^0.86.0",
5
+ "@nivo/core": "^0.86.0",
6
+ "@nivo/line": "^0.86.0",
7
+ "@nivo/pie": "^0.86.0",
8
8
  "@tinymce/tinymce-react": "^5.0.1",
9
9
  "add": "^2.0.6",
10
10
  "akar-icons": "^1.9.31",
@@ -37,7 +37,7 @@
37
37
  "react-to-print": "^2.15.1",
38
38
  "react-toastify": "^10.0.5",
39
39
  "react-toggle": "^4.1.3",
40
- "react-tooltip": "^5.26.3",
40
+ "react-tooltip": "^5.26.4",
41
41
  "react-window": "^1.8.10",
42
42
  "reactjs-popup": "^2.0.6",
43
43
  "truncate": "^3.0.0",
@@ -54,7 +54,7 @@
54
54
  "react-dom": "^17.0.1"
55
55
  },
56
56
  "name": "@visns-studio/visns-components",
57
- "version": "3.8.12",
57
+ "version": "3.9.0",
58
58
  "description": "Various packages to assist in the development of our Custom Applications.",
59
59
  "main": "index.js",
60
60
  "scripts": {