@firecms/collection_editor 3.0.0-canary.145 → 3.0.0-canary.146
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/dist/index.es.js +27 -29
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +26 -28
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -8
- package/src/types/persisted_collection.ts +0 -1
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +4 -2
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +2 -6
- package/src/ui/collection_editor/GetCodeDialog.tsx +22 -20
- package/src/ui/collection_editor/PropertyEditView.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.146",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@firecms/data_export": "^3.0.0-canary.
|
|
11
|
-
"@firecms/data_import": "^3.0.0-canary.
|
|
12
|
-
"@firecms/data_import_export": "^3.0.0-canary.
|
|
13
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
14
|
-
"@firecms/schema_inference": "^3.0.0-canary.
|
|
15
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
10
|
+
"@firecms/data_export": "^3.0.0-canary.146",
|
|
11
|
+
"@firecms/data_import": "^3.0.0-canary.146",
|
|
12
|
+
"@firecms/data_import_export": "^3.0.0-canary.146",
|
|
13
|
+
"@firecms/formex": "^3.0.0-canary.146",
|
|
14
|
+
"@firecms/schema_inference": "^3.0.0-canary.146",
|
|
15
|
+
"@firecms/ui": "^3.0.0-canary.146",
|
|
16
16
|
"json5": "^2.2.3",
|
|
17
17
|
"prism-react-renderer": "^2.4.0"
|
|
18
18
|
},
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "601e622a79787f5b08f7ac27646d044787b972f1"
|
|
71
71
|
}
|
|
@@ -2,7 +2,6 @@ import { EntityCollection, User } from "@firecms/core";
|
|
|
2
2
|
|
|
3
3
|
export type PersistedCollection<M extends Record<string, any> = any, USER extends User = User>
|
|
4
4
|
= Omit<EntityCollection<M, USER>, "subcollections"> & {
|
|
5
|
-
// properties: Properties<M>;
|
|
6
5
|
ownerId?: string;
|
|
7
6
|
subcollections?: PersistedCollection<any, any>[];
|
|
8
7
|
editable?: boolean;
|
|
@@ -276,6 +276,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
276
276
|
|
|
277
277
|
const saveCollection = (updatedCollection: PersistedCollection<M>): Promise<boolean> => {
|
|
278
278
|
const id = updatedCollection.id || updatedCollection.path;
|
|
279
|
+
|
|
279
280
|
return configController.saveCollection({
|
|
280
281
|
id,
|
|
281
282
|
collectionData: updatedCollection,
|
|
@@ -377,7 +378,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
377
378
|
|
|
378
379
|
if (!isNewCollection) {
|
|
379
380
|
saveCollection(newCollectionState).then(() => {
|
|
380
|
-
formexController.resetForm(
|
|
381
|
+
formexController.resetForm();
|
|
381
382
|
handleClose(newCollectionState);
|
|
382
383
|
});
|
|
383
384
|
return;
|
|
@@ -466,7 +467,8 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
466
467
|
const formController = useCreateFormex<PersistedCollection<M>>({
|
|
467
468
|
initialValues,
|
|
468
469
|
onSubmit,
|
|
469
|
-
validation
|
|
470
|
+
validation,
|
|
471
|
+
debugId: "COLLECTION_EDITOR"
|
|
470
472
|
});
|
|
471
473
|
|
|
472
474
|
const {
|
|
@@ -228,17 +228,13 @@ export function CollectionPropertiesEditorForm({
|
|
|
228
228
|
namespace
|
|
229
229
|
}: OnPropertyChangedParams) => {
|
|
230
230
|
|
|
231
|
+
console.log("!!!!!! onPropertyChanged", property)
|
|
232
|
+
|
|
231
233
|
const fullId = id ? getFullId(id, namespace) : undefined;
|
|
232
234
|
const propertyPath = fullId ? idToPropertiesPath(fullId) : undefined;
|
|
233
235
|
|
|
234
236
|
// If the id has changed we need to a little cleanup
|
|
235
237
|
if (previousId && previousId !== id) {
|
|
236
|
-
console.debug("onPropertyChanged, id change", {
|
|
237
|
-
id,
|
|
238
|
-
property,
|
|
239
|
-
previousId,
|
|
240
|
-
namespace
|
|
241
|
-
})
|
|
242
238
|
|
|
243
239
|
const previousFullId = getFullId(previousId, namespace);
|
|
244
240
|
const previousPropertyPath = idToPropertiesPath(previousFullId);
|
|
@@ -4,6 +4,7 @@ import React from "react";
|
|
|
4
4
|
import JSON5 from "json5";
|
|
5
5
|
import { Highlight, themes } from "prism-react-renderer"
|
|
6
6
|
import { camelCase } from "./utils/strings";
|
|
7
|
+
import { clone } from "@firecms/formex";
|
|
7
8
|
|
|
8
9
|
export function GetCodeDialog({
|
|
9
10
|
collection,
|
|
@@ -14,7 +15,7 @@ export function GetCodeDialog({
|
|
|
14
15
|
const snackbarController = useSnackbarController();
|
|
15
16
|
|
|
16
17
|
const code = collection
|
|
17
|
-
? "import { EntityCollection } from \"@firecms/core\";\n\nconst " + (collection?.name ? camelCase(collection.name) : "my") + "Collection:EntityCollection = " + JSON5.stringify(collectionToCode(collection), null, "\t")
|
|
18
|
+
? "import { EntityCollection } from \"@firecms/core\";\n\nconst " + (collection?.name ? camelCase(collection.name) : "my") + "Collection:EntityCollection = " + JSON5.stringify(collectionToCode({ ...collection }), null, "\t")
|
|
18
19
|
: "No collection selected";
|
|
19
20
|
return <Dialog open={open}
|
|
20
21
|
onOpenChange={onOpenChange}
|
|
@@ -79,35 +80,36 @@ export function GetCodeDialog({
|
|
|
79
80
|
function collectionToCode(collection: EntityCollection): object {
|
|
80
81
|
|
|
81
82
|
const propertyCleanup = (value: any): any => {
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
const valueCopy = clone(value);
|
|
84
|
+
if (typeof valueCopy === "function") {
|
|
85
|
+
return valueCopy;
|
|
84
86
|
}
|
|
85
|
-
if (Array.isArray(
|
|
86
|
-
return
|
|
87
|
+
if (Array.isArray(valueCopy)) {
|
|
88
|
+
return valueCopy.map((v: any) => propertyCleanup(v));
|
|
87
89
|
}
|
|
88
|
-
if (typeof
|
|
89
|
-
if (
|
|
90
|
-
return
|
|
91
|
-
Object.keys(
|
|
92
|
-
if (!isEmptyObject(
|
|
93
|
-
const childRes = propertyCleanup(
|
|
90
|
+
if (typeof valueCopy === "object") {
|
|
91
|
+
if (valueCopy === null)
|
|
92
|
+
return valueCopy;
|
|
93
|
+
Object.keys(valueCopy).forEach((key) => {
|
|
94
|
+
if (!isEmptyObject(valueCopy)) {
|
|
95
|
+
const childRes = propertyCleanup(valueCopy[key]);
|
|
94
96
|
if (childRes !== null && childRes !== undefined && childRes !== false && !isEmptyObject(childRes)) {
|
|
95
|
-
|
|
97
|
+
valueCopy[key] = childRes;
|
|
96
98
|
} else {
|
|
97
|
-
delete
|
|
99
|
+
delete valueCopy[key];
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
}
|
|
102
104
|
|
|
103
|
-
delete
|
|
104
|
-
delete
|
|
105
|
-
delete
|
|
106
|
-
delete
|
|
107
|
-
delete
|
|
108
|
-
delete
|
|
105
|
+
delete valueCopy.fromBuilder;
|
|
106
|
+
delete valueCopy.resolved;
|
|
107
|
+
delete valueCopy.propertiesOrder;
|
|
108
|
+
delete valueCopy.propertyConfig;
|
|
109
|
+
delete valueCopy.resolvedProperties;
|
|
110
|
+
delete valueCopy.editable;
|
|
109
111
|
|
|
110
|
-
return
|
|
112
|
+
return valueCopy;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
return {
|