@visns-studio/visns-components 1.6.5 → 1.6.7

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.
@@ -153,7 +153,7 @@ const DataGrid = ({
153
153
  const [filterDataSource, setFilterDataSource] = useState([]);
154
154
  const [filterValue, setFilterValue] = useState([]);
155
155
  const [gridColumns, setGridColumns] = useState([]);
156
- const limit = ajaxSetting.take || 10;
156
+ const [limit, setLimit] = useState(ajaxSetting.take || 10);
157
157
  const [search, setSearch] = useState("");
158
158
  const sortInfo =
159
159
  ajaxSetting.sortBy && ajaxSetting.sort
@@ -1322,15 +1322,17 @@ const DataGrid = ({
1322
1322
  : 400,
1323
1323
  }));
1324
1324
 
1325
- console.info(
1325
+ let dgHeight =
1326
1326
  dataCount > 5
1327
1327
  ? dataCount > 8
1328
1328
  ? windowHeight * 0.7 > 550
1329
1329
  ? windowHeight * 0.7
1330
1330
  : 550
1331
1331
  : 450
1332
- : 400
1333
- );
1332
+ : 400;
1333
+
1334
+ let rowCount = Math.floor((dgHeight - 50) / 60);
1335
+ setLimit(rowCount);
1334
1336
  }, [dataCount]);
1335
1337
 
1336
1338
  useEffect(() => {
@@ -1385,7 +1387,6 @@ const DataGrid = ({
1385
1387
  columns={gridColumns}
1386
1388
  dataSource={data}
1387
1389
  filterValue={filterValue}
1388
- defaultLimit={limit}
1389
1390
  defaultSortInfo={sortInfo}
1390
1391
  enableColumnAutosize={false}
1391
1392
  enableColumnFilterContextMenu={false}
@@ -1395,8 +1396,10 @@ const DataGrid = ({
1395
1396
  /\//g,
1396
1397
  "-"
1397
1398
  )}`}
1399
+ limit={limit}
1398
1400
  minRowHeight={40}
1399
1401
  onFilterValueChange={setFilterValue}
1402
+ onLimitChange={setLimit}
1400
1403
  onRenderRow={onRenderRow}
1401
1404
  pagination
1402
1405
  renderColumnContextMenu={renderColumnContextMenu}
@@ -17,6 +17,7 @@ import CustomFetch from "../crm/visns-fetch";
17
17
  import Select from "../crm/visns-select";
18
18
  import MultiSelect from "../crm/visns-multi-select";
19
19
  import VisnsAutocomplete from "../crm/visns-autocomplete";
20
+ import moment from "moment";
20
21
 
21
22
  Quill.register("modules/imageUploader", ImageUploader);
22
23
 
@@ -63,6 +64,7 @@ const Field = ({
63
64
  inputValue,
64
65
  inputClass,
65
66
  onChange,
67
+ onChangeDate,
66
68
  onChangeFile,
67
69
  onChangeRicheditor,
68
70
  onChangeSelect,
@@ -556,7 +558,11 @@ const Field = ({
556
558
  : "dd-MM-yyyy"
557
559
  }
558
560
  className={inputClass[settings.id]}
559
- selected={inputValue || ""}
561
+ selected={
562
+ inputValue
563
+ ? moment(inputValue).toDate()
564
+ : ""
565
+ }
560
566
  showMonthDropdown
561
567
  showYearDropdown
562
568
  dropdownMode="select"
@@ -576,7 +582,11 @@ const Field = ({
576
582
  }
577
583
  showTimeSelect
578
584
  className={inputClass[settings.id]}
579
- selected={inputValue || null}
585
+ selected={
586
+ inputValue
587
+ ? moment(inputValue).toDate()
588
+ : ""
589
+ }
580
590
  showMonthDropdown
581
591
  showYearDropdown
582
592
  dropdownMode="select"
@@ -600,7 +610,11 @@ const Field = ({
600
610
  timeIntervals={15}
601
611
  timeCaption="Time"
602
612
  className={inputClass[settings.id]}
603
- selected={inputValue || ""}
613
+ selected={
614
+ inputValue
615
+ ? moment(inputValue).toDate()
616
+ : ""
617
+ }
604
618
  onChange={(date) =>
605
619
  onChangeDate(date, settings.id)
606
620
  }
@@ -67,6 +67,13 @@ function Form(props) {
67
67
  }
68
68
  };
69
69
 
70
+ const handleChangeDate = (date, id) => {
71
+ setData((prevState) => ({
72
+ ...prevState,
73
+ [id]: date,
74
+ }));
75
+ };
76
+
70
77
  const handleChangeSelect = (value, action, id) => {
71
78
  if (value && action && id) {
72
79
  setData((prevState) => ({
@@ -406,6 +413,7 @@ function Form(props) {
406
413
  }
407
414
  inputClass={dataClass}
408
415
  onChange={handleChange}
416
+ onChangeDate={handleChangeDate}
409
417
  onChangeFile={handleChangeFile}
410
418
  onChangeRicheditor={handleChangeRicheditor}
411
419
  onChangeSelect={handleChangeSelect}
@@ -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.5",
37
+ "version": "1.6.7",
38
38
  "description": "Various packages to assist in the development of our Custom Applications.",
39
39
  "main": "index.js",
40
40
  "devDependencies": {},