@firecms/collection_editor 3.0.0-alpha.27 → 3.0.0-alpha.29
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/components/CollectionViewHeaderAction.d.ts +3 -1
- package/dist/components/PropertyAddColumnComponent.d.ts +2 -2
- package/dist/components/collection_editor/CollectionPropertiesEditorForm.d.ts +5 -4
- package/dist/components/collection_editor/PropertyEditView.d.ts +4 -3
- package/dist/components/collection_editor/PropertySelectItem.d.ts +3 -3
- package/dist/components/collection_editor/PropertyTree.d.ts +4 -2
- package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +4 -3
- package/dist/components/collection_editor/properties/BlockPropertyField.d.ts +4 -3
- package/dist/components/collection_editor/properties/MapPropertyField.d.ts +4 -3
- package/dist/components/collection_editor/properties/RepeatPropertyField.d.ts +4 -3
- package/dist/components/collection_editor/templates/blog_template.d.ts +1 -1
- package/dist/components/collection_editor/templates/products_template.d.ts +1 -1
- package/dist/components/collection_editor/templates/users_template.d.ts +1 -1
- package/dist/components/collection_editor/utils/supported_fields.d.ts +1 -1
- package/dist/components/collection_editor/utils/update_property_for_widget.d.ts +2 -2
- package/dist/index.es.js +1967 -1914
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +4 -2
- package/dist/types/config_controller.d.ts +8 -0
- package/dist/types/persisted_collection.d.ts +2 -1
- package/dist/useCollectionEditorPlugin.d.ts +1 -1
- package/package.json +4 -4
- package/src/ConfigControllerProvider.tsx +38 -5
- package/src/components/CollectionViewHeaderAction.tsx +7 -3
- package/src/components/PropertyAddColumnComponent.tsx +4 -2
- package/src/components/collection_editor/CollectionEditorDialog.tsx +7 -3
- package/src/components/collection_editor/CollectionPropertiesEditorForm.tsx +10 -4
- package/src/components/collection_editor/EnumForm.tsx +8 -6
- package/src/components/collection_editor/PropertyEditView.tsx +26 -15
- package/src/components/collection_editor/PropertyFieldPreview.tsx +8 -8
- package/src/components/collection_editor/PropertySelectItem.tsx +6 -6
- package/src/components/collection_editor/PropertyTree.tsx +15 -6
- package/src/components/collection_editor/import/CollectionEditorImportMapping.tsx +9 -6
- package/src/components/collection_editor/properties/BlockPropertyField.tsx +6 -3
- package/src/components/collection_editor/properties/MapPropertyField.tsx +6 -3
- package/src/components/collection_editor/properties/RepeatPropertyField.tsx +6 -3
- package/src/components/collection_editor/utils/update_property_for_widget.ts +23 -23
- package/src/types/collection_editor_controller.tsx +4 -2
- package/src/types/config_controller.tsx +9 -0
- package/src/types/persisted_collection.ts +3 -2
- package/src/useCollectionEditorPlugin.tsx +3 -8
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { cn,
|
|
1
|
+
import { cn, PropertyConfig, FieldConfigBadge, SelectItem, Typography } from "@firecms/core";
|
|
2
2
|
|
|
3
3
|
export interface PropertySelectItemProps {
|
|
4
4
|
value: string;
|
|
5
5
|
optionDisabled: boolean;
|
|
6
|
-
|
|
6
|
+
propertyConfig: PropertyConfig;
|
|
7
7
|
existing: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export function PropertySelectItem({ value, optionDisabled,
|
|
10
|
+
export function PropertySelectItem({ value, optionDisabled, propertyConfig, existing }: PropertySelectItemProps) {
|
|
11
11
|
return <SelectItem value={value}
|
|
12
12
|
disabled={optionDisabled}
|
|
13
13
|
className={"flex flex-row items-center"}>
|
|
@@ -16,14 +16,14 @@ export function PropertySelectItem({ value, optionDisabled, fieldConfig, existin
|
|
|
16
16
|
"flex flex-row items-center text-base min-h-[52px]",
|
|
17
17
|
optionDisabled ? "w-full" : "")}>
|
|
18
18
|
<div className={"mr-8"}>
|
|
19
|
-
<FieldConfigBadge
|
|
19
|
+
<FieldConfigBadge propertyConfig={propertyConfig}/>
|
|
20
20
|
</div>
|
|
21
21
|
<div>
|
|
22
|
-
<div>{
|
|
22
|
+
<div>{propertyConfig.name}</div>
|
|
23
23
|
<Typography variant={"caption"}
|
|
24
24
|
color={"disabled"}
|
|
25
25
|
className={"max-w-sm"}>
|
|
26
|
-
{existing && optionDisabled ? "You can only switch to widgets that use the same data type" :
|
|
26
|
+
{existing && optionDisabled ? "You can only switch to widgets that use the same data type" : propertyConfig.description}
|
|
27
27
|
</Typography>
|
|
28
28
|
</div>
|
|
29
29
|
</div>
|
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
defaultBorderMixin,
|
|
6
6
|
DragHandleIcon,
|
|
7
7
|
ErrorBoundary,
|
|
8
|
-
IconButton,
|
|
9
|
-
|
|
8
|
+
IconButton,
|
|
9
|
+
isPropertyBuilder,
|
|
10
|
+
PropertiesOrBuilders,
|
|
11
|
+
PropertyOrBuilder,
|
|
10
12
|
RemoveIcon,
|
|
11
13
|
Tooltip
|
|
12
14
|
} from "@firecms/core";
|
|
@@ -30,7 +32,8 @@ export function PropertyTree<M extends {
|
|
|
30
32
|
onPropertyMove,
|
|
31
33
|
onPropertyRemove,
|
|
32
34
|
className,
|
|
33
|
-
inferredPropertyKeys
|
|
35
|
+
inferredPropertyKeys,
|
|
36
|
+
collectionEditable
|
|
34
37
|
}: {
|
|
35
38
|
namespace?: string;
|
|
36
39
|
selectedPropertyKey?: string;
|
|
@@ -43,6 +46,7 @@ export function PropertyTree<M extends {
|
|
|
43
46
|
onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
|
|
44
47
|
className?: string;
|
|
45
48
|
inferredPropertyKeys?: string[];
|
|
49
|
+
collectionEditable: boolean;
|
|
46
50
|
}) {
|
|
47
51
|
|
|
48
52
|
const propertiesOrder = propertiesOrderProp ?? Object.keys(properties);
|
|
@@ -102,6 +106,7 @@ export function PropertyTree<M extends {
|
|
|
102
106
|
onPropertyRemove={onPropertyRemove}
|
|
103
107
|
onPropertyClick={snapshot.isDragging ? undefined : onPropertyClick}
|
|
104
108
|
selectedPropertyKey={selectedPropertyKey}
|
|
109
|
+
collectionEditable={collectionEditable}
|
|
105
110
|
/>
|
|
106
111
|
</ErrorBoundary>
|
|
107
112
|
);
|
|
@@ -131,7 +136,8 @@ export function PropertyTreeEntry({
|
|
|
131
136
|
onPropertyClick,
|
|
132
137
|
onPropertyMove,
|
|
133
138
|
onPropertyRemove,
|
|
134
|
-
inferredPropertyKeys
|
|
139
|
+
inferredPropertyKeys,
|
|
140
|
+
collectionEditable
|
|
135
141
|
}: {
|
|
136
142
|
propertyKey: string;
|
|
137
143
|
namespace?: string;
|
|
@@ -144,6 +150,7 @@ export function PropertyTreeEntry({
|
|
|
144
150
|
onPropertyMove?: (propertiesOrder: string[], namespace?: string) => void;
|
|
145
151
|
onPropertyRemove?: (propertyKey: string, namespace?: string) => void;
|
|
146
152
|
inferredPropertyKeys?: string[];
|
|
153
|
+
collectionEditable: boolean;
|
|
147
154
|
}) {
|
|
148
155
|
|
|
149
156
|
const isPropertyInferred = inferredPropertyKeys?.includes(namespace ? `${namespace}.${propertyKey}` : propertyKey);
|
|
@@ -161,13 +168,15 @@ export function PropertyTreeEntry({
|
|
|
161
168
|
errors={errors}
|
|
162
169
|
onPropertyClick={onPropertyClick}
|
|
163
170
|
onPropertyMove={onPropertyMove}
|
|
164
|
-
onPropertyRemove={onPropertyRemove}
|
|
171
|
+
onPropertyRemove={onPropertyRemove}
|
|
172
|
+
collectionEditable={collectionEditable}
|
|
173
|
+
/>
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
176
|
|
|
168
177
|
const hasError = fullId ? getIn(errors, idToPropertiesPath(fullId)) : false;
|
|
169
178
|
const selected = selectedPropertyKey === fullId;
|
|
170
|
-
const editable = propertyOrBuilder && editableProperty(propertyOrBuilder);
|
|
179
|
+
const editable = propertyOrBuilder && ((collectionEditable && !isPropertyBuilder(propertyOrBuilder)) || editableProperty(propertyOrBuilder));
|
|
171
180
|
|
|
172
181
|
return (
|
|
173
182
|
<div
|
|
@@ -8,12 +8,12 @@ import { getIn, useFormikContext } from "formik";
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
10
10
|
Container,
|
|
11
|
-
FieldConfig,
|
|
12
11
|
FieldConfigBadge,
|
|
13
12
|
getFieldConfig,
|
|
14
13
|
getFieldId,
|
|
15
14
|
Properties,
|
|
16
15
|
Property,
|
|
16
|
+
PropertyConfig,
|
|
17
17
|
Select,
|
|
18
18
|
Tooltip,
|
|
19
19
|
Typography,
|
|
@@ -30,11 +30,13 @@ import { buildPropertyFromData } from "@firecms/schema_inference";
|
|
|
30
30
|
|
|
31
31
|
export function CollectionEditorImportMapping({
|
|
32
32
|
importConfig,
|
|
33
|
-
customFields
|
|
33
|
+
customFields,
|
|
34
|
+
collectionEditable
|
|
34
35
|
}:
|
|
35
36
|
{
|
|
36
37
|
importConfig: ImportConfig,
|
|
37
|
-
customFields: Record<string,
|
|
38
|
+
customFields: Record<string, PropertyConfig>,
|
|
39
|
+
collectionEditable: boolean
|
|
38
40
|
}) {
|
|
39
41
|
|
|
40
42
|
const {
|
|
@@ -192,6 +194,7 @@ export function CollectionEditorImportMapping({
|
|
|
192
194
|
autoUpdateId={false}
|
|
193
195
|
onPropertyChanged={onPropertyChanged}
|
|
194
196
|
allowDataInference={false}
|
|
197
|
+
collectionEditable={collectionEditable}
|
|
195
198
|
onOkClicked={() => {
|
|
196
199
|
setSelectedProperty(undefined);
|
|
197
200
|
}}
|
|
@@ -223,7 +226,7 @@ function PropertySelect({
|
|
|
223
226
|
previousId,
|
|
224
227
|
namespace
|
|
225
228
|
}: OnPropertyChangedParams) => void,
|
|
226
|
-
customFields: Record<string,
|
|
229
|
+
customFields: Record<string, PropertyConfig>,
|
|
227
230
|
disabled?: boolean
|
|
228
231
|
}) {
|
|
229
232
|
|
|
@@ -247,7 +250,7 @@ function PropertySelect({
|
|
|
247
250
|
position={"item-aligned"}
|
|
248
251
|
renderValue={(value) => {
|
|
249
252
|
if (!widget) return null;
|
|
250
|
-
return <FieldConfigBadge
|
|
253
|
+
return <FieldConfigBadge propertyConfig={widget}/>
|
|
251
254
|
}}
|
|
252
255
|
onValueChange={(newSelectedWidgetId) => {
|
|
253
256
|
const newProperty = updatePropertyFromWidget(property, newSelectedWidgetId, customFields)
|
|
@@ -265,7 +268,7 @@ function PropertySelect({
|
|
|
265
268
|
key={key}
|
|
266
269
|
value={key}
|
|
267
270
|
optionDisabled={false}
|
|
268
|
-
|
|
271
|
+
propertyConfig={widget}
|
|
269
272
|
existing={false}/>;
|
|
270
273
|
})
|
|
271
274
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { AddIcon, ArrayProperty, Button,
|
|
2
|
+
import { AddIcon, ArrayProperty, Button, PropertyConfig, Paper, Property, Typography } from "@firecms/core";
|
|
3
3
|
import { getIn, useFormikContext } from "formik";
|
|
4
4
|
import { PropertyFormDialog } from "../PropertyEditView";
|
|
5
5
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath } from "../util";
|
|
6
6
|
import { PropertyTree } from "../PropertyTree";
|
|
7
7
|
|
|
8
|
-
export function BlockPropertyField({ disabled, getData, allowDataInference, customFields }: {
|
|
8
|
+
export function BlockPropertyField({ disabled, getData, allowDataInference, customFields, collectionEditable }: {
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
getData?: () => Promise<object[]>;
|
|
11
11
|
allowDataInference: boolean;
|
|
12
|
-
customFields: Record<string,
|
|
12
|
+
customFields: Record<string, PropertyConfig>,
|
|
13
|
+
collectionEditable: boolean;
|
|
13
14
|
}) {
|
|
14
15
|
|
|
15
16
|
const {
|
|
@@ -81,6 +82,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, cust
|
|
|
81
82
|
properties={values.oneOf?.properties ?? {}}
|
|
82
83
|
propertiesOrder={values.oneOf?.propertiesOrder}
|
|
83
84
|
errors={{}}
|
|
85
|
+
collectionEditable={collectionEditable}
|
|
84
86
|
onPropertyClick={disabled
|
|
85
87
|
? undefined
|
|
86
88
|
: (propertyKey, namespace) => {
|
|
@@ -116,6 +118,7 @@ export function BlockPropertyField({ disabled, getData, allowDataInference, cust
|
|
|
116
118
|
setSelectedPropertyKey(undefined);
|
|
117
119
|
setSelectedPropertyNamespace(undefined);
|
|
118
120
|
}}
|
|
121
|
+
collectionEditable={collectionEditable}
|
|
119
122
|
onDelete={deleteProperty}
|
|
120
123
|
propertyKey={selectedPropertyKey}
|
|
121
124
|
propertyNamespace={selectedPropertyNamespace}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
AddIcon,
|
|
4
4
|
BooleanSwitchWithLabel,
|
|
5
5
|
Button,
|
|
6
|
-
|
|
6
|
+
PropertyConfig,
|
|
7
7
|
MapProperty,
|
|
8
8
|
Paper,
|
|
9
9
|
Property,
|
|
@@ -15,11 +15,12 @@ import { PropertyTree } from "../PropertyTree";
|
|
|
15
15
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
|
|
16
16
|
import { FieldHelperView } from "./FieldHelperView";
|
|
17
17
|
|
|
18
|
-
export function MapPropertyField({ disabled, getData, allowDataInference, customFields }: {
|
|
18
|
+
export function MapPropertyField({ disabled, getData, allowDataInference, customFields, collectionEditable }: {
|
|
19
19
|
disabled: boolean;
|
|
20
20
|
getData?: () => Promise<object[]>;
|
|
21
21
|
allowDataInference: boolean;
|
|
22
|
-
customFields: Record<string,
|
|
22
|
+
customFields: Record<string, PropertyConfig>,
|
|
23
|
+
collectionEditable: boolean;
|
|
23
24
|
}) {
|
|
24
25
|
|
|
25
26
|
const {
|
|
@@ -94,6 +95,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
|
|
|
94
95
|
properties={values.properties ?? {}}
|
|
95
96
|
propertiesOrder={propertiesOrder}
|
|
96
97
|
errors={{}}
|
|
98
|
+
collectionEditable={collectionEditable}
|
|
97
99
|
onPropertyClick={(propertyKey, namespace) => {
|
|
98
100
|
setSelectedPropertyKey(propertyKey);
|
|
99
101
|
setSelectedPropertyNamespace(namespace);
|
|
@@ -127,6 +129,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, custom
|
|
|
127
129
|
forceShowErrors={false}
|
|
128
130
|
open={propertyDialogOpen}
|
|
129
131
|
allowDataInference={allowDataInference}
|
|
132
|
+
collectionEditable={collectionEditable}
|
|
130
133
|
onCancel={() => {
|
|
131
134
|
setPropertyDialogOpen(false);
|
|
132
135
|
setSelectedPropertyKey(undefined);
|
|
@@ -2,10 +2,10 @@ import React, { useCallback, useState } from "react";
|
|
|
2
2
|
import {
|
|
3
3
|
ArrayProperty,
|
|
4
4
|
Button,
|
|
5
|
-
FieldConfig,
|
|
6
5
|
getFieldConfig,
|
|
7
6
|
Paper,
|
|
8
7
|
Property,
|
|
8
|
+
PropertyConfig,
|
|
9
9
|
Typography,
|
|
10
10
|
useFireCMSContext
|
|
11
11
|
} from "@firecms/core";
|
|
@@ -21,14 +21,16 @@ export function RepeatPropertyField({
|
|
|
21
21
|
disabled,
|
|
22
22
|
getData,
|
|
23
23
|
allowDataInference,
|
|
24
|
-
customFields
|
|
24
|
+
customFields,
|
|
25
|
+
collectionEditable
|
|
25
26
|
}: {
|
|
26
27
|
showErrors: boolean,
|
|
27
28
|
existing: boolean,
|
|
28
29
|
disabled: boolean,
|
|
29
30
|
getData?: () => Promise<object[]>;
|
|
30
31
|
allowDataInference: boolean;
|
|
31
|
-
customFields: Record<string,
|
|
32
|
+
customFields: Record<string, PropertyConfig>,
|
|
33
|
+
collectionEditable: boolean;
|
|
32
34
|
}) {
|
|
33
35
|
|
|
34
36
|
const { fields } = useFireCMSContext();
|
|
@@ -96,6 +98,7 @@ export function RepeatPropertyField({
|
|
|
96
98
|
onPropertyChanged={onPropertyChanged}
|
|
97
99
|
forceShowErrors={showErrors}
|
|
98
100
|
customFields={customFields}
|
|
101
|
+
collectionEditable={collectionEditable}
|
|
99
102
|
/>
|
|
100
103
|
</Paper>
|
|
101
104
|
)}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { buildProperty,
|
|
1
|
+
import { buildProperty, PropertyConfig, mergeDeep, Property } from "@firecms/core";
|
|
2
2
|
|
|
3
3
|
export function updatePropertyFromWidget(propertyData: any,
|
|
4
4
|
selectedWidgetId: string | undefined,
|
|
5
|
-
customFields: Record<string,
|
|
5
|
+
customFields: Record<string, PropertyConfig>): Property {
|
|
6
6
|
|
|
7
7
|
let updatedProperty;
|
|
8
8
|
if (selectedWidgetId === "text_field") {
|
|
@@ -10,7 +10,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
10
10
|
propertyData,
|
|
11
11
|
buildProperty({
|
|
12
12
|
dataType: "string",
|
|
13
|
-
|
|
13
|
+
propertyConfig: "text_field",
|
|
14
14
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
15
15
|
storage: undefined,
|
|
16
16
|
multiline: undefined,
|
|
@@ -25,7 +25,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
25
25
|
propertyData,
|
|
26
26
|
buildProperty({
|
|
27
27
|
dataType: "string",
|
|
28
|
-
|
|
28
|
+
propertyConfig: "multiline",
|
|
29
29
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
30
30
|
multiline: true,
|
|
31
31
|
storage: undefined,
|
|
@@ -40,7 +40,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
40
40
|
propertyData,
|
|
41
41
|
buildProperty({
|
|
42
42
|
dataType: "string",
|
|
43
|
-
|
|
43
|
+
propertyConfig: "markdown",
|
|
44
44
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
45
45
|
storage: undefined,
|
|
46
46
|
multiline: undefined,
|
|
@@ -54,7 +54,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
54
54
|
propertyData,
|
|
55
55
|
buildProperty({
|
|
56
56
|
dataType: "string",
|
|
57
|
-
|
|
57
|
+
propertyConfig: "url",
|
|
58
58
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
59
59
|
storage: undefined,
|
|
60
60
|
multiline: undefined,
|
|
@@ -69,7 +69,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
69
69
|
propertyData,
|
|
70
70
|
buildProperty({
|
|
71
71
|
dataType: "string",
|
|
72
|
-
|
|
72
|
+
propertyConfig: "email",
|
|
73
73
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
74
74
|
storage: undefined,
|
|
75
75
|
multiline: undefined,
|
|
@@ -84,7 +84,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
84
84
|
propertyData,
|
|
85
85
|
buildProperty({
|
|
86
86
|
dataType: "string",
|
|
87
|
-
|
|
87
|
+
propertyConfig: "select",
|
|
88
88
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
89
89
|
storage: undefined,
|
|
90
90
|
multiline: undefined,
|
|
@@ -99,7 +99,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
99
99
|
propertyData,
|
|
100
100
|
buildProperty({
|
|
101
101
|
dataType: "array",
|
|
102
|
-
|
|
102
|
+
propertyConfig: "multi_select",
|
|
103
103
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
104
104
|
of: {
|
|
105
105
|
dataType: "string",
|
|
@@ -112,7 +112,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
112
112
|
propertyData,
|
|
113
113
|
buildProperty({
|
|
114
114
|
dataType: "number",
|
|
115
|
-
|
|
115
|
+
propertyConfig: "number_input",
|
|
116
116
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
117
117
|
enumValues: undefined
|
|
118
118
|
})
|
|
@@ -122,7 +122,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
122
122
|
propertyData,
|
|
123
123
|
buildProperty({
|
|
124
124
|
dataType: "number",
|
|
125
|
-
|
|
125
|
+
propertyConfig: "number_select",
|
|
126
126
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
127
127
|
enumValues: propertyData.enumValues ?? []
|
|
128
128
|
})
|
|
@@ -132,7 +132,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
132
132
|
propertyData,
|
|
133
133
|
buildProperty({
|
|
134
134
|
dataType: "array",
|
|
135
|
-
|
|
135
|
+
propertyConfig: "multi_number_select",
|
|
136
136
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
137
137
|
of: {
|
|
138
138
|
dataType: "number",
|
|
@@ -145,7 +145,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
145
145
|
propertyData,
|
|
146
146
|
buildProperty({
|
|
147
147
|
dataType: "string",
|
|
148
|
-
|
|
148
|
+
propertyConfig: "file_upload",
|
|
149
149
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
150
150
|
storage: {
|
|
151
151
|
storagePath: "/"
|
|
@@ -157,7 +157,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
157
157
|
propertyData,
|
|
158
158
|
buildProperty({
|
|
159
159
|
dataType: "array",
|
|
160
|
-
|
|
160
|
+
propertyConfig: "multi_file_upload",
|
|
161
161
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
162
162
|
of: {
|
|
163
163
|
dataType: "string",
|
|
@@ -172,7 +172,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
172
172
|
propertyData,
|
|
173
173
|
buildProperty({
|
|
174
174
|
dataType: "map",
|
|
175
|
-
|
|
175
|
+
propertyConfig: "group",
|
|
176
176
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
177
177
|
keyValue: false,
|
|
178
178
|
properties: propertyData.properties ?? {}
|
|
@@ -183,7 +183,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
183
183
|
propertyData,
|
|
184
184
|
buildProperty({
|
|
185
185
|
dataType: "map",
|
|
186
|
-
|
|
186
|
+
propertyConfig: "key_value",
|
|
187
187
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
188
188
|
keyValue: true,
|
|
189
189
|
properties: undefined
|
|
@@ -194,7 +194,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
194
194
|
propertyData,
|
|
195
195
|
buildProperty({
|
|
196
196
|
dataType: "reference",
|
|
197
|
-
|
|
197
|
+
propertyConfig: "reference",
|
|
198
198
|
editable: propertyData.editable !== undefined ? propertyData.editable : true
|
|
199
199
|
})
|
|
200
200
|
);
|
|
@@ -203,7 +203,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
203
203
|
propertyData,
|
|
204
204
|
buildProperty({
|
|
205
205
|
dataType: "array",
|
|
206
|
-
|
|
206
|
+
propertyConfig: "multi_references",
|
|
207
207
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
208
208
|
of: {
|
|
209
209
|
dataType: "reference"
|
|
@@ -215,7 +215,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
215
215
|
propertyData,
|
|
216
216
|
buildProperty({
|
|
217
217
|
dataType: "boolean",
|
|
218
|
-
|
|
218
|
+
propertyConfig: "switch",
|
|
219
219
|
editable: propertyData.editable !== undefined ? propertyData.editable : true
|
|
220
220
|
})
|
|
221
221
|
);
|
|
@@ -224,7 +224,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
224
224
|
propertyData,
|
|
225
225
|
buildProperty({
|
|
226
226
|
dataType: "date",
|
|
227
|
-
|
|
227
|
+
propertyConfig: "date_time",
|
|
228
228
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
229
229
|
mode: "date_time"
|
|
230
230
|
})
|
|
@@ -234,7 +234,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
234
234
|
propertyData,
|
|
235
235
|
buildProperty({
|
|
236
236
|
dataType: "array",
|
|
237
|
-
|
|
237
|
+
propertyConfig: "repeat",
|
|
238
238
|
editable: propertyData.editable !== undefined ? propertyData.editable : true
|
|
239
239
|
})
|
|
240
240
|
);
|
|
@@ -243,7 +243,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
243
243
|
propertyData,
|
|
244
244
|
buildProperty({
|
|
245
245
|
dataType: "array",
|
|
246
|
-
|
|
246
|
+
propertyConfig: "block",
|
|
247
247
|
editable: propertyData.editable !== undefined ? propertyData.editable : true,
|
|
248
248
|
oneOf: {
|
|
249
249
|
properties: {}
|
|
@@ -251,7 +251,7 @@ export function updatePropertyFromWidget(propertyData: any,
|
|
|
251
251
|
})
|
|
252
252
|
);
|
|
253
253
|
} else if (selectedWidgetId && customFields[selectedWidgetId]) {
|
|
254
|
-
updatedProperty = { ...customFields[selectedWidgetId].property,
|
|
254
|
+
updatedProperty = { ...customFields[selectedWidgetId].property, propertyConfig: selectedWidgetId };
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
return updatedProperty;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CollectionEditorPermissionsBuilder } from "./config_permissions";
|
|
2
2
|
import { EntityCollection, Property } from "@firecms/core";
|
|
3
|
+
import { PersistedCollection } from "./persisted_collection";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Controller to open the collection editor dialog.
|
|
@@ -11,7 +12,7 @@ export interface CollectionEditorController {
|
|
|
11
12
|
path?: string,
|
|
12
13
|
fullPath?: string,
|
|
13
14
|
parentPathSegments: string[],
|
|
14
|
-
parentCollection?: EntityCollection
|
|
15
|
+
parentCollection?: EntityCollection
|
|
15
16
|
}) => void;
|
|
16
17
|
|
|
17
18
|
createCollection: (props: {
|
|
@@ -21,7 +22,7 @@ export interface CollectionEditorController {
|
|
|
21
22
|
name?: string
|
|
22
23
|
},
|
|
23
24
|
parentPathSegments: string[],
|
|
24
|
-
parentCollection?:
|
|
25
|
+
parentCollection?: PersistedCollection,
|
|
25
26
|
redirect: boolean
|
|
26
27
|
}) => void;
|
|
27
28
|
|
|
@@ -31,6 +32,7 @@ export interface CollectionEditorController {
|
|
|
31
32
|
currentPropertiesOrder?: string[],
|
|
32
33
|
editedCollectionPath: string,
|
|
33
34
|
parentPathSegments: string[],
|
|
35
|
+
collection: PersistedCollection
|
|
34
36
|
}) => void;
|
|
35
37
|
|
|
36
38
|
configPermissions: CollectionEditorPermissionsBuilder;
|
|
@@ -14,6 +14,7 @@ export interface CollectionsConfigController {
|
|
|
14
14
|
saveCollection: <M extends { [Key: string]: CMSType }>(params: SaveCollectionParams<M>) => Promise<void>;
|
|
15
15
|
|
|
16
16
|
saveProperty: (params: SavePropertyParams) => Promise<void>;
|
|
17
|
+
deleteProperty: (params: DeletePropertyParams) => Promise<void>;
|
|
17
18
|
|
|
18
19
|
deleteCollection: (props: DeleteCollectionParams) => Promise<void>;
|
|
19
20
|
|
|
@@ -35,6 +36,14 @@ export type SavePropertyParams = {
|
|
|
35
36
|
parentPathSegments?: string[]
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
export type DeletePropertyParams = {
|
|
40
|
+
path: string,
|
|
41
|
+
propertyKey: string,
|
|
42
|
+
namespace?: string,
|
|
43
|
+
newPropertiesOrder?: string[],
|
|
44
|
+
parentPathSegments?: string[]
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
export type DeleteCollectionParams = {
|
|
39
48
|
path: string,
|
|
40
49
|
parentPathSegments?: string[]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { EntityCollection, Properties, User } from "@firecms/core";
|
|
2
2
|
|
|
3
|
-
export type PersistedCollection<M extends Record<string, any> = any,
|
|
4
|
-
= Omit<EntityCollection<M,
|
|
3
|
+
export type PersistedCollection<M extends Record<string, any> = any, UserType extends User = User>
|
|
4
|
+
= Omit<EntityCollection<M, UserType>, "properties" | "subcollections"> & {
|
|
5
5
|
properties: Properties<M>;
|
|
6
6
|
ownerId: string;
|
|
7
7
|
subcollections?: PersistedCollection<any, any>[];
|
|
8
|
+
editable?: boolean;
|
|
8
9
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
EntityCollection,
|
|
4
|
-
FireCMSPlugin,
|
|
5
|
-
makePropertiesEditable,
|
|
6
|
-
makePropertiesNonEditable,
|
|
7
|
-
User
|
|
8
|
-
} from "@firecms/core";
|
|
2
|
+
import { EntityCollection, FireCMSPlugin, makePropertiesEditable, User } from "@firecms/core";
|
|
9
3
|
import { ConfigControllerProvider } from "./ConfigControllerProvider";
|
|
10
4
|
import { CollectionEditorPermissionsBuilder } from "./types/config_permissions";
|
|
11
5
|
import { EditorCollectionAction } from "./components/EditorCollectionAction";
|
|
@@ -76,7 +70,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
76
70
|
getUser,
|
|
77
71
|
collectionInference,
|
|
78
72
|
getData
|
|
79
|
-
}: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin {
|
|
73
|
+
}: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
|
|
80
74
|
|
|
81
75
|
const injectCollections = useCallback(
|
|
82
76
|
(collections: EntityCollection[]) => {
|
|
@@ -86,6 +80,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
|
|
|
86
80
|
};
|
|
87
81
|
const editableCollections = collectionConfigController.collections ?? [];
|
|
88
82
|
editableCollections.forEach(markAsEditable);
|
|
83
|
+
console.debug("Injecting collections", { editableCollections, collections });
|
|
89
84
|
return joinCollectionLists(editableCollections, collections);
|
|
90
85
|
},
|
|
91
86
|
[collectionConfigController.collections]);
|