drapcode-utility 2.5.2 → 2.5.3
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/build/utils/util.js +12 -2
- package/package.json +1 -1
package/build/utils/util.js
CHANGED
|
@@ -595,12 +595,22 @@ const fillDefaultValues = (collection, itemdata) => {
|
|
|
595
595
|
!fieldTypesToSkip.includes(field.type));
|
|
596
596
|
allFields.forEach((field) => {
|
|
597
597
|
const fieldName = field.fieldName;
|
|
598
|
+
const currentValue = filledItemData[fieldName];
|
|
599
|
+
const isEmptyArray = Array.isArray(currentValue) && currentValue.length === 0;
|
|
598
600
|
if (!(fieldName in filledItemData) ||
|
|
599
601
|
filledItemData[fieldName] === "" ||
|
|
600
602
|
filledItemData[fieldName] === 0 ||
|
|
601
|
-
filledItemData[fieldName] === false
|
|
603
|
+
filledItemData[fieldName] === false ||
|
|
604
|
+
isEmptyArray) {
|
|
602
605
|
const formattedField = JSON.parse(JSON.stringify(field));
|
|
603
|
-
|
|
606
|
+
console.log("These are the field types: ", field.type, typeof field.type);
|
|
607
|
+
if (field.type === "static_option") {
|
|
608
|
+
if (formattedField.extraFieldSetting?.staticDefaultValue?.length > 0) {
|
|
609
|
+
filledItemData[fieldName] =
|
|
610
|
+
formattedField.extraFieldSetting.staticDefaultValue[0];
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
else if (field.extraFieldSetting &&
|
|
604
614
|
"defaultValue" in formattedField.extraFieldSetting) {
|
|
605
615
|
filledItemData[fieldName] = assignFieldValue(formattedField, field, fieldName, filledItemData);
|
|
606
616
|
}
|