@firecms/collection_editor 3.0.0-beta.14 → 3.0.0-beta.15
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 +1345 -870
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1343 -868
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_inference.d.ts +3 -0
- package/dist/types/config_controller.d.ts +3 -1
- package/dist/ui/EditorEntityAction.d.ts +2 -0
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +1 -1
- package/dist/ui/collection_editor/EntityActionsEditTab.d.ts +4 -0
- package/dist/ui/collection_editor/EntityActionsSelectDialog.d.ts +4 -0
- package/dist/ui/collection_editor/properties/ReferencePropertyField.d.ts +2 -1
- package/package.json +8 -8
- package/src/types/collection_inference.ts +3 -0
- package/src/types/config_controller.tsx +4 -1
- package/src/ui/EditorCollectionAction.tsx +2 -7
- package/src/ui/EditorEntityAction.tsx +51 -0
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +36 -38
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +18 -5
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +10 -4
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +3 -2
- package/src/ui/collection_editor/EntityActionsEditTab.tsx +163 -0
- package/src/ui/collection_editor/EntityActionsSelectDialog.tsx +41 -0
- package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +5 -2
- package/src/ui/collection_editor/GetCodeDialog.tsx +5 -3
- package/src/ui/collection_editor/PropertyEditView.tsx +10 -1
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +1 -0
- package/src/ui/collection_editor/UnsavedChangesDialog.tsx +6 -2
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +5 -3
- package/src/ui/collection_editor/utils/supported_fields.tsx +1 -0
- package/src/ui/collection_editor/utils/update_property_for_widget.ts +9 -0
- package/src/useCollectionEditorPlugin.tsx +7 -1
- package/src/utils/collections.ts +14 -5
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCustomizationController } from "@firecms/core";
|
|
2
|
+
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@firecms/ui";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
export function EntityActionsSelectDialog({
|
|
6
|
+
open,
|
|
7
|
+
onClose
|
|
8
|
+
}: { open: boolean, onClose: (selectedActionKey?: string) => void }) {
|
|
9
|
+
const {
|
|
10
|
+
entityActions
|
|
11
|
+
} = useCustomizationController();
|
|
12
|
+
|
|
13
|
+
return <Dialog
|
|
14
|
+
maxWidth={"md"}
|
|
15
|
+
open={open}>
|
|
16
|
+
<DialogTitle>Select custom action</DialogTitle>
|
|
17
|
+
<DialogContent className={"flex flex-col gap-4"}>
|
|
18
|
+
{entityActions?.map((action) => {
|
|
19
|
+
return <Button
|
|
20
|
+
key={action.key}
|
|
21
|
+
onClick={() => onClose(action.key)}
|
|
22
|
+
fullWidth
|
|
23
|
+
variant={"text"}
|
|
24
|
+
>
|
|
25
|
+
{action.name} ({action.key})
|
|
26
|
+
</Button>;
|
|
27
|
+
})}
|
|
28
|
+
{(entityActions ?? []).length === 0 &&
|
|
29
|
+
<Typography variant={"body2"}>
|
|
30
|
+
No custom actions defined. Define your custom actions in the customization settings, before using this
|
|
31
|
+
dialog.
|
|
32
|
+
</Typography>
|
|
33
|
+
}
|
|
34
|
+
</DialogContent>
|
|
35
|
+
<DialogActions>
|
|
36
|
+
<Button variant={"outlined"}
|
|
37
|
+
color={"primary"}
|
|
38
|
+
onClick={() => onClose()}>Cancel</Button>
|
|
39
|
+
</DialogActions>
|
|
40
|
+
</Dialog>
|
|
41
|
+
}
|
|
@@ -27,12 +27,15 @@ export function EntityCustomViewsSelectDialog({
|
|
|
27
27
|
})}
|
|
28
28
|
{(entityViews ?? []).length === 0 &&
|
|
29
29
|
<Typography variant={"body2"}>
|
|
30
|
-
No custom views defined
|
|
30
|
+
No custom views defined. Define your custom views in the customization settings, before using this
|
|
31
|
+
dialog.
|
|
31
32
|
</Typography>
|
|
32
33
|
}
|
|
33
34
|
</DialogContent>
|
|
34
35
|
<DialogActions>
|
|
35
|
-
<Button variant={"outlined"}
|
|
36
|
+
<Button variant={"outlined"}
|
|
37
|
+
color={"primary"}
|
|
38
|
+
onClick={() => onClose()}>Cancel</Button>
|
|
36
39
|
</DialogActions>
|
|
37
40
|
</Dialog>
|
|
38
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntityCollection, isEmptyObject, useSnackbarController } from "@firecms/core";
|
|
2
|
-
import { Button, ContentCopyIcon, Dialog, DialogActions, DialogContent, DialogTitle, Typography
|
|
2
|
+
import { Button, ContentCopyIcon, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@firecms/ui";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import JSON5 from "json5";
|
|
5
5
|
import { Highlight, themes } from "prism-react-renderer"
|
|
@@ -59,12 +59,13 @@ export function GetCodeDialog({
|
|
|
59
59
|
<Button
|
|
60
60
|
variant={"text"}
|
|
61
61
|
size={"small"}
|
|
62
|
+
color={"primary"}
|
|
62
63
|
onClick={(e) => {
|
|
63
64
|
e.stopPropagation();
|
|
64
65
|
e.preventDefault();
|
|
65
66
|
snackbarController.open({
|
|
66
67
|
type: "success",
|
|
67
|
-
message:
|
|
68
|
+
message: "Copied"
|
|
68
69
|
})
|
|
69
70
|
return navigator.clipboard.writeText(code);
|
|
70
71
|
}}>
|
|
@@ -133,7 +134,8 @@ function collectionToCode(collection: EntityCollection): object {
|
|
|
133
134
|
.map(([key, value]) => ({
|
|
134
135
|
[key]: propertyCleanup(value)
|
|
135
136
|
}))
|
|
136
|
-
.reduce((a, b) => ({ ...a,
|
|
137
|
+
.reduce((a, b) => ({ ...a,
|
|
138
|
+
...b }), {}),
|
|
137
139
|
subcollections: (collection.subcollections ?? []).map(collectionToCode)
|
|
138
140
|
}
|
|
139
141
|
|
|
@@ -295,6 +295,7 @@ export function PropertyFormDialog({
|
|
|
295
295
|
|
|
296
296
|
{onCancel && <Button
|
|
297
297
|
variant={"text"}
|
|
298
|
+
color={"primary"}
|
|
298
299
|
onClick={() => {
|
|
299
300
|
onCancel();
|
|
300
301
|
formexRef.current?.resetForm();
|
|
@@ -461,6 +462,13 @@ function PropertyEditFormFields({
|
|
|
461
462
|
existing={existing}
|
|
462
463
|
multiple={false}
|
|
463
464
|
disabled={disabled}/>;
|
|
465
|
+
} else if (selectedFieldConfigId === "reference_as_string") {
|
|
466
|
+
childComponent =
|
|
467
|
+
<ReferencePropertyField showErrors={showErrors}
|
|
468
|
+
existing={existing}
|
|
469
|
+
asString={true}
|
|
470
|
+
multiple={false}
|
|
471
|
+
disabled={disabled}/>;
|
|
464
472
|
} else if (selectedFieldConfigId === "date_time") {
|
|
465
473
|
childComponent = <DateTimePropertyField disabled={disabled}/>;
|
|
466
474
|
} else if (selectedFieldConfigId === "multi_references") {
|
|
@@ -605,6 +613,7 @@ const WIDGET_TYPE_MAP: Record<PropertyConfigId, string> = {
|
|
|
605
613
|
file_upload: "File",
|
|
606
614
|
multi_file_upload: "File",
|
|
607
615
|
reference: "Reference",
|
|
616
|
+
reference_as_string: "Text",
|
|
608
617
|
multi_references: "Reference",
|
|
609
618
|
date_time: "Date",
|
|
610
619
|
group: "Group",
|
|
@@ -762,7 +771,7 @@ export function WidgetSelectViewItem({
|
|
|
762
771
|
|
|
763
772
|
return <Card
|
|
764
773
|
onClick={onClick}
|
|
765
|
-
className={"flex flex-row items-center px-4 py-2"}>
|
|
774
|
+
className={"flex flex-row items-center px-4 py-2 m-1"}>
|
|
766
775
|
<div
|
|
767
776
|
className={cls(
|
|
768
777
|
"flex flex-row items-center text-base min-h-[48px]",
|
|
@@ -37,8 +37,12 @@ export function UnsavedChangesDialog({
|
|
|
37
37
|
</DialogContent>
|
|
38
38
|
|
|
39
39
|
<DialogActions>
|
|
40
|
-
<Button variant="text"
|
|
41
|
-
|
|
40
|
+
<Button variant="text"
|
|
41
|
+
color={"primary"}
|
|
42
|
+
onClick={handleCancel} autoFocus> Cancel </Button>
|
|
43
|
+
<Button
|
|
44
|
+
color={"primary"}
|
|
45
|
+
onClick={handleOk}> Ok </Button>
|
|
42
46
|
</DialogActions>
|
|
43
47
|
</Dialog>
|
|
44
48
|
);
|
|
@@ -7,12 +7,14 @@ export function ReferencePropertyField({
|
|
|
7
7
|
existing,
|
|
8
8
|
multiple,
|
|
9
9
|
disabled,
|
|
10
|
-
showErrors
|
|
10
|
+
showErrors,
|
|
11
|
+
asString
|
|
11
12
|
}: {
|
|
12
13
|
existing: boolean,
|
|
13
14
|
multiple: boolean,
|
|
14
15
|
disabled: boolean,
|
|
15
|
-
showErrors: boolean
|
|
16
|
+
showErrors: boolean,
|
|
17
|
+
asString?: boolean
|
|
16
18
|
}) {
|
|
17
19
|
|
|
18
20
|
const {
|
|
@@ -28,7 +30,7 @@ export function ReferencePropertyField({
|
|
|
28
30
|
<CircularProgress/>
|
|
29
31
|
</div>;
|
|
30
32
|
|
|
31
|
-
const pathPath = multiple ? "of.path" : "path";
|
|
33
|
+
const pathPath = asString ? "reference.path" : (multiple ? "of.path" : "path") ;
|
|
32
34
|
const pathValue: string | undefined = getIn(values, pathPath);
|
|
33
35
|
const pathError: string | undefined = showErrors && getIn(errors, pathPath);
|
|
34
36
|
|
|
@@ -208,6 +208,15 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
208
208
|
editable: propertyData.editable !== undefined ? propertyData.editable : true
|
|
209
209
|
} satisfies Property
|
|
210
210
|
);
|
|
211
|
+
} else if (selectedWidgetId === "reference_as_string") {
|
|
212
|
+
updatedProperty = mergeDeep(
|
|
213
|
+
propertyData,
|
|
214
|
+
{
|
|
215
|
+
dataType: "string",
|
|
216
|
+
propertyConfig: "reference_as_string",
|
|
217
|
+
editable: propertyData.editable !== undefined ? propertyData.editable : true
|
|
218
|
+
} satisfies Property
|
|
219
|
+
);
|
|
211
220
|
} else if (selectedWidgetId === "multi_references") {
|
|
212
221
|
updatedProperty = mergeDeep(
|
|
213
222
|
propertyData,
|
|
@@ -14,6 +14,7 @@ import { AddIcon, Button, Paper, Typography } from "@firecms/ui";
|
|
|
14
14
|
import { useCollectionEditorController } from "./useCollectionEditorController";
|
|
15
15
|
import { EditorCollectionActionStart } from "./ui/EditorCollectionActionStart";
|
|
16
16
|
import { NewCollectionCard } from "./ui/NewCollectionCard";
|
|
17
|
+
import { EditorEntityAction } from "./ui/EditorEntityAction";
|
|
17
18
|
|
|
18
19
|
export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, USER extends User = User> {
|
|
19
20
|
|
|
@@ -96,15 +97,20 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
96
97
|
homePage: {
|
|
97
98
|
additionalActions: <NewCollectionButton/>,
|
|
98
99
|
additionalChildrenStart: includeIntroView ? <IntroWidget/> : undefined,
|
|
99
|
-
// additionalChildrenEnd: <RootCollectionSuggestions introMode={introMode}/>,
|
|
100
100
|
CollectionActions: HomePageEditorCollectionAction,
|
|
101
101
|
AdditionalCards: NewCollectionCard,
|
|
102
|
+
allowDragAndDrop: true,
|
|
103
|
+
navigationEntries: collectionConfigController.navigationEntries,
|
|
104
|
+
onNavigationEntriesUpdate: collectionConfigController.saveNavigationEntries,
|
|
102
105
|
},
|
|
103
106
|
collectionView: {
|
|
104
107
|
CollectionActionsStart: EditorCollectionActionStart,
|
|
105
108
|
CollectionActions: EditorCollectionAction,
|
|
106
109
|
HeaderAction: CollectionViewHeaderAction,
|
|
107
110
|
AddColumnComponent: PropertyAddColumnComponent
|
|
111
|
+
},
|
|
112
|
+
form: {
|
|
113
|
+
ActionsTop: EditorEntityAction,
|
|
108
114
|
}
|
|
109
115
|
};
|
|
110
116
|
}
|
package/src/utils/collections.ts
CHANGED
|
@@ -26,11 +26,20 @@ export const mergeCollections = (baseCollections: EntityCollection[],
|
|
|
26
26
|
const result = joinCollectionLists(baseCollections, backendCollections, [], modifyCollection);
|
|
27
27
|
|
|
28
28
|
// sort the collections so they are in the same order as the base collections
|
|
29
|
-
result.sort((a, b) =>
|
|
30
|
-
|
|
31
|
-
baseCollections
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
result.sort((a, b) => {
|
|
30
|
+
const indexA = baseCollections.findIndex(c => c.id === a.id);
|
|
31
|
+
const indexB = baseCollections.findIndex(c => c.id === b.id);
|
|
32
|
+
|
|
33
|
+
if (indexA === -1 && indexB === -1) {
|
|
34
|
+
return 0; // Keep original order for items not in baseCollections
|
|
35
|
+
}
|
|
36
|
+
if (indexA === -1) {
|
|
37
|
+
return 1; // a is not in base, so it goes to the end
|
|
38
|
+
}
|
|
39
|
+
if (indexB === -1) {
|
|
40
|
+
return -1; // b is not in base, so it goes to the end
|
|
41
|
+
}
|
|
42
|
+
return indexA - indexB;
|
|
34
43
|
});
|
|
35
44
|
|
|
36
45
|
return result;
|