@visns-studio/visns-components 4.7.9 → 4.7.11

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/package.json CHANGED
@@ -75,7 +75,7 @@
75
75
  "react-dom": "^17.0.0 || ^18.0.0"
76
76
  },
77
77
  "name": "@visns-studio/visns-components",
78
- "version": "4.7.9",
78
+ "version": "4.7.11",
79
79
  "description": "Various packages to assist in the development of our Custom Applications.",
80
80
  "main": "src/index.js",
81
81
  "files": [
@@ -646,28 +646,38 @@ const DataGrid = forwardRef(
646
646
 
647
647
  if (column.type !== 'dropdown') {
648
648
  if (column.id !== '__checkbox-column') {
649
- if (column.link && column.link.url) {
650
- const fileRelationArray = column.id.split('.');
651
- const linkUrl = column.link.url;
652
- const linkKey =
653
- rowProps.columns[columnIndex].link.key;
654
- const rowData = rowProps.data[linkKey];
655
-
656
- if (column.link.hasOwnProperty('folder')) {
657
- const linkFolder =
658
- rowProps.columns[columnIndex].link.folder;
659
-
660
- if (rowProps.data[fileRelationArray[0]]) {
661
- if (linkFolder !== '') {
662
- window.open(
663
- `${linkUrl}${rowData}/${linkFolder}`
664
- );
665
- } else {
666
- window.open(`${linkUrl}${rowData}`);
649
+ if (column.link && column.link.hasOwnProperty('url')) {
650
+ if (column.link.url) {
651
+ const fileRelationArray = column.id.split('.');
652
+ const linkUrl = column.link.url;
653
+ const linkKey =
654
+ rowProps.columns[columnIndex].link.key;
655
+ const rowData = rowProps.data[linkKey];
656
+
657
+ if (column.link.hasOwnProperty('folder')) {
658
+ const linkFolder =
659
+ rowProps.columns[columnIndex].link
660
+ .folder;
661
+
662
+ if (rowProps.data[fileRelationArray[0]]) {
663
+ if (linkFolder !== '') {
664
+ window.open(
665
+ `${linkUrl}${rowData}/${linkFolder}`
666
+ );
667
+ } else {
668
+ window.open(`${linkUrl}${rowData}`);
669
+ }
667
670
  }
671
+ } else {
672
+ navigate(`${linkUrl}${rowData}`);
668
673
  }
669
674
  } else {
670
- navigate(`${linkUrl}${rowData}`);
675
+ if (rowProps.data[column.id]) {
676
+ window.open(
677
+ rowProps.data[column.id],
678
+ '_blank'
679
+ );
680
+ }
671
681
  }
672
682
  } else if (column.link && column.link.popup) {
673
683
  const linkPopup = column.link.popup;
@@ -554,8 +554,25 @@ function Field({
554
554
  className={styles.buttonRight}
555
555
  onClick={(e) => {
556
556
  e.preventDefault();
557
+ let allow = false;
557
558
 
558
- handleAddEntry(settings.create);
559
+ if (settings.create.parent_id) {
560
+ if (
561
+ formData[settings.create.parent_id]
562
+ ) {
563
+ allow = true;
564
+ }
565
+ } else {
566
+ allow = true;
567
+ }
568
+
569
+ if (allow) {
570
+ handleAddEntry(settings.create);
571
+ } else {
572
+ toast.warning(
573
+ 'Please select a parent item first'
574
+ );
575
+ }
559
576
  }}
560
577
  >
561
578
  <CirclePlus strokeWidth={2} size={16} />
@@ -897,8 +914,25 @@ function Field({
897
914
  className={styles.buttonRight}
898
915
  onClick={(e) => {
899
916
  e.preventDefault();
917
+ let allow = false;
900
918
 
901
- handleAddEntry(settings.create);
919
+ if (settings.create.parent_id) {
920
+ if (
921
+ formData[settings.create.parent_id]
922
+ ) {
923
+ allow = true;
924
+ }
925
+ } else {
926
+ allow = true;
927
+ }
928
+
929
+ if (allow) {
930
+ handleAddEntry(settings.create);
931
+ } else {
932
+ toast.warning(
933
+ 'Please select a parent item first'
934
+ );
935
+ }
902
936
  }}
903
937
  >
904
938
  <CirclePlus strokeWidth={2} size={16} />
@@ -1572,29 +1606,13 @@ function Field({
1572
1606
 
1573
1607
  const handleAddEntry = (form) => {
1574
1608
  if (form) {
1575
- let f = { ...form }; // Create a copy of the form object to avoid direct mutation
1609
+ let f = form;
1576
1610
 
1577
1611
  form.fields.forEach((item, itemKey) => {
1578
- if (item.hasOwnProperty('dataId')) {
1579
- let value;
1580
-
1581
- if (Array.isArray(item.dataId)) {
1582
- // If dataId is an array, nest the keys to access formData
1583
- value = item.dataId.reduce((acc, key) => {
1584
- return acc && acc[key] ? acc[key] : undefined;
1585
- }, formData);
1586
- } else {
1587
- // If dataId is not an array, access formData directly
1588
- value = formData[item.dataId]
1589
- ? formData[item.dataId].value ||
1590
- formData[item.dataId]
1591
- : undefined;
1592
- }
1593
-
1594
- // Set the value if it exists
1595
- if (value !== undefined) {
1596
- f.fields[itemKey].value = value;
1597
- }
1612
+ if (item.hasOwnProperty('dataId') && formData[item.dataId]) {
1613
+ f.fields[itemKey].value = formData[item.dataId].value
1614
+ ? formData[item.dataId].value
1615
+ : formData[item.dataId];
1598
1616
  }
1599
1617
  });
1600
1618