@firecms/collection_editor 3.0.0-alpha.19 → 3.0.0-alpha.20

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
- "version": "3.0.0-alpha.19",
3
+ "version": "3.0.0-alpha.20",
4
4
  "main": "./dist/index.umd.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,11 +10,14 @@
10
10
  "import": "./dist/index.es.js",
11
11
  "require": "./dist/index.umd.js",
12
12
  "types": "./dist/index.d.ts"
13
- }
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "dependencies": {
17
+ "@firecms/data_import": "^3.0.0-alpha.20",
18
+ "@firecms/schema_inference": "^3.0.0-alpha.20"
14
19
  },
15
20
  "peerDependencies": {
16
- "@firecms/data_import": "^3.0.0-alpha.9",
17
- "@firecms/schema_inference": "^3.0.0-alpha.9",
18
21
  "react": "^18.2.0",
19
22
  "react-dom": "^18.2.0",
20
23
  "react-router": "^6.12.0",
@@ -72,5 +75,5 @@
72
75
  "publishConfig": {
73
76
  "access": "public"
74
77
  },
75
- "gitHead": "dfac6a681cd88ab0b926eb6fcd94a3a49a43d945"
78
+ "gitHead": "7b74c47b5ea9f490bd0ba3d2b479108484a19411"
76
79
  }
@@ -10,9 +10,11 @@ import {
10
10
  DebouncedTextField,
11
11
  defaultBorderMixin,
12
12
  EntityCollection,
13
- ErrorBoundary, FieldConfig,
13
+ ErrorBoundary,
14
+ FieldConfig,
14
15
  isPropertyBuilder,
15
16
  Paper,
17
+ Properties,
16
18
  Property,
17
19
  PropertyOrBuilder,
18
20
  Tooltip,
@@ -100,6 +102,11 @@ export function CollectionPropertiesEditorForm({
100
102
  // @ts-ignore
101
103
  doCollectionInference(values)
102
104
  .then((newCollection) => {
105
+
106
+ if (newCollection)
107
+ makePropertiesEditable(newCollection.properties as Properties);
108
+ console.log("newCollection", newCollection);
109
+
103
110
  if (!newCollection) {
104
111
  snackbarController.open({
105
112
  type: "error",
@@ -448,3 +455,13 @@ export function CollectionPropertiesEditorForm({
448
455
  </>
449
456
  );
450
457
  }
458
+
459
+ function makePropertiesEditable(properties: Properties) {
460
+ Object.keys(properties).forEach((key) => {
461
+ const property = properties[key];
462
+ property.editable = true;
463
+ if (property.dataType === "map" && property.properties) {
464
+ makePropertiesEditable(property.properties as Properties);
465
+ }
466
+ });
467
+ }
@@ -28,13 +28,20 @@ import { PropertySelectItem } from "../PropertySelectItem";
28
28
  import { supportedFields } from "../utils/supported_fields";
29
29
  import { buildPropertyFromData } from "@firecms/schema_inference";
30
30
 
31
- export function CollectionEditorImportMapping({ importConfig, customFields }:
31
+ export function CollectionEditorImportMapping({
32
+ importConfig,
33
+ customFields
34
+ }:
32
35
  {
33
36
  importConfig: ImportConfig,
34
37
  customFields: Record<string, FieldConfig>
35
38
  }) {
36
39
 
37
- const { setFieldValue, setFieldTouched, values } = useFormikContext<PersistedCollection>();
40
+ const {
41
+ setFieldValue,
42
+ setFieldTouched,
43
+ values
44
+ } = useFormikContext<PersistedCollection>();
38
45
  const [selectedProperty, setSelectedProperty] = useState<PropertyWithId | undefined>(undefined);
39
46
 
40
47
  const currentPropertiesOrderRef = React.useRef<{
@@ -117,11 +124,17 @@ export function CollectionEditorImportMapping({ importConfig, customFields }:
117
124
 
118
125
  // we try to infer the rest of the properties of a property, from the type and the data
119
126
  const propertyData = importConfig.importData.map((d) => getIn(d, importKey));
120
- const inferredNewProperty = buildPropertyFromData(propertyData, property, getInferenceType);
127
+ const inferredNewProperty = {
128
+ ...buildPropertyFromData(propertyData, property, getInferenceType),
129
+ editable: true
130
+ };
121
131
 
122
132
  if (propertyPath) {
123
133
  if (inferredNewProperty) {
124
- console.log("updating inferredNewProperty", { property, inferredNewProperty })
134
+ console.log("updating inferredNewProperty", {
135
+ property,
136
+ inferredNewProperty
137
+ })
125
138
  setFieldValue(propertyPath, inferredNewProperty, false);
126
139
  } else {
127
140
  setFieldValue(propertyPath, property, false);
@@ -142,18 +155,29 @@ export function CollectionEditorImportMapping({ importConfig, customFields }:
142
155
  originProperties={importConfig.originProperties}
143
156
  destinationProperties={values.properties as Properties}
144
157
  onIdPropertyChanged={(value) => importConfig.setIdColumn(value)}
145
- buildPropertyView={({ property, propertyKey, importKey }) => {
158
+ buildPropertyView={({
159
+ property,
160
+ propertyKey,
161
+ importKey
162
+ }) => {
146
163
  return <ImportNewPropertyFieldPreview
147
164
  property={property}
148
165
  propertyKey={propertyKey}
149
166
  onPropertyNameChanged={(propertyKey: string, value: string) => setFieldValue(`properties.${propertyKey}.name`, value, false)}
150
167
  onEditClick={() => {
151
168
  if (!propertyKey || !property) return;
152
- setSelectedProperty({ ...property, id: propertyKey, editable: true });
169
+ setSelectedProperty({
170
+ ...property,
171
+ id: propertyKey,
172
+ editable: true
173
+ });
153
174
  }}
154
175
  propertyTypeView={<PropertySelect property={property}
155
176
  disabled={false}
156
- onPropertyChanged={(props) => onPropertyTypeChanged({ ...props, importKey })}
177
+ onPropertyChanged={(props) => onPropertyTypeChanged({
178
+ ...props,
179
+ importKey
180
+ })}
157
181
  propertyKey={propertyKey}
158
182
  customFields={customFields}/>}
159
183
  />;
@@ -184,10 +208,21 @@ export function CollectionEditorImportMapping({ importConfig, customFields }:
184
208
 
185
209
  }
186
210
 
187
- function PropertySelect({ property, onPropertyChanged, propertyKey, customFields, disabled }: {
211
+ function PropertySelect({
212
+ property,
213
+ onPropertyChanged,
214
+ propertyKey,
215
+ customFields,
216
+ disabled
217
+ }: {
188
218
  property: Property | null,
189
219
  propertyKey: string | null,
190
- onPropertyChanged: ({ id, property, previousId, namespace }: OnPropertyChangedParams) => void,
220
+ onPropertyChanged: ({
221
+ id,
222
+ property,
223
+ previousId,
224
+ namespace
225
+ }: OnPropertyChangedParams) => void,
191
226
  customFields: Record<string, FieldConfig>,
192
227
  disabled?: boolean
193
228
  }) {
@@ -218,7 +253,10 @@ function PropertySelect({ property, onPropertyChanged, propertyKey, customFields
218
253
  const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId, customFields)
219
254
  if (!propertyKey) return;
220
255
  onPropertyChanged({
221
- id: propertyKey, property: newProperty, previousId: propertyKey, namespace: undefined
256
+ id: propertyKey,
257
+ property: newProperty,
258
+ previousId: propertyKey,
259
+ namespace: undefined
222
260
  });
223
261
  console.log("newSelectedWidgetId", newSelectedWidgetId);
224
262
  }}>
@@ -45,8 +45,6 @@ export function joinCollectionLists(storedCollections: PersistedCollection[], co
45
45
  const resultStoredCollections = resolvedFetchedCollections
46
46
  .filter((col) => !updatedCollections.map(c => c.path).includes(col.path) || !updatedCollections.map(c => c.alias).includes(col.alias));
47
47
 
48
- console.log("Updated collections", { updatedCollections, resultStoredCollections });
49
-
50
48
  return [...updatedCollections, ...resultStoredCollections];
51
49
  }
52
50