@snowtop/ent 0.2.3-alpha2 → 0.2.4
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/action/orchestrator.js +19 -2
- package/package.json +1 -1
package/action/orchestrator.js
CHANGED
|
@@ -696,12 +696,29 @@ class Orchestrator {
|
|
|
696
696
|
data[dbKey] = value;
|
|
697
697
|
}
|
|
698
698
|
if (defaultValue !== undefined) {
|
|
699
|
+
// Format defaults early so JSON/list defaults are DB-ready in edited data.
|
|
700
|
+
let formattedDefaultValue = defaultValue;
|
|
701
|
+
if (defaultValue !== null && !this.isBuilder(defaultValue) && field.format) {
|
|
702
|
+
let valid = true;
|
|
703
|
+
if (field.valid) {
|
|
704
|
+
valid = field.valid(defaultValue);
|
|
705
|
+
if ((0, types_1.isPromise)(valid)) {
|
|
706
|
+
valid = await valid;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (valid) {
|
|
710
|
+
formattedDefaultValue = field.format(defaultValue);
|
|
711
|
+
if ((0, types_1.isPromise)(formattedDefaultValue)) {
|
|
712
|
+
formattedDefaultValue = await formattedDefaultValue;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
699
716
|
updateInput = true;
|
|
700
717
|
if (updateOnlyIfOther) {
|
|
701
|
-
defaultData[dbKey] =
|
|
718
|
+
defaultData[dbKey] = formattedDefaultValue;
|
|
702
719
|
}
|
|
703
720
|
else {
|
|
704
|
-
data[dbKey] =
|
|
721
|
+
data[dbKey] = formattedDefaultValue;
|
|
705
722
|
}
|
|
706
723
|
this.defaultFieldsByFieldName[fieldName] = defaultValue;
|
|
707
724
|
this.defaultFieldsByTSName[this.getInputKey(fieldName)] = defaultValue;
|