@firecms/collection_editor 3.0.0-canary.20 → 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.
- package/LICENSE +114 -21
- package/dist/ConfigControllerProvider.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +10061 -4770
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +10751 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +4 -2
- package/dist/types/collection_inference.d.ts +1 -1
- package/dist/types/config_permissions.d.ts +2 -2
- package/dist/types/persisted_collection.d.ts +1 -1
- package/dist/ui/CollectionViewHeaderAction.d.ts +3 -2
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/PropertyAddColumnComponent.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionDetailsForm.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +3 -2
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +1 -1
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +1 -1
- package/dist/ui/collection_editor/LayoutModeSwitch.d.ts +5 -0
- package/dist/ui/collection_editor/PropertyEditView.d.ts +8 -0
- package/dist/ui/collection_editor/PropertyTree.d.ts +9 -9
- package/dist/ui/collection_editor/SubcollectionsEditTab.d.ts +1 -1
- package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +7 -0
- package/dist/ui/collection_editor/properties/MarkdownPropertyField.d.ts +4 -0
- package/dist/ui/collection_editor/properties/StringPropertyField.d.ts +1 -1
- package/dist/useCollectionEditorPlugin.d.ts +8 -11
- package/dist/utils/collections.d.ts +6 -0
- package/package.json +24 -35
- package/src/ConfigControllerProvider.tsx +67 -64
- package/src/index.ts +1 -0
- package/src/types/collection_editor_controller.tsx +7 -4
- package/src/types/collection_inference.ts +1 -1
- package/src/types/config_permissions.ts +1 -1
- package/src/types/persisted_collection.ts +2 -3
- package/src/ui/CollectionViewHeaderAction.tsx +10 -5
- package/src/ui/EditorCollectionAction.tsx +10 -63
- package/src/ui/EditorCollectionActionStart.tsx +88 -0
- package/src/ui/HomePageEditorCollectionAction.tsx +19 -13
- package/src/ui/NewCollectionButton.tsx +1 -1
- package/src/ui/NewCollectionCard.tsx +3 -3
- package/src/ui/PropertyAddColumnComponent.tsx +11 -6
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +88 -11
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +101 -34
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +8 -7
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +39 -36
- package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +6 -5
- package/src/ui/collection_editor/EnumForm.tsx +10 -6
- package/src/ui/collection_editor/GetCodeDialog.tsx +56 -26
- package/src/ui/collection_editor/LayoutModeSwitch.tsx +54 -0
- package/src/ui/collection_editor/PropertyEditView.tsx +257 -79
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +7 -10
- package/src/ui/collection_editor/PropertyTree.tsx +9 -7
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +26 -19
- package/src/ui/collection_editor/UnsavedChangesDialog.tsx +3 -5
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +26 -9
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +42 -9
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +32 -20
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +54 -47
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +3 -1
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +7 -6
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +139 -0
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +2 -0
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +0 -1
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +34 -19
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +1 -10
- package/src/ui/collection_editor/properties/UrlPropertyField.tsx +1 -0
- package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +2 -2
- package/src/ui/collection_editor/templates/pages_template.ts +1 -6
- package/src/useCollectionEditorPlugin.tsx +33 -32
- package/src/utils/collections.ts +36 -0
- package/dist/ui/RootCollectionSuggestions.d.ts +0 -3
- package/dist/ui/collection_editor/PropertySelectItem.d.ts +0 -8
- package/src/ui/RootCollectionSuggestions.tsx +0 -63
- package/src/ui/collection_editor/PropertySelectItem.tsx +0 -32
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
3
|
+
ConfirmationDialog,
|
|
4
4
|
EntityCollection,
|
|
5
5
|
EntityCustomView,
|
|
6
6
|
resolveEntityView,
|
|
@@ -41,7 +41,7 @@ export function SubcollectionsEditTab({
|
|
|
41
41
|
parentCollection?: EntityCollection,
|
|
42
42
|
configController: CollectionsConfigController;
|
|
43
43
|
collectionInference?: CollectionInference;
|
|
44
|
-
getUser
|
|
44
|
+
getUser?: (uid: string) => User | null;
|
|
45
45
|
parentCollectionIds?: string[];
|
|
46
46
|
}) {
|
|
47
47
|
|
|
@@ -61,7 +61,7 @@ export function SubcollectionsEditTab({
|
|
|
61
61
|
setFieldValue,
|
|
62
62
|
} = useFormex<EntityCollection>();
|
|
63
63
|
|
|
64
|
-
const subcollections = collection.subcollections ?? [];
|
|
64
|
+
const [subcollections, setSubcollections] = React.useState<EntityCollection[]>(collection.subcollections ?? []);
|
|
65
65
|
const resolvedEntityViews = values.entityViews?.filter(e => typeof e === "string")
|
|
66
66
|
.map(e => resolveEntityView(e, contextEntityViews))
|
|
67
67
|
.filter(Boolean) as EntityCustomView[] ?? [];
|
|
@@ -95,7 +95,8 @@ export function SubcollectionsEditTab({
|
|
|
95
95
|
</TableCell>
|
|
96
96
|
<TableCell
|
|
97
97
|
align="right">
|
|
98
|
-
<Tooltip title={"Remove"}
|
|
98
|
+
<Tooltip title={"Remove"}
|
|
99
|
+
asChild={true}>
|
|
99
100
|
<IconButton size="small"
|
|
100
101
|
onClick={(e) => {
|
|
101
102
|
e.preventDefault();
|
|
@@ -135,7 +136,7 @@ export function SubcollectionsEditTab({
|
|
|
135
136
|
{totalEntityViews === 0 &&
|
|
136
137
|
<Alert action={<Button variant="text"
|
|
137
138
|
size={"small"}
|
|
138
|
-
href={"https://firecms.co/docs/
|
|
139
|
+
href={"https://firecms.co/docs/cloud/quickstart"}
|
|
139
140
|
component={"a"}
|
|
140
141
|
rel="noopener noreferrer"
|
|
141
142
|
target="_blank">More info</Button>}>
|
|
@@ -157,7 +158,8 @@ export function SubcollectionsEditTab({
|
|
|
157
158
|
</TableCell>
|
|
158
159
|
<TableCell
|
|
159
160
|
align="right">
|
|
160
|
-
<Tooltip title={"Remove"}
|
|
161
|
+
<Tooltip title={"Remove"}
|
|
162
|
+
asChild={true}>
|
|
161
163
|
<IconButton size="small"
|
|
162
164
|
onClick={(e) => {
|
|
163
165
|
e.preventDefault();
|
|
@@ -209,30 +211,32 @@ export function SubcollectionsEditTab({
|
|
|
209
211
|
<div style={{ height: "52px" }}/>
|
|
210
212
|
|
|
211
213
|
{subcollectionToDelete &&
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
+
<ConfirmationDialog open={Boolean(subcollectionToDelete)}
|
|
215
|
+
onAccept={() => {
|
|
214
216
|
const props = {
|
|
215
217
|
id: subcollectionToDelete,
|
|
216
218
|
parentCollectionIds: [...(parentCollectionIds ?? []), collection.id]
|
|
217
219
|
};
|
|
218
220
|
console.debug("Deleting subcollection", props)
|
|
219
|
-
configController.deleteCollection(props)
|
|
220
|
-
|
|
221
|
+
configController.deleteCollection(props).then(() => {
|
|
222
|
+
setSubcollectionToDelete(undefined);
|
|
223
|
+
setSubcollections(subcollections?.filter(e => e.id !== subcollectionToDelete))
|
|
224
|
+
});
|
|
221
225
|
}}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
onCancel={() => setSubcollectionToDelete(undefined)}
|
|
227
|
+
title={<>Delete this subcollection?</>}
|
|
228
|
+
body={<> This will <b>not
|
|
225
229
|
delete any data</b>, only
|
|
226
230
|
the collection in the CMS</>}/>}
|
|
227
231
|
{viewToDelete &&
|
|
228
|
-
<
|
|
229
|
-
|
|
232
|
+
<ConfirmationDialog open={Boolean(viewToDelete)}
|
|
233
|
+
onAccept={() => {
|
|
230
234
|
setFieldValue("entityViews", values.entityViews?.filter(e => e !== viewToDelete));
|
|
231
235
|
setViewToDelete(undefined);
|
|
232
236
|
}}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
237
|
+
onCancel={() => setViewToDelete(undefined)}
|
|
238
|
+
title={<>Remove this view?</>}
|
|
239
|
+
body={<>This will <b>not
|
|
236
240
|
delete any data</b>, only
|
|
237
241
|
the view in the CMS</>}/>}
|
|
238
242
|
|
|
@@ -245,7 +249,10 @@ export function SubcollectionsEditTab({
|
|
|
245
249
|
isNewCollection={false}
|
|
246
250
|
{...currentDialog}
|
|
247
251
|
getUser={getUser}
|
|
248
|
-
handleClose={() => {
|
|
252
|
+
handleClose={(updatedCollection) => {
|
|
253
|
+
if (updatedCollection && !subcollections.map(e => e.id).includes(updatedCollection.id)) {
|
|
254
|
+
setSubcollections([...subcollections, updatedCollection]);
|
|
255
|
+
}
|
|
249
256
|
setCurrentDialog(undefined);
|
|
250
257
|
}}/>
|
|
251
258
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Button, Dialog, DialogActions, DialogContent, Typography } from "@firecms/ui";
|
|
2
|
+
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@firecms/ui";
|
|
3
3
|
|
|
4
4
|
export interface UnsavedChangesDialogProps {
|
|
5
5
|
open: boolean;
|
|
@@ -24,11 +24,9 @@ export function UnsavedChangesDialog({
|
|
|
24
24
|
aria-labelledby="alert-dialog-title"
|
|
25
25
|
aria-describedby="alert-dialog-description"
|
|
26
26
|
>
|
|
27
|
-
<DialogContent>
|
|
28
|
-
<Typography variant={"h6"}>
|
|
29
|
-
{title ?? "Unsaved changes"}
|
|
30
|
-
</Typography>
|
|
31
27
|
|
|
28
|
+
<DialogTitle>{title ?? "Unsaved changes"}</DialogTitle>
|
|
29
|
+
<DialogContent>
|
|
32
30
|
{body && <Typography>
|
|
33
31
|
{body}
|
|
34
32
|
</Typography>}
|
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
import { convertDataToEntity,
|
|
2
|
-
import { EntityCollectionTable, Properties, useSelectionController } from "@firecms/core";
|
|
3
|
-
import { useEffect } from "react";
|
|
1
|
+
import { convertDataToEntity, ImportConfig } from "@firecms/data_import_export";
|
|
2
|
+
import { CircularProgressCenter, EntityCollectionTable, Properties, useSelectionController } from "@firecms/core";
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
4
|
import { Typography } from "@firecms/ui";
|
|
5
5
|
|
|
6
|
-
export function CollectionEditorImportDataPreview({
|
|
6
|
+
export function CollectionEditorImportDataPreview({
|
|
7
|
+
importConfig,
|
|
8
|
+
properties,
|
|
9
|
+
propertiesOrder
|
|
10
|
+
}: {
|
|
7
11
|
importConfig: ImportConfig,
|
|
8
12
|
properties: Properties,
|
|
9
13
|
propertiesOrder: string[]
|
|
10
14
|
}) {
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
17
|
+
|
|
18
|
+
async function loadEntities() {
|
|
19
|
+
// const propertiesMapping = getPropertiesMapping(importConfig.originProperties, properties, importConfig.headersMapping);
|
|
20
|
+
const mappedData = importConfig.importData.map(d => convertDataToEntity(d, importConfig.idColumn, importConfig.headersMapping, properties, "TEMP_PATH", importConfig.defaultValues));
|
|
15
21
|
importConfig.setEntities(mappedData);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
loadEntities().finally(() => setLoading(false));
|
|
16
26
|
}, []);
|
|
17
27
|
|
|
18
28
|
const selectionController = useSelectionController();
|
|
29
|
+
if (loading)
|
|
30
|
+
return <CircularProgressCenter/>
|
|
19
31
|
|
|
20
32
|
return <EntityCollectionTable
|
|
21
33
|
title={<div>
|
|
@@ -31,7 +43,12 @@ export function CollectionEditorImportDataPreview({ importConfig, properties, pr
|
|
|
31
43
|
filterable={false}
|
|
32
44
|
sortable={false}
|
|
33
45
|
selectionController={selectionController}
|
|
34
|
-
displayedColumnIds={propertiesOrder.map(p => ({
|
|
35
|
-
|
|
46
|
+
displayedColumnIds={propertiesOrder.map(p => ({
|
|
47
|
+
key: p,
|
|
48
|
+
disabled: false
|
|
49
|
+
}))}
|
|
50
|
+
openEntityMode={"side_panel"}
|
|
51
|
+
properties={properties}
|
|
52
|
+
enablePopupIcon={false}/>
|
|
36
53
|
|
|
37
54
|
}
|
|
@@ -6,14 +6,13 @@ import {
|
|
|
6
6
|
} from "@firecms/data_import_export";
|
|
7
7
|
import { getIn, useFormex } from "@firecms/formex";
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import { Container, Select, Tooltip, Typography } from "@firecms/ui";
|
|
9
|
+
import { getFieldConfig, getFieldId, Properties, Property, PropertyConfig, PropertyConfigBadge, } from "@firecms/core";
|
|
10
|
+
import { cls, Container, Select, SelectItem, Tooltip, Typography } from "@firecms/ui";
|
|
11
11
|
import React, { useState } from "react";
|
|
12
12
|
import { OnPropertyChangedParams, PropertyFormDialog, PropertyWithId } from "../PropertyEditView";
|
|
13
13
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
|
|
14
14
|
import { PersistedCollection } from "../../../types/persisted_collection";
|
|
15
15
|
import { updatePropertyFromWidget } from "../utils/update_property_for_widget";
|
|
16
|
-
import { PropertySelectItem } from "../PropertySelectItem";
|
|
17
16
|
import { supportedFields } from "../utils/supported_fields";
|
|
18
17
|
import { buildPropertyFromData } from "@firecms/schema_inference";
|
|
19
18
|
|
|
@@ -143,18 +142,20 @@ export function CollectionEditorImportMapping({
|
|
|
143
142
|
<div className={"overflow-auto my-auto"}>
|
|
144
143
|
<Container maxWidth={"6xl"} className={"flex flex-col gap-4 p-8 m-auto"}>
|
|
145
144
|
|
|
146
|
-
<Typography variant="h6" className={"
|
|
145
|
+
<Typography variant="h6" className={"my-4 ml-3.5"}>Data property mapping</Typography>
|
|
147
146
|
|
|
148
|
-
<DataNewPropertiesMapping
|
|
149
|
-
idColumn={importConfig.idColumn}
|
|
150
|
-
originProperties={importConfig.originProperties}
|
|
147
|
+
<DataNewPropertiesMapping importConfig={importConfig}
|
|
151
148
|
destinationProperties={values.properties as Properties}
|
|
152
|
-
onIdPropertyChanged={(value) => importConfig.setIdColumn(value ?? undefined)}
|
|
153
149
|
buildPropertyView={({
|
|
154
150
|
property,
|
|
155
151
|
propertyKey,
|
|
156
|
-
importKey
|
|
152
|
+
importKey,
|
|
153
|
+
isIdColumn
|
|
157
154
|
}) => {
|
|
155
|
+
if (isIdColumn) {
|
|
156
|
+
return <Typography> This column will be used as ID</Typography>
|
|
157
|
+
}
|
|
158
|
+
|
|
158
159
|
return <ImportNewPropertyFieldPreview
|
|
159
160
|
property={property}
|
|
160
161
|
propertyKey={propertyKey}
|
|
@@ -234,9 +235,11 @@ function PropertySelect({
|
|
|
234
235
|
open={selectOpen}
|
|
235
236
|
onOpenChange={setSelectOpen}
|
|
236
237
|
invisible={true}
|
|
238
|
+
size={"large"}
|
|
237
239
|
className={"w-full"}
|
|
238
240
|
disabled={disabled}
|
|
239
241
|
error={!widget}
|
|
242
|
+
fullWidth={true}
|
|
240
243
|
value={fieldId ?? ""}
|
|
241
244
|
placeholder={"Select a property widget"}
|
|
242
245
|
position={"item-aligned"}
|
|
@@ -266,3 +269,33 @@ function PropertySelect({
|
|
|
266
269
|
</Select>
|
|
267
270
|
</Tooltip>;
|
|
268
271
|
}
|
|
272
|
+
|
|
273
|
+
export interface PropertySelectItemProps {
|
|
274
|
+
value: string;
|
|
275
|
+
optionDisabled: boolean;
|
|
276
|
+
propertyConfig: PropertyConfig;
|
|
277
|
+
existing: boolean;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function PropertySelectItem({ value, optionDisabled, propertyConfig, existing }: PropertySelectItemProps) {
|
|
281
|
+
return <SelectItem value={value}
|
|
282
|
+
disabled={optionDisabled}
|
|
283
|
+
className={"flex flex-row items-center"}>
|
|
284
|
+
<div
|
|
285
|
+
className={cls(
|
|
286
|
+
"flex flex-row items-center text-base min-h-[48px]",
|
|
287
|
+
optionDisabled ? "w-full" : "")}>
|
|
288
|
+
<div className={"mr-8"}>
|
|
289
|
+
<PropertyConfigBadge propertyConfig={propertyConfig}/>
|
|
290
|
+
</div>
|
|
291
|
+
<div>
|
|
292
|
+
<div>{propertyConfig.name}</div>
|
|
293
|
+
<Typography variant={"caption"}
|
|
294
|
+
color={"disabled"}
|
|
295
|
+
className={"max-w-sm"}>
|
|
296
|
+
{existing && optionDisabled ? "You can only switch to widgets that use the same data type" : propertyConfig.description}
|
|
297
|
+
</Typography>
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
</SelectItem>
|
|
301
|
+
}
|
|
@@ -1,12 +1,24 @@
|
|
|
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
|
-
import { PropertyFormDialog } from "../PropertyEditView";
|
|
5
|
-
import {
|
|
4
|
+
import { OnPropertyChangedParams, PropertyFormDialog } from "../PropertyEditView";
|
|
5
|
+
import {
|
|
6
|
+
getFullId,
|
|
7
|
+
getFullIdPath,
|
|
8
|
+
idToPropertiesPath,
|
|
9
|
+
namespaceToPropertiesOrderPath,
|
|
10
|
+
namespaceToPropertiesPath
|
|
11
|
+
} from "../util";
|
|
6
12
|
import { PropertyTree } from "../PropertyTree";
|
|
7
|
-
import { ArrayProperty,
|
|
8
|
-
|
|
9
|
-
export function BlockPropertyField({
|
|
13
|
+
import { ArrayProperty, PropertyConfig } from "@firecms/core";
|
|
14
|
+
|
|
15
|
+
export function BlockPropertyField({
|
|
16
|
+
disabled,
|
|
17
|
+
getData,
|
|
18
|
+
allowDataInference,
|
|
19
|
+
propertyConfigs,
|
|
20
|
+
collectionEditable
|
|
21
|
+
}: {
|
|
10
22
|
disabled: boolean;
|
|
11
23
|
getData?: () => Promise<object[]>;
|
|
12
24
|
allowDataInference: boolean;
|
|
@@ -25,38 +37,37 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, prop
|
|
|
25
37
|
|
|
26
38
|
const onPropertyChanged = ({
|
|
27
39
|
id,
|
|
40
|
+
namespace,
|
|
28
41
|
property
|
|
29
|
-
}:
|
|
42
|
+
}: OnPropertyChangedParams) => {
|
|
30
43
|
if (!id)
|
|
31
44
|
throw Error();
|
|
32
45
|
|
|
33
|
-
setFieldValue("oneOf.
|
|
34
|
-
|
|
35
|
-
[id]: property
|
|
36
|
-
}, false);
|
|
46
|
+
setFieldValue("oneOf." + getFullIdPath(id, namespace), property, false);
|
|
47
|
+
|
|
37
48
|
const currentPropertiesOrder = values.oneOf?.propertiesOrder ?? Object.keys(values.oneOf?.properties ?? {});
|
|
38
49
|
const newPropertiesOrder = currentPropertiesOrder.includes(id) ? currentPropertiesOrder : [...currentPropertiesOrder, id];
|
|
39
|
-
setFieldValue("oneOf.
|
|
50
|
+
setFieldValue("oneOf." + namespaceToPropertiesOrderPath(namespace), newPropertiesOrder, false);
|
|
40
51
|
setPropertyDialogOpen(false);
|
|
41
52
|
};
|
|
42
53
|
|
|
43
54
|
const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : undefined;
|
|
44
55
|
const selectedProperty = selectedPropertyFullId ? getIn(values.oneOf?.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : undefined;
|
|
45
56
|
|
|
46
|
-
const deleteProperty =
|
|
57
|
+
const deleteProperty = (propertyKey?: string, namespace?: string) => {
|
|
47
58
|
const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
|
|
48
59
|
if (!fullId)
|
|
49
60
|
throw Error("collection editor miss config");
|
|
50
61
|
|
|
51
62
|
setFieldValue(`oneOf.${idToPropertiesPath(fullId)}`, undefined, false);
|
|
52
63
|
const propertiesOrderPath = `oneOf.${namespaceToPropertiesOrderPath(namespace)}`;
|
|
53
|
-
const currentPropertiesOrder: string[] = getIn(values, propertiesOrderPath);
|
|
64
|
+
const currentPropertiesOrder: string[] = getIn(values, propertiesOrderPath) ?? Object.keys(getIn(values, namespaceToPropertiesPath(namespace)));
|
|
54
65
|
setFieldValue(propertiesOrderPath, currentPropertiesOrder.filter((p) => p !== propertyKey), false);
|
|
55
66
|
|
|
56
67
|
setPropertyDialogOpen(false);
|
|
57
68
|
setSelectedPropertyKey(undefined);
|
|
58
69
|
setSelectedPropertyNamespace(undefined);
|
|
59
|
-
}
|
|
70
|
+
};
|
|
60
71
|
|
|
61
72
|
const addChildButton = <Button
|
|
62
73
|
autoFocus
|
|
@@ -68,16 +79,17 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, prop
|
|
|
68
79
|
Add property to {values.name ?? "this block"}
|
|
69
80
|
</Button>;
|
|
70
81
|
|
|
71
|
-
const onPropertyMove =
|
|
82
|
+
const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
|
|
72
83
|
setFieldValue(`oneOf.${namespaceToPropertiesOrderPath(namespace)}`, propertiesOrder, false);
|
|
73
|
-
}
|
|
84
|
+
};
|
|
74
85
|
|
|
75
86
|
return (
|
|
76
87
|
<>
|
|
77
88
|
<div className={"col-span-12"}>
|
|
78
89
|
<div className={"flex justify-between items-end mt-8 mb-4"}>
|
|
79
|
-
<Typography variant={"subtitle2"}>
|
|
80
|
-
block
|
|
90
|
+
<Typography variant={"subtitle2"}>
|
|
91
|
+
Properties in this block
|
|
92
|
+
</Typography>
|
|
81
93
|
{addChildButton}
|
|
82
94
|
</div>
|
|
83
95
|
<Paper className="p-2 pl-8">
|
|
@@ -98,7 +110,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, prop
|
|
|
98
110
|
? undefined
|
|
99
111
|
: onPropertyMove}/>
|
|
100
112
|
|
|
101
|
-
{!disabled &&
|
|
113
|
+
{!disabled && (values.oneOf?.propertiesOrder?.length === 0)&&
|
|
102
114
|
<div className="h-full flex items-center justify-center p-4">
|
|
103
115
|
Add the first property to this block
|
|
104
116
|
</div>}
|
|
@@ -26,53 +26,60 @@ export function DateTimePropertyField({ disabled }: {
|
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<>
|
|
29
|
-
<div className={"flex flex-col col-span-12"}>
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
29
|
+
<div className={"flex flex-col col-span-12 gap-2"}>
|
|
30
|
+
<div>
|
|
31
|
+
<Select name={modePath}
|
|
32
|
+
value={modeValue ?? "date"}
|
|
33
|
+
error={Boolean(modeError)}
|
|
34
|
+
size={"large"}
|
|
35
|
+
onValueChange={(v) => setFieldValue(modePath, v)}
|
|
36
|
+
label={"Mode"}
|
|
37
|
+
fullWidth={true}
|
|
38
|
+
renderValue={(v) => {
|
|
39
|
+
switch (v) {
|
|
40
|
+
case "date_time":
|
|
41
|
+
return "Date/Time";
|
|
42
|
+
case "date":
|
|
43
|
+
return "Date";
|
|
44
|
+
default:
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
}}
|
|
48
|
+
disabled={disabled}>
|
|
49
|
+
<SelectItem value={"date_time"}> Date/Time </SelectItem>
|
|
50
|
+
<SelectItem value={"date"}> Date </SelectItem>
|
|
51
|
+
</Select>
|
|
52
|
+
<FieldCaption error={Boolean(modeError)}>
|
|
53
|
+
{modeError}
|
|
54
|
+
</FieldCaption>
|
|
55
|
+
</div>
|
|
56
|
+
<div>
|
|
57
|
+
<Select name={autoValuePath}
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
size={"large"}
|
|
60
|
+
fullWidth={true}
|
|
61
|
+
value={autoValueValue ?? ""}
|
|
62
|
+
onValueChange={(v) => setFieldValue(autoValuePath, v === "none" ? null : v)}
|
|
63
|
+
renderValue={(v) => {
|
|
64
|
+
switch (v) {
|
|
65
|
+
case "on_create":
|
|
66
|
+
return "On create";
|
|
67
|
+
case "on_update":
|
|
68
|
+
return "On any update";
|
|
69
|
+
default:
|
|
70
|
+
return "None";
|
|
71
|
+
}
|
|
72
|
+
}}
|
|
73
|
+
error={Boolean(autoValueError)}
|
|
74
|
+
label={"Automatic value"}>
|
|
75
|
+
<SelectItem value={"none"}> None </SelectItem>
|
|
76
|
+
<SelectItem value={"on_create"}> On create </SelectItem>
|
|
77
|
+
<SelectItem value={"on_update"}> On any update </SelectItem>
|
|
78
|
+
</Select>
|
|
79
|
+
<FieldCaption error={Boolean(autoValueError)}>
|
|
80
|
+
{autoValueError ?? "Update this field automatically when creating or updating the entity"}
|
|
81
|
+
</FieldCaption>
|
|
82
|
+
</div>
|
|
76
83
|
|
|
77
84
|
</div>
|
|
78
85
|
|
|
@@ -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>
|
|
@@ -93,9 +93,11 @@ export function EnumPropertyField({
|
|
|
93
93
|
<Select
|
|
94
94
|
disabled={disabled}
|
|
95
95
|
position={"item-aligned"}
|
|
96
|
+
fullWidth={true}
|
|
96
97
|
onValueChange={(value: string) => {
|
|
97
98
|
setFieldValue("defaultValue", value);
|
|
98
99
|
}}
|
|
100
|
+
size={"large"}
|
|
99
101
|
label={"Default value"}
|
|
100
102
|
value={defaultValue ?? ""}>
|
|
101
103
|
{enumValues
|
|
@@ -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
|
<>
|
|
@@ -113,7 +113,8 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
|
|
|
113
113
|
value={values.spreadChildren ?? false}
|
|
114
114
|
/>
|
|
115
115
|
<FieldCaption>
|
|
116
|
-
Set this flag to true if you want to display the children of this group as individual columns.
|
|
116
|
+
Set this flag to true if you want to display the children of this group as individual columns. This
|
|
117
|
+
will only work for top level groups.
|
|
117
118
|
</FieldCaption>
|
|
118
119
|
</div>
|
|
119
120
|
|