@visns-studio/visns-components 4.7.9 → 4.7.10
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 +1 -1
- package/src/components/crm/Field.jsx +41 -23
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.
|
|
78
|
+
"version": "4.7.10",
|
|
79
79
|
"description": "Various packages to assist in the development of our Custom Applications.",
|
|
80
80
|
"main": "src/index.js",
|
|
81
81
|
"files": [
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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 =
|
|
1609
|
+
let f = form;
|
|
1576
1610
|
|
|
1577
1611
|
form.fields.forEach((item, itemKey) => {
|
|
1578
|
-
if (item.hasOwnProperty('dataId')) {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
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
|
|