@visns-studio/visns-components 1.6.4 → 1.6.6

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.
@@ -139,13 +139,21 @@ const DataGrid = ({
139
139
  const [dataReload, setDataReload] = useState(0);
140
140
  const [dSearch, setDSearch] = useState("");
141
141
  const data = useCallback(
142
- (params) => loadData(params, dSearch, ajaxSetting),
142
+ (params) => {
143
+ const sqlResult = loadData(params, dSearch, ajaxSetting);
144
+
145
+ sqlResult.then((res) => {
146
+ setDataCount(res.count);
147
+ });
148
+
149
+ return sqlResult;
150
+ },
143
151
  [ajaxSetting, dataReload, dSearch]
144
152
  );
145
153
  const [filterDataSource, setFilterDataSource] = useState([]);
146
154
  const [filterValue, setFilterValue] = useState([]);
147
155
  const [gridColumns, setGridColumns] = useState([]);
148
- const limit = ajaxSetting.take || 10;
156
+ const [limit, setLimit] = useState(ajaxSetting.take || 10);
149
157
  const [search, setSearch] = useState("");
150
158
  const sortInfo =
151
159
  ajaxSetting.sortBy && ajaxSetting.sort
@@ -1285,14 +1293,48 @@ const DataGrid = ({
1285
1293
 
1286
1294
  // Data Grid Styling
1287
1295
  const [windowHeight, setWindowHeight] = useState(window.innerHeight);
1288
- const gridStyle = {
1289
- minHeight: windowHeight * 0.7 > 550 ? windowHeight * 0.7 : 550,
1296
+ const [dataCount, setDataCount] = useState(0);
1297
+ const [gridStyle, setGridStyle] = useState({
1298
+ minHeight:
1299
+ dataCount > 5
1300
+ ? dataCount > 8
1301
+ ? windowHeight * 0.7 > 550
1302
+ ? windowHeight * 0.7
1303
+ : 550
1304
+ : 450
1305
+ : 400,
1290
1306
  boxShadow: "none",
1291
- };
1307
+ });
1292
1308
  const headerProps = {
1293
1309
  style: style ? style : {},
1294
1310
  };
1295
1311
 
1312
+ useEffect(() => {
1313
+ setGridStyle((prevState) => ({
1314
+ ...prevState,
1315
+ minHeight:
1316
+ dataCount > 5
1317
+ ? dataCount > 8
1318
+ ? windowHeight * 0.7 > 550
1319
+ ? windowHeight * 0.7
1320
+ : 550
1321
+ : 450
1322
+ : 400,
1323
+ }));
1324
+
1325
+ let dgHeight =
1326
+ dataCount > 5
1327
+ ? dataCount > 8
1328
+ ? windowHeight * 0.7 > 550
1329
+ ? windowHeight * 0.7
1330
+ : 550
1331
+ : 450
1332
+ : 400;
1333
+
1334
+ let rowCount = Math.floor((dgHeight - 100) / 40);
1335
+ setLimit(rowCount);
1336
+ }, [dataCount]);
1337
+
1296
1338
  useEffect(() => {
1297
1339
  const handleResize = () => {
1298
1340
  setWindowHeight(window.innerHeight);
@@ -1345,7 +1387,6 @@ const DataGrid = ({
1345
1387
  columns={gridColumns}
1346
1388
  dataSource={data}
1347
1389
  filterValue={filterValue}
1348
- defaultLimit={limit}
1349
1390
  defaultSortInfo={sortInfo}
1350
1391
  enableColumnAutosize={false}
1351
1392
  enableColumnFilterContextMenu={false}
@@ -1355,8 +1396,10 @@ const DataGrid = ({
1355
1396
  /\//g,
1356
1397
  "-"
1357
1398
  )}`}
1399
+ limit={limit}
1358
1400
  minRowHeight={40}
1359
1401
  onFilterValueChange={setFilterValue}
1402
+ onLimitChange={setLimit}
1360
1403
  onRenderRow={onRenderRow}
1361
1404
  pagination
1362
1405
  renderColumnContextMenu={renderColumnContextMenu}
@@ -172,7 +172,7 @@ const DataGrid = forwardRef(
172
172
  const [filterDataSource, setFilterDataSource] = useState([]);
173
173
  const [filterValue, setFilterValue] = useState([]);
174
174
  const [gridColumns, setGridColumns] = useState([]);
175
- const limit = ajaxSetting.take || 10;
175
+ const [limit, setLimit] = useState(ajaxSetting.take || 10);
176
176
  const [search, setSearch] = useState("");
177
177
  const sortInfo =
178
178
  ajaxSetting.sortBy && ajaxSetting.sort
@@ -1653,15 +1653,17 @@ const DataGrid = forwardRef(
1653
1653
  : 400,
1654
1654
  }));
1655
1655
 
1656
- console.info(
1656
+ let dgHeight =
1657
1657
  dataCount > 5
1658
1658
  ? dataCount > 8
1659
1659
  ? windowHeight * 0.7 > 550
1660
1660
  ? windowHeight * 0.7
1661
1661
  : 550
1662
1662
  : 450
1663
- : 400
1664
- );
1663
+ : 400;
1664
+
1665
+ let rowCount = Math.floor((dgHeight - 100) / 40);
1666
+ setLimit(rowCount);
1665
1667
  }, [dataCount]);
1666
1668
 
1667
1669
  useEffect(() => {
@@ -1685,7 +1687,7 @@ const DataGrid = forwardRef(
1685
1687
  columns={gridColumns}
1686
1688
  dataSource={data}
1687
1689
  filterValue={filterValue}
1688
- defaultLimit={limit}
1690
+ limit={limit}
1689
1691
  defaultSortInfo={sortInfo}
1690
1692
  enableColumnAutosize={false}
1691
1693
  enableColumnFilterContextMenu={false}
@@ -1697,6 +1699,7 @@ const DataGrid = forwardRef(
1697
1699
  )}`}
1698
1700
  minRowHeight={40}
1699
1701
  onFilterValueChange={setFilterValue}
1702
+ onLimitChange={setLimit}
1700
1703
  onRenderRow={onRenderRow}
1701
1704
  pagination
1702
1705
  renderColumnContextMenu={renderColumnContextMenu}
@@ -583,6 +583,8 @@ function Form(props) {
583
583
  ? result.data
584
584
  : result;
585
585
 
586
+ console.info(result);
587
+
586
588
  Object.keys(formData).forEach((item) => {
587
589
  let tempRes = "";
588
590
  let tempResKey = "";
@@ -655,9 +657,20 @@ function Form(props) {
655
657
  tempObj !== undefined &&
656
658
  tempObj !== null
657
659
  ) {
660
+ let labelValue;
661
+
662
+ if (Array.isArray(field.relationName)) {
663
+ labelValue = field.relationName.map(
664
+ (name) => `${tempObj[name]} `
665
+ );
666
+ } else {
667
+ labelValue =
668
+ tempObj[field.relationName];
669
+ }
670
+
658
671
  tempRes = {
659
672
  value: tempObj.id,
660
- label: tempObj[field.relationName],
673
+ label: labelValue,
661
674
  };
662
675
  }
663
676
 
@@ -709,14 +722,23 @@ function Form(props) {
709
722
  }
710
723
  }
711
724
 
725
+ let labelValue;
726
+
727
+ if (Array.isArray(field.relationName)) {
728
+ labelValue = field.relationName.map(
729
+ (name) => `${tempObj[name]} `
730
+ );
731
+ } else {
732
+ labelValue =
733
+ tempObj[field.relationName];
734
+ }
735
+
712
736
  tempRes =
713
737
  tempObj !== undefined &&
714
738
  tempObj !== null
715
739
  ? {
716
740
  value: tempObj.id,
717
- label: tempObj[
718
- field.relationName
719
- ],
741
+ label: labelValue,
720
742
  }
721
743
  : {};
722
744
 
package/package.json CHANGED
@@ -34,7 +34,7 @@
34
34
  "react-dom": "^17.0.1"
35
35
  },
36
36
  "name": "@visns-studio/visns-components",
37
- "version": "1.6.4",
37
+ "version": "1.6.6",
38
38
  "description": "Various packages to assist in the development of our Custom Applications.",
39
39
  "main": "index.js",
40
40
  "devDependencies": {},