drapcode-utility 2.5.2-preview → 2.5.3-preview
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
|
@@ -640,12 +640,22 @@ const fillDefaultValues = (collection, itemdata) => {
|
|
|
640
640
|
!fieldTypesToSkip.includes(field.type));
|
|
641
641
|
allFields.forEach((field) => {
|
|
642
642
|
const fieldName = field.fieldName;
|
|
643
|
+
const currentValue = filledItemData[fieldName];
|
|
644
|
+
const isEmptyArray = Array.isArray(currentValue) && currentValue.length === 0;
|
|
643
645
|
if (!(fieldName in filledItemData) ||
|
|
644
646
|
filledItemData[fieldName] === "" ||
|
|
645
647
|
filledItemData[fieldName] === 0 ||
|
|
646
|
-
filledItemData[fieldName] === false
|
|
648
|
+
filledItemData[fieldName] === false ||
|
|
649
|
+
isEmptyArray) {
|
|
647
650
|
const formattedField = JSON.parse(JSON.stringify(field));
|
|
648
|
-
|
|
651
|
+
console.log("These are the field types: ", field.type, typeof field.type);
|
|
652
|
+
if (field.type === "static_option") {
|
|
653
|
+
if (formattedField.extraFieldSetting?.staticDefaultValue?.length > 0) {
|
|
654
|
+
filledItemData[fieldName] =
|
|
655
|
+
formattedField.extraFieldSetting.staticDefaultValue[0];
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
else if (field.extraFieldSetting &&
|
|
649
659
|
"defaultValue" in formattedField.extraFieldSetting) {
|
|
650
660
|
filledItemData[fieldName] = assignFieldValue(formattedField, field, fieldName, filledItemData);
|
|
651
661
|
}
|