@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/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.145",
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.145",
11
- "@firecms/data_import": "^3.0.0-canary.145",
12
- "@firecms/data_import_export": "^3.0.0-canary.145",
13
- "@firecms/formex": "^3.0.0-canary.145",
14
- "@firecms/schema_inference": "^3.0.0-canary.145",
15
- "@firecms/ui": "^3.0.0-canary.145",
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": "e5d660f00c5806e1b63839c013af3c973f3dd47e"
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({ values: initialValues });
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
- if (typeof value === "function") {
83
- return value;
83
+ const valueCopy = clone(value);
84
+ if (typeof valueCopy === "function") {
85
+ return valueCopy;
84
86
  }
85
- if (Array.isArray(value)) {
86
- return value.map((v: any) => propertyCleanup(v));
87
+ if (Array.isArray(valueCopy)) {
88
+ return valueCopy.map((v: any) => propertyCleanup(v));
87
89
  }
88
- if (typeof value === "object") {
89
- if (value === null)
90
- return value;
91
- Object.keys(value).forEach((key) => {
92
- if (!isEmptyObject(value)) {
93
- const childRes = propertyCleanup(value[key]);
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
- value[key] = childRes;
97
+ valueCopy[key] = childRes;
96
98
  } else {
97
- delete value[key];
99
+ delete valueCopy[key];
98
100
  }
99
101
  }
100
102
  });
101
103
  }
102
104
 
103
- delete value.fromBuilder;
104
- delete value.resolved;
105
- delete value.propertiesOrder;
106
- delete value.propertyConfig;
107
- delete value.resolvedProperties;
108
- delete value.editable;
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 value;
112
+ return valueCopy;
111
113
  }
112
114
 
113
115
  return {
@@ -142,6 +142,7 @@ export const PropertyForm = React.memo(
142
142
  };
143
143
 
144
144
  const formexController = useCreateFormex<PropertyWithId>({
145
+ debugId: "PROPERTY_FORM",
145
146
  initialValues: property
146
147
  ? { id: propertyKey, ...property } as PropertyWithId
147
148
  : initialValue,