@firecms/collection_editor 3.0.0-beta.6 → 3.0.0-beta.8
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 +1582 -1520
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +3 -1
- package/dist/ui/CollectionViewHeaderAction.d.ts +3 -2
- package/dist/ui/PropertyAddColumnComponent.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +2 -1
- package/dist/useCollectionEditorPlugin.d.ts +1 -1
- package/package.json +16 -32
- package/src/ConfigControllerProvider.tsx +37 -28
- package/src/types/collection_editor_controller.tsx +5 -3
- package/src/ui/CollectionViewHeaderAction.tsx +6 -3
- package/src/ui/EditorCollectionAction.tsx +9 -12
- package/src/ui/HomePageEditorCollectionAction.tsx +16 -11
- package/src/ui/NewCollectionCard.tsx +3 -3
- package/src/ui/PropertyAddColumnComponent.tsx +6 -3
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +33 -3
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +26 -16
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +2 -2
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +19 -17
- package/src/ui/collection_editor/PropertyEditView.tsx +5 -4
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +3 -6
- package/src/ui/collection_editor/PropertySelectItem.tsx +2 -2
- package/src/ui/collection_editor/PropertyTree.tsx +3 -3
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +1 -1
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +2 -1
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +5 -5
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +5 -5
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +0 -1
- package/src/useCollectionEditorPlugin.tsx +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
4
|
CircularProgressCenter,
|
|
5
|
+
Entity,
|
|
5
6
|
EntityCollection,
|
|
6
7
|
ErrorView,
|
|
7
8
|
isPropertyBuilder,
|
|
@@ -25,7 +26,7 @@ import {
|
|
|
25
26
|
import {
|
|
26
27
|
ArrowBackIcon,
|
|
27
28
|
Button,
|
|
28
|
-
|
|
29
|
+
cls,
|
|
29
30
|
coolIconKeys,
|
|
30
31
|
defaultBorderMixin,
|
|
31
32
|
Dialog,
|
|
@@ -79,6 +80,7 @@ export interface CollectionEditorDialogProps {
|
|
|
79
80
|
getUser?: (uid: string) => User | null;
|
|
80
81
|
getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
|
|
81
82
|
parentCollection?: PersistedCollection;
|
|
83
|
+
existingEntities?: Entity<any>[];
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
export function CollectionEditorDialog(props: CollectionEditorDialogProps) {
|
|
@@ -88,13 +90,13 @@ export function CollectionEditorDialog(props: CollectionEditorDialogProps) {
|
|
|
88
90
|
const [formDirty, setFormDirty] = React.useState<boolean>(false);
|
|
89
91
|
const [unsavedChangesDialogOpen, setUnsavedChangesDialogOpen] = React.useState<boolean>(false);
|
|
90
92
|
|
|
91
|
-
const handleCancel =
|
|
93
|
+
const handleCancel = () => {
|
|
92
94
|
if (!formDirty) {
|
|
93
95
|
props.handleClose(undefined);
|
|
94
96
|
} else {
|
|
95
97
|
setUnsavedChangesDialogOpen(true);
|
|
96
98
|
}
|
|
97
|
-
}
|
|
99
|
+
};
|
|
98
100
|
|
|
99
101
|
useEffect(() => {
|
|
100
102
|
if (!open) {
|
|
@@ -170,7 +172,7 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
|
170
172
|
} catch (e) {
|
|
171
173
|
console.error(e);
|
|
172
174
|
}
|
|
173
|
-
}, [props.editedCollectionId, props.parentCollectionIds, navigation]);
|
|
175
|
+
}, [props.editedCollectionId, props.parentCollectionIds, navigation.initialised, navigation.getCollectionFromPaths]);
|
|
174
176
|
|
|
175
177
|
if (!topLevelNavigation) {
|
|
176
178
|
throw Error("Internal: Navigation not ready in collection editor");
|
|
@@ -244,7 +246,8 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
244
246
|
setCollection,
|
|
245
247
|
initialValues,
|
|
246
248
|
propertyConfigs,
|
|
247
|
-
groups
|
|
249
|
+
groups,
|
|
250
|
+
existingEntities
|
|
248
251
|
}: CollectionEditorDialogProps & {
|
|
249
252
|
handleCancel: () => void,
|
|
250
253
|
setFormDirty: (dirty: boolean) => void,
|
|
@@ -294,7 +297,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
294
297
|
});
|
|
295
298
|
};
|
|
296
299
|
|
|
297
|
-
const setNextMode =
|
|
300
|
+
const setNextMode = () => {
|
|
298
301
|
if (currentView === "details") {
|
|
299
302
|
if (importConfig.inUse) {
|
|
300
303
|
setCurrentView("import_data_saving");
|
|
@@ -315,14 +318,14 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
315
318
|
setCurrentView("details");
|
|
316
319
|
}
|
|
317
320
|
|
|
318
|
-
}
|
|
321
|
+
};
|
|
319
322
|
|
|
320
|
-
const doCollectionInference =
|
|
323
|
+
const doCollectionInference = (collection: PersistedCollection<any>) => {
|
|
321
324
|
if (!collectionInference) return undefined;
|
|
322
325
|
return collectionInference?.(collection.path, collection.collectionGroup ?? false, parentCollectionIds ?? []);
|
|
323
|
-
}
|
|
326
|
+
};
|
|
324
327
|
|
|
325
|
-
const inferCollectionFromData =
|
|
328
|
+
const inferCollectionFromData = async (newCollection: PersistedCollection<M>) => {
|
|
326
329
|
|
|
327
330
|
try {
|
|
328
331
|
if (!doCollectionInference) {
|
|
@@ -366,10 +369,10 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
366
369
|
});
|
|
367
370
|
return newCollection;
|
|
368
371
|
}
|
|
369
|
-
}
|
|
372
|
+
};
|
|
370
373
|
|
|
371
374
|
const onSubmit = (newCollectionState: PersistedCollection<M>, formexController: FormexController<PersistedCollection<M>>) => {
|
|
372
|
-
console.
|
|
375
|
+
console.debug("Submitting collection", newCollectionState);
|
|
373
376
|
try {
|
|
374
377
|
|
|
375
378
|
if (!isNewCollection) {
|
|
@@ -481,7 +484,14 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
481
484
|
|
|
482
485
|
const parentPaths = !pathError && parentCollectionIds ? navigation.convertIdsToPaths(parentCollectionIds) : undefined;
|
|
483
486
|
const resolvedPath = !pathError ? navigation.resolveAliasesFrom(updatedFullPath) : undefined;
|
|
484
|
-
const getDataWithPath = resolvedPath && getData ? () =>
|
|
487
|
+
const getDataWithPath = resolvedPath && getData ? async () => {
|
|
488
|
+
const data = await getData(resolvedPath, parentPaths ?? []);
|
|
489
|
+
if (existingEntities) {
|
|
490
|
+
const existingData = existingEntities.map(e => e.values);
|
|
491
|
+
data.push(...existingData);
|
|
492
|
+
}
|
|
493
|
+
return data;
|
|
494
|
+
} : undefined;
|
|
485
495
|
|
|
486
496
|
useEffect(() => {
|
|
487
497
|
setFormDirty(dirty);
|
|
@@ -526,7 +536,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
526
536
|
|
|
527
537
|
<>
|
|
528
538
|
{!isNewCollection && <Tabs value={currentView}
|
|
529
|
-
className={
|
|
539
|
+
className={cls(defaultBorderMixin, "justify-end bg-gray-50 dark:bg-gray-950 border-b")}
|
|
530
540
|
onValueChange={(v) => setCurrentView(v as EditorView)}>
|
|
531
541
|
<Tab value={"details"}>
|
|
532
542
|
Details
|
|
@@ -541,7 +551,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
541
551
|
|
|
542
552
|
<form noValidate
|
|
543
553
|
onSubmit={formController.handleSubmit}
|
|
544
|
-
className={
|
|
554
|
+
className={cls(
|
|
545
555
|
isNewCollection ? "h-full" : "h-[calc(100%-48px)]",
|
|
546
556
|
"flex-grow flex flex-col relative")}>
|
|
547
557
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { EntityCollection, unslugify, } from "@firecms/core";
|
|
3
|
-
import { Button, Card, Chip, CircularProgress,
|
|
3
|
+
import { Button, Card, Chip, CircularProgress, cls, Container, Icon, Tooltip, Typography, } from "@firecms/ui";
|
|
4
4
|
|
|
5
5
|
import { productsCollectionTemplate } from "./templates/products_template";
|
|
6
6
|
import { blogCollectionTemplate } from "./templates/blog_template";
|
|
@@ -188,7 +188,7 @@ export function TemplateButton({
|
|
|
188
188
|
<Tooltip title={subtitle}>
|
|
189
189
|
<Card
|
|
190
190
|
onClick={onClick}
|
|
191
|
-
className={
|
|
191
|
+
className={cls(
|
|
192
192
|
"my-2 rounded-md border mx-0 p-6 px-4 focus:outline-none transition ease-in-out duration-150 flex flex-row gap-4 items-center",
|
|
193
193
|
"text-gray-700 dark:text-slate-300",
|
|
194
194
|
"hover:border-primary-dark hover:text-primary-dark dark:hover:text-primary focus:ring-primary hover:ring-1 hover:ring-primary",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
4
4
|
import {
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
AutoAwesomeIcon,
|
|
20
20
|
Button,
|
|
21
21
|
CircularProgress,
|
|
22
|
-
|
|
22
|
+
cls,
|
|
23
23
|
CodeIcon,
|
|
24
24
|
DebouncedTextField,
|
|
25
25
|
defaultBorderMixin,
|
|
@@ -158,20 +158,20 @@ export function CollectionPropertiesEditorForm({
|
|
|
158
158
|
}
|
|
159
159
|
: undefined;
|
|
160
160
|
|
|
161
|
-
const getCurrentPropertiesOrder =
|
|
162
|
-
if (!namespace) return currentPropertiesOrderRef.current[""];
|
|
161
|
+
const getCurrentPropertiesOrder = (namespace?: string) => {
|
|
162
|
+
if (!namespace) return currentPropertiesOrderRef.current[""] ?? getIn(values, namespaceToPropertiesOrderPath());
|
|
163
163
|
return currentPropertiesOrderRef.current[namespace] ?? getIn(values, namespaceToPropertiesOrderPath(namespace));
|
|
164
|
-
}
|
|
164
|
+
};
|
|
165
165
|
|
|
166
|
-
const updatePropertiesOrder =
|
|
166
|
+
const updatePropertiesOrder = (newPropertiesOrder: string[], namespace?: string) => {
|
|
167
167
|
const propertiesOrderPath = namespaceToPropertiesOrderPath(namespace);
|
|
168
168
|
|
|
169
169
|
setFieldValue(propertiesOrderPath, newPropertiesOrder, false);
|
|
170
170
|
currentPropertiesOrderRef.current[namespace ?? ""] = newPropertiesOrder;
|
|
171
171
|
|
|
172
|
-
}
|
|
172
|
+
};
|
|
173
173
|
|
|
174
|
-
const deleteProperty =
|
|
174
|
+
const deleteProperty = (propertyKey?: string, namespace?: string) => {
|
|
175
175
|
const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
|
|
176
176
|
if (!fullId)
|
|
177
177
|
throw Error("collection editor miss config");
|
|
@@ -179,15 +179,17 @@ export function CollectionPropertiesEditorForm({
|
|
|
179
179
|
setFieldValue(idToPropertiesPath(fullId), undefined, false);
|
|
180
180
|
|
|
181
181
|
const currentPropertiesOrder = getCurrentPropertiesOrder(namespace);
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
if (currentPropertiesOrder) {
|
|
183
|
+
const newPropertiesOrder = currentPropertiesOrder.filter((p) => p !== propertyKey);
|
|
184
|
+
updatePropertiesOrder(newPropertiesOrder, namespace);
|
|
185
|
+
}
|
|
184
186
|
|
|
185
187
|
setNewPropertyDialogOpen(false);
|
|
186
188
|
|
|
187
189
|
setSelectedPropertyIndex(undefined);
|
|
188
190
|
setSelectedPropertyKey(undefined);
|
|
189
191
|
setSelectedPropertyNamespace(undefined);
|
|
190
|
-
}
|
|
192
|
+
};
|
|
191
193
|
|
|
192
194
|
const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
|
|
193
195
|
setFieldValue(namespaceToPropertiesOrderPath(namespace), propertiesOrder, false);
|
|
@@ -207,8 +209,8 @@ export function CollectionPropertiesEditorForm({
|
|
|
207
209
|
...(values.properties ?? {}),
|
|
208
210
|
[id]: property
|
|
209
211
|
}, false);
|
|
210
|
-
const newPropertiesOrder = [...(values.propertiesOrder ?? Object.keys(values.properties)), id];
|
|
211
212
|
|
|
213
|
+
const newPropertiesOrder = [...(values.propertiesOrder ?? Object.keys(values.properties)), id];
|
|
212
214
|
updatePropertiesOrder(newPropertiesOrder);
|
|
213
215
|
|
|
214
216
|
setNewPropertyDialogOpen(false);
|
|
@@ -273,7 +275,7 @@ export function CollectionPropertiesEditorForm({
|
|
|
273
275
|
|
|
274
276
|
};
|
|
275
277
|
|
|
276
|
-
const onPropertyErrorInternal =
|
|
278
|
+
const onPropertyErrorInternal = (id: string, namespace?: string, error?: Record<string, any>) => {
|
|
277
279
|
const propertyPath = id ? getFullId(id, namespace) : undefined;
|
|
278
280
|
console.debug("onPropertyErrorInternal", {
|
|
279
281
|
id,
|
|
@@ -286,7 +288,7 @@ export function CollectionPropertiesEditorForm({
|
|
|
286
288
|
onPropertyError(id, namespace, hasError ? error : undefined);
|
|
287
289
|
setFieldError(idToPropertiesPath(propertyPath), hasError ? "Property error" : undefined);
|
|
288
290
|
}
|
|
289
|
-
}
|
|
291
|
+
}
|
|
290
292
|
|
|
291
293
|
const closePropertyDialog = () => {
|
|
292
294
|
setSelectedPropertyIndex(undefined);
|
|
@@ -303,7 +305,7 @@ export function CollectionPropertiesEditorForm({
|
|
|
303
305
|
|
|
304
306
|
const owner = useMemo(() => values.ownerId && getUser ? getUser(values.ownerId) : null, [getUser, values.ownerId]);
|
|
305
307
|
|
|
306
|
-
const onPropertyClick =
|
|
308
|
+
const onPropertyClick = (propertyKey: string, namespace?: string) => {
|
|
307
309
|
console.debug("CollectionEditor: onPropertyClick", {
|
|
308
310
|
propertyKey,
|
|
309
311
|
namespace
|
|
@@ -311,11 +313,11 @@ export function CollectionPropertiesEditorForm({
|
|
|
311
313
|
setSelectedPropertyIndex(usedPropertiesOrder.indexOf(propertyKey));
|
|
312
314
|
setSelectedPropertyKey(propertyKey);
|
|
313
315
|
setSelectedPropertyNamespace(namespace);
|
|
314
|
-
}
|
|
316
|
+
};
|
|
315
317
|
|
|
316
318
|
const body = (
|
|
317
319
|
<div className={"grid grid-cols-12 gap-2 h-full bg-gray-50 dark:bg-gray-900"}>
|
|
318
|
-
<div className={
|
|
320
|
+
<div className={cls(
|
|
319
321
|
"p-4 md:p-8 pb-20 md:pb-20",
|
|
320
322
|
"col-span-12 lg:col-span-5 h-full overflow-auto",
|
|
321
323
|
!asDialog && "border-r " + defaultBorderMixin
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@firecms/core";
|
|
18
18
|
import {
|
|
19
19
|
Button,
|
|
20
|
-
|
|
20
|
+
cls,
|
|
21
21
|
DeleteIcon,
|
|
22
22
|
Dialog,
|
|
23
23
|
DialogActions,
|
|
@@ -228,6 +228,7 @@ export const PropertyForm = React.memo(
|
|
|
228
228
|
a.includeIdAndName === b.includeIdAndName &&
|
|
229
229
|
a.autoOpenTypeSelect === b.autoOpenTypeSelect &&
|
|
230
230
|
a.autoUpdateId === b.autoUpdateId &&
|
|
231
|
+
a.existingPropertyKeys === b.existingPropertyKeys &&
|
|
231
232
|
a.existingProperty === b.existingProperty
|
|
232
233
|
);
|
|
233
234
|
|
|
@@ -367,13 +368,13 @@ function PropertyEditFormFields({
|
|
|
367
368
|
}
|
|
368
369
|
}
|
|
369
370
|
}
|
|
370
|
-
}, [deferredValues, includeIdAndTitle,
|
|
371
|
+
}, [deferredValues, includeIdAndTitle, propertyNamespace]);
|
|
371
372
|
|
|
372
373
|
useEffect(() => {
|
|
373
374
|
if (values?.id && onError) {
|
|
374
375
|
onError(values?.id, propertyNamespace, errors);
|
|
375
376
|
}
|
|
376
|
-
}, [errors,
|
|
377
|
+
}, [errors, propertyNamespace, values?.id]);
|
|
377
378
|
|
|
378
379
|
const onWidgetSelectChanged = (newSelectedWidgetId: PropertyConfigId) => {
|
|
379
380
|
setSelectedFieldConfigId(newSelectedWidgetId);
|
|
@@ -508,7 +509,7 @@ function PropertyEditFormFields({
|
|
|
508
509
|
e.preventDefault();
|
|
509
510
|
}
|
|
510
511
|
}}
|
|
511
|
-
className={
|
|
512
|
+
className={cls(
|
|
512
513
|
"flex items-center",
|
|
513
514
|
optionDisabled ? "w-full pointer-events-none opacity-50" : "")}>
|
|
514
515
|
<div className={"mr-8"}>
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
cardClickableMixin,
|
|
12
12
|
cardMixin,
|
|
13
13
|
cardSelectedMixin,
|
|
14
|
-
|
|
14
|
+
cls,
|
|
15
15
|
FunctionsIcon,
|
|
16
16
|
Paper,
|
|
17
17
|
RemoveCircleIcon,
|
|
@@ -45,9 +45,6 @@ export function PropertyFieldPreview({
|
|
|
45
45
|
? "border-red-500 dark:border-red-500 border-opacity-100 dark:border-opacity-100 ring-0 dark:ring-0"
|
|
46
46
|
: (selected ? "border-primary" : "border-transparent");
|
|
47
47
|
|
|
48
|
-
if(hasError)
|
|
49
|
-
console.log("PropertyFieldPreview", property)
|
|
50
|
-
|
|
51
48
|
return <ErrorBoundary>
|
|
52
49
|
<div
|
|
53
50
|
onClick={onClick}
|
|
@@ -56,7 +53,7 @@ export function PropertyFieldPreview({
|
|
|
56
53
|
<PropertyConfigBadge propertyConfig={propertyConfig}/>
|
|
57
54
|
</div>
|
|
58
55
|
<Paper
|
|
59
|
-
className={
|
|
56
|
+
className={cls(
|
|
60
57
|
"border",
|
|
61
58
|
"pl-2 w-full flex flex-row gap-4 items-center",
|
|
62
59
|
cardMixin,
|
|
@@ -139,7 +136,7 @@ export function NonEditablePropertyPreview({
|
|
|
139
136
|
<RemoveCircleIcon color={"disabled"} size={"small"} className={"absolute -right-2 -top-2"}/>
|
|
140
137
|
</div>
|
|
141
138
|
<Paper
|
|
142
|
-
className={
|
|
139
|
+
className={cls(
|
|
143
140
|
"pl-2 w-full flex flex-row gap-4 items-center",
|
|
144
141
|
cardMixin,
|
|
145
142
|
onClick ? cardClickableMixin : "",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PropertyConfigBadge, PropertyConfig } from "@firecms/core";
|
|
2
|
-
import {
|
|
2
|
+
import { cls, SelectItem, Typography } from "@firecms/ui";
|
|
3
3
|
|
|
4
4
|
export interface PropertySelectItemProps {
|
|
5
5
|
value: string;
|
|
@@ -13,7 +13,7 @@ export function PropertySelectItem({ value, optionDisabled, propertyConfig, exis
|
|
|
13
13
|
disabled={optionDisabled}
|
|
14
14
|
className={"flex flex-row items-center"}>
|
|
15
15
|
<div
|
|
16
|
-
className={
|
|
16
|
+
className={cls(
|
|
17
17
|
"flex flex-row items-center text-base min-h-[52px]",
|
|
18
18
|
optionDisabled ? "w-full" : "")}>
|
|
19
19
|
<div className={"mr-8"}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
import equal from "react-fast-compare"
|
|
3
3
|
|
|
4
4
|
import {
|
|
@@ -48,7 +48,7 @@ export const PropertyTree = React.memo(
|
|
|
48
48
|
|
|
49
49
|
const propertiesOrder = propertiesOrderProp ?? Object.keys(properties);
|
|
50
50
|
|
|
51
|
-
const onDragEnd =
|
|
51
|
+
const onDragEnd = (result: any) => {
|
|
52
52
|
// dropped outside the list
|
|
53
53
|
if (!result.destination) {
|
|
54
54
|
return;
|
|
@@ -61,7 +61,7 @@ export const PropertyTree = React.memo(
|
|
|
61
61
|
newPropertiesOrder.splice(endIndex, 0, removed);
|
|
62
62
|
if (onPropertyMove)
|
|
63
63
|
onPropertyMove(newPropertiesOrder, namespace);
|
|
64
|
-
}
|
|
64
|
+
}
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
67
|
<>
|
|
@@ -135,7 +135,7 @@ export function SubcollectionsEditTab({
|
|
|
135
135
|
{totalEntityViews === 0 &&
|
|
136
136
|
<Alert action={<Button variant="text"
|
|
137
137
|
size={"small"}
|
|
138
|
-
href={"https://firecms.co/docs/
|
|
138
|
+
href={"https://firecms.co/docs/cloud/quickstart"}
|
|
139
139
|
component={"a"}
|
|
140
140
|
rel="noopener noreferrer"
|
|
141
141
|
target="_blank">More info</Button>}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import { AddIcon, Button, Paper, Typography } from "@firecms/ui";
|
|
3
3
|
import { getIn, useFormex } from "@firecms/formex";
|
|
4
4
|
import { PropertyFormDialog } from "../PropertyEditView";
|
|
@@ -49,7 +49,7 @@ export function BlockPropertyField({
|
|
|
49
49
|
const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : undefined;
|
|
50
50
|
const selectedProperty = selectedPropertyFullId ? getIn(values.oneOf?.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : undefined;
|
|
51
51
|
|
|
52
|
-
const deleteProperty =
|
|
52
|
+
const deleteProperty = (propertyKey?: string, namespace?: string) => {
|
|
53
53
|
const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
|
|
54
54
|
if (!fullId)
|
|
55
55
|
throw Error("collection editor miss config");
|
|
@@ -62,7 +62,7 @@ export function BlockPropertyField({
|
|
|
62
62
|
setPropertyDialogOpen(false);
|
|
63
63
|
setSelectedPropertyKey(undefined);
|
|
64
64
|
setSelectedPropertyNamespace(undefined);
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
66
|
|
|
67
67
|
const addChildButton = <Button
|
|
68
68
|
autoFocus
|
|
@@ -74,9 +74,9 @@ export function BlockPropertyField({
|
|
|
74
74
|
Add property to {values.name ?? "this block"}
|
|
75
75
|
</Button>;
|
|
76
76
|
|
|
77
|
-
const onPropertyMove =
|
|
77
|
+
const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
|
|
78
78
|
setFieldValue(`oneOf.${namespaceToPropertiesOrderPath(namespace)}`, propertiesOrder, false);
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
82
|
<>
|
|
@@ -71,7 +71,7 @@ export function EnumPropertyField({
|
|
|
71
71
|
}}
|
|
72
72
|
getData={getData
|
|
73
73
|
? () => getData()
|
|
74
|
-
.then(res => res.map(
|
|
74
|
+
.then(res => res.map(entry => values.id && getIn(entry, values.id)).filter(Boolean))
|
|
75
75
|
: undefined}
|
|
76
76
|
onValuesChanged={onValuesChanged}/>
|
|
77
77
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import { FieldCaption, MapProperty, Property, PropertyConfig, } from "@firecms/core";
|
|
3
3
|
import { AddIcon, BooleanSwitchWithLabel, Button, Paper, Typography } from "@firecms/ui";
|
|
4
4
|
import { PropertyFormDialog } from "../PropertyEditView";
|
|
@@ -42,7 +42,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
|
|
|
42
42
|
setPropertyDialogOpen(false);
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const deleteProperty =
|
|
45
|
+
const deleteProperty = (propertyKey?: string, namespace?: string) => {
|
|
46
46
|
const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
|
|
47
47
|
if (!fullId)
|
|
48
48
|
throw Error("collection editor miss config");
|
|
@@ -58,16 +58,16 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
|
|
|
58
58
|
setPropertyDialogOpen(false);
|
|
59
59
|
setSelectedPropertyKey(undefined);
|
|
60
60
|
setSelectedPropertyNamespace(undefined);
|
|
61
|
-
}
|
|
61
|
+
};
|
|
62
62
|
|
|
63
63
|
const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : undefined;
|
|
64
64
|
const selectedProperty = selectedPropertyFullId ? getIn(values.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : undefined;
|
|
65
65
|
|
|
66
66
|
const empty = !propertiesOrder || propertiesOrder.length < 1;
|
|
67
67
|
|
|
68
|
-
const onPropertyMove =
|
|
68
|
+
const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
|
|
69
69
|
setFieldValue(namespaceToPropertiesOrderPath(namespace), propertiesOrder, false);
|
|
70
|
-
}
|
|
70
|
+
};
|
|
71
71
|
|
|
72
72
|
return (
|
|
73
73
|
<>
|
|
@@ -39,7 +39,6 @@ export function RepeatPropertyField({
|
|
|
39
39
|
|
|
40
40
|
const onPropertyChanged = ({ id, property, namespace }:
|
|
41
41
|
{ id?: string, property: Property, namespace?: string }) => {
|
|
42
|
-
console.log("onPropertyChanged", id, property, namespace);
|
|
43
42
|
setFieldValue("of", property);
|
|
44
43
|
};
|
|
45
44
|
|
|
@@ -60,7 +60,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
|
|
|
60
60
|
* @param configPermissions
|
|
61
61
|
* @param reservedGroups
|
|
62
62
|
* @param extraView
|
|
63
|
-
* @param
|
|
63
|
+
* @param getData
|
|
64
64
|
* @param getUser
|
|
65
65
|
* @param collectionInference
|
|
66
66
|
*/
|
|
@@ -125,7 +125,7 @@ export function IntroWidget({}: {}) {
|
|
|
125
125
|
}).createCollections
|
|
126
126
|
: true;
|
|
127
127
|
|
|
128
|
-
if (!navigation.initialised ||
|
|
128
|
+
if (!navigation.initialised || (navigation.collections ?? []).length > 0) {
|
|
129
129
|
return null;
|
|
130
130
|
}
|
|
131
131
|
|