@onehat/ui 0.3.136 → 0.3.137
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
|
@@ -37,6 +37,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
37
37
|
onChange,
|
|
38
38
|
onSave,
|
|
39
39
|
newEntityDisplayValue,
|
|
40
|
+
defaultValues,
|
|
40
41
|
|
|
41
42
|
// withComponent
|
|
42
43
|
self,
|
|
@@ -88,8 +89,19 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
88
89
|
return newEntityDisplayValueRef.current;
|
|
89
90
|
},
|
|
90
91
|
onAdd = async (e, values) => {
|
|
91
|
-
|
|
92
|
-
|
|
92
|
+
let addValues = values;
|
|
93
|
+
|
|
94
|
+
if (!values) {
|
|
95
|
+
// you can either:
|
|
96
|
+
// 1. directlty submit 'values' to use in onAdd(), or
|
|
97
|
+
// 2. Use the repository's default values (defined on each property as 'defaultValue'), or
|
|
98
|
+
// 3. Individually override the repository's default values with submitted 'defaultValues' (given as a prop to this HOC)
|
|
99
|
+
let defaultValuesToUse = Repository.getSchema().getDefaultValues();
|
|
100
|
+
if (defaultValues) {
|
|
101
|
+
_.merge(defaultValuesToUse, defaultValues);
|
|
102
|
+
}
|
|
103
|
+
addValues = _.clone(defaultValuesToUse);
|
|
104
|
+
}
|
|
93
105
|
|
|
94
106
|
if (selectorId && !_.isEmpty(selectorSelected)) {
|
|
95
107
|
addValues[selectorId] = selectorSelected.id;
|