@firecms/core 3.0.0-canary.200 → 3.0.0-canary.201
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.
|
@@ -281,6 +281,12 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
|
|
|
281
281
|
* This prop has only effect if you are using the collection editor.
|
|
282
282
|
*/
|
|
283
283
|
editable?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* If set to true, the default values of the properties will be applied
|
|
286
|
+
* to the entity every time the entity is updated (not only when created).
|
|
287
|
+
* Defaults to false.
|
|
288
|
+
*/
|
|
289
|
+
alwaysApplyDefaultValues?: boolean;
|
|
284
290
|
}
|
|
285
291
|
/**
|
|
286
292
|
* Parameter passed to the `Actions` prop in the collection configuration.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.201",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"./package.json": "./package.json"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@firecms/editor": "^3.0.0-canary.
|
|
54
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
55
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
53
|
+
"@firecms/editor": "^3.0.0-canary.201",
|
|
54
|
+
"@firecms/formex": "^3.0.0-canary.201",
|
|
55
|
+
"@firecms/ui": "^3.0.0-canary.201",
|
|
56
56
|
"@hello-pangea/dnd": "^17.0.0",
|
|
57
57
|
"@radix-ui/react-portal": "^1.1.3",
|
|
58
58
|
"clsx": "^2.1.1",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"dist",
|
|
105
105
|
"src"
|
|
106
106
|
],
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "39d8cd5c2397a004c233c96a798e16133ec8590c",
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
package/src/form/EntityForm.tsx
CHANGED
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
EntityStatus,
|
|
7
7
|
EntityValues,
|
|
8
8
|
FormContext,
|
|
9
|
-
PluginFormActionProps,
|
|
9
|
+
PluginFormActionProps,
|
|
10
|
+
PropertyConfig,
|
|
10
11
|
PropertyFieldBindingProps,
|
|
11
12
|
ResolvedEntityCollection
|
|
12
13
|
} from "../types";
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
getValueInPath,
|
|
20
21
|
isHidden,
|
|
21
22
|
isReadOnly,
|
|
23
|
+
mergeDeep,
|
|
22
24
|
resolveCollection,
|
|
23
25
|
useDebouncedCallback
|
|
24
26
|
} from "../util";
|
|
@@ -638,7 +640,11 @@ function getInitialEntityValues<M extends object>(
|
|
|
638
640
|
});
|
|
639
641
|
const properties = resolvedCollection.properties;
|
|
640
642
|
if ((status === "existing" || status === "copy") && entity) {
|
|
641
|
-
|
|
643
|
+
if (!collection.alwaysApplyDefaultValues) {
|
|
644
|
+
return entity.values ?? getDefaultValuesFor(properties);
|
|
645
|
+
} else {
|
|
646
|
+
return mergeDeep(getDefaultValuesFor(properties), entity.values ?? {});
|
|
647
|
+
}
|
|
642
648
|
} else if (status === "new") {
|
|
643
649
|
return getDefaultValuesFor(properties);
|
|
644
650
|
} else {
|
package/src/types/collections.ts
CHANGED
|
@@ -323,6 +323,13 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
|
|
|
323
323
|
* This prop has only effect if you are using the collection editor.
|
|
324
324
|
*/
|
|
325
325
|
editable?: boolean;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* If set to true, the default values of the properties will be applied
|
|
329
|
+
* to the entity every time the entity is updated (not only when created).
|
|
330
|
+
* Defaults to false.
|
|
331
|
+
*/
|
|
332
|
+
alwaysApplyDefaultValues?: boolean;
|
|
326
333
|
}
|
|
327
334
|
|
|
328
335
|
/**
|