@firecms/collection_editor 3.0.0-beta.6 → 3.0.0-beta.7
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 +887 -854
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +20 -20
- package/src/ConfigControllerProvider.tsx +24 -24
- package/src/ui/HomePageEditorCollectionAction.tsx +5 -5
- package/src/ui/NewCollectionCard.tsx +3 -3
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +33 -3
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +14 -14
- 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/import/CollectionEditorImportDataPreview.tsx +2 -1
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +5 -5
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +5 -5
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +0 -1
- package/src/useCollectionEditorPlugin.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.7",
|
|
5
5
|
"main": "./dist/index.umd.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@firecms/data_import_export": "^3.0.0-beta.
|
|
11
|
-
"@firecms/formex": "^3.0.0-beta.
|
|
12
|
-
"@firecms/schema_inference": "^3.0.0-beta.
|
|
13
|
-
"@firecms/ui": "^3.0.0-beta.
|
|
10
|
+
"@firecms/data_import_export": "^3.0.0-beta.7",
|
|
11
|
+
"@firecms/formex": "^3.0.0-beta.7",
|
|
12
|
+
"@firecms/schema_inference": "^3.0.0-beta.7",
|
|
13
|
+
"@firecms/ui": "^3.0.0-beta.7",
|
|
14
14
|
"json5": "^2.2.3",
|
|
15
15
|
"prism-react-renderer": "^2.3.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"react": "^18.
|
|
19
|
-
"react-dom": "^18.
|
|
18
|
+
"react": "^18.3.1",
|
|
19
|
+
"react-dom": "^18.3.1",
|
|
20
20
|
"react-router": "^6.22.0",
|
|
21
21
|
"react-router-dom": "^6.22.0"
|
|
22
22
|
},
|
|
@@ -54,24 +54,24 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@jest/globals": "^29.7.0",
|
|
57
|
-
"@types/react": "^18.
|
|
58
|
-
"@types/react-dom": "^18.
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
60
|
-
"@typescript-eslint/parser": "^7.
|
|
61
|
-
"@vitejs/plugin-react": "^4.
|
|
57
|
+
"@types/react": "^18.3.3",
|
|
58
|
+
"@types/react-dom": "^18.3.0",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
|
60
|
+
"@typescript-eslint/parser": "^7.11.0",
|
|
61
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
62
62
|
"eslint": "^8.57.0",
|
|
63
63
|
"eslint-config-standard": "^17.1.0",
|
|
64
64
|
"eslint-plugin-import": "^2.29.1",
|
|
65
65
|
"eslint-plugin-n": "^16.6.2",
|
|
66
|
-
"eslint-plugin-promise": "^6.
|
|
67
|
-
"eslint-plugin-react": "^7.34.
|
|
68
|
-
"eslint-plugin-react-hooks": "^4.6.
|
|
66
|
+
"eslint-plugin-promise": "^6.2.0",
|
|
67
|
+
"eslint-plugin-react": "^7.34.2",
|
|
68
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
69
69
|
"jest": "^29.7.0",
|
|
70
|
-
"react-router": "^6.
|
|
71
|
-
"react-router-dom": "^6.
|
|
72
|
-
"ts-jest": "^29.1.
|
|
70
|
+
"react-router": "^6.23.1",
|
|
71
|
+
"react-router-dom": "^6.23.1",
|
|
72
|
+
"ts-jest": "^29.1.4",
|
|
73
73
|
"typescript": "^5.4.5",
|
|
74
|
-
"vite": "^5.2.
|
|
74
|
+
"vite": "^5.2.12",
|
|
75
75
|
"vite-plugin-fonts": "^0.7.0"
|
|
76
76
|
},
|
|
77
77
|
"files": [
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "b1f5dbd89d66bd75e8d214a4a6c40e07e371a1d1"
|
|
85
85
|
}
|
|
@@ -109,12 +109,12 @@ export const ConfigControllerProvider = React.memo(
|
|
|
109
109
|
deleteCollections: true
|
|
110
110
|
}), []);
|
|
111
111
|
|
|
112
|
-
const editCollection =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
const editCollection = ({
|
|
113
|
+
id,
|
|
114
|
+
fullPath,
|
|
115
|
+
parentCollectionIds,
|
|
116
|
+
parentCollection
|
|
117
|
+
}: {
|
|
118
118
|
id?: string,
|
|
119
119
|
fullPath?: string,
|
|
120
120
|
parentCollectionIds: string[],
|
|
@@ -133,16 +133,16 @@ export const ConfigControllerProvider = React.memo(
|
|
|
133
133
|
parentCollection,
|
|
134
134
|
redirect: false
|
|
135
135
|
});
|
|
136
|
-
}
|
|
136
|
+
};
|
|
137
137
|
|
|
138
|
-
const editProperty =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
const editProperty = ({
|
|
139
|
+
propertyKey,
|
|
140
|
+
property,
|
|
141
|
+
editedCollectionId,
|
|
142
|
+
currentPropertiesOrder,
|
|
143
|
+
parentCollectionIds,
|
|
144
|
+
collection
|
|
145
|
+
}: {
|
|
146
146
|
propertyKey?: string,
|
|
147
147
|
property?: Property,
|
|
148
148
|
currentPropertiesOrder?: string[],
|
|
@@ -171,15 +171,15 @@ export const ConfigControllerProvider = React.memo(
|
|
|
171
171
|
parentCollectionIds,
|
|
172
172
|
collectionEditable: collection?.editable ?? false
|
|
173
173
|
});
|
|
174
|
-
}
|
|
174
|
+
};
|
|
175
175
|
|
|
176
|
-
const createCollection =
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
const createCollection = ({
|
|
177
|
+
parentCollectionIds,
|
|
178
|
+
parentCollection,
|
|
179
|
+
initialValues,
|
|
180
|
+
redirect,
|
|
181
|
+
sourceClick
|
|
182
|
+
}: {
|
|
183
183
|
parentCollectionIds: string[],
|
|
184
184
|
parentCollection?: PersistedCollection
|
|
185
185
|
initialValues?: {
|
|
@@ -211,7 +211,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
211
211
|
initialValues,
|
|
212
212
|
redirect
|
|
213
213
|
});
|
|
214
|
-
}
|
|
214
|
+
};
|
|
215
215
|
|
|
216
216
|
return (
|
|
217
217
|
<ConfigControllerContext.Provider value={collectionConfigController}>
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "@firecms/core";
|
|
7
7
|
import { DeleteIcon, IconButton, Menu, MenuItem, MoreVertIcon, SettingsIcon, } from "@firecms/ui";
|
|
8
8
|
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
9
|
-
import {
|
|
9
|
+
import { useState } from "react";
|
|
10
10
|
import { useCollectionsConfigController } from "../useCollectionsConfigController";
|
|
11
11
|
|
|
12
12
|
export function HomePageEditorCollectionAction({
|
|
@@ -24,13 +24,13 @@ export function HomePageEditorCollectionAction({
|
|
|
24
24
|
collection
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
const onEditCollectionClicked =
|
|
27
|
+
const onEditCollectionClicked = () => {
|
|
28
28
|
collectionEditorController?.editCollection({ id: collection.id, parentCollectionIds: [] });
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
|
|
31
31
|
const [deleteRequested, setDeleteRequested] = useState(false);
|
|
32
32
|
|
|
33
|
-
const deleteCollection =
|
|
33
|
+
const deleteCollection = () => {
|
|
34
34
|
configController?.deleteCollection({ id: collection.id }).then(() => {
|
|
35
35
|
setDeleteRequested(false);
|
|
36
36
|
snackbarController.open({
|
|
@@ -38,7 +38,7 @@ export function HomePageEditorCollectionAction({
|
|
|
38
38
|
type: "success"
|
|
39
39
|
});
|
|
40
40
|
});
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
|
|
43
43
|
return <>
|
|
44
44
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginHomePageAdditionalCardsProps, useAuthController } from "@firecms/core";
|
|
2
|
-
import { AddIcon, Card,
|
|
2
|
+
import { AddIcon, Card, cls, Typography } from "@firecms/ui";
|
|
3
3
|
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
4
4
|
|
|
5
5
|
export function NewCollectionCard({
|
|
@@ -20,7 +20,7 @@ export function NewCollectionCard({
|
|
|
20
20
|
: true;
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<Card className={
|
|
23
|
+
<Card className={cls("h-full p-4 min-h-[124px]")}
|
|
24
24
|
onClick={collectionEditorController && canCreateCollections
|
|
25
25
|
? () => collectionEditorController.createCollection({
|
|
26
26
|
initialValues: group ? { group } : undefined,
|
|
@@ -31,7 +31,7 @@ export function NewCollectionCard({
|
|
|
31
31
|
: undefined}>
|
|
32
32
|
|
|
33
33
|
<div
|
|
34
|
-
className="flex
|
|
34
|
+
className="flex items-center justify-center h-full w-full flex-grow flex-col">
|
|
35
35
|
<AddIcon color="primary" size={"large"}/>
|
|
36
36
|
<Typography color="primary"
|
|
37
37
|
variant={"caption"}
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
AutocompleteItem,
|
|
6
6
|
BooleanSwitchWithLabel,
|
|
7
7
|
Chip,
|
|
8
|
-
|
|
8
|
+
ClearIcon,
|
|
9
|
+
cls,
|
|
9
10
|
Container,
|
|
10
11
|
DebouncedTextField,
|
|
11
12
|
Dialog,
|
|
@@ -146,7 +147,7 @@ export function CollectionDetailsForm({
|
|
|
146
147
|
</FieldCaption>
|
|
147
148
|
</div>
|
|
148
149
|
|
|
149
|
-
<div className={
|
|
150
|
+
<div className={cls("col-span-12 ", isSubcollection ? "" : "sm:col-span-8")}>
|
|
150
151
|
<Field name={"path"}
|
|
151
152
|
as={DebouncedTextField}
|
|
152
153
|
label={"Path"}
|
|
@@ -235,6 +236,35 @@ export function CollectionDetailsForm({
|
|
|
235
236
|
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define a singular name for your entities"}
|
|
236
237
|
</FieldCaption>
|
|
237
238
|
</div>
|
|
239
|
+
<div className={"col-span-12"}>
|
|
240
|
+
<TextField
|
|
241
|
+
error={showErrors && Boolean(errors.sideDialogWidth)}
|
|
242
|
+
name={"sideDialogWidth"}
|
|
243
|
+
type={"number"}
|
|
244
|
+
aria-describedby={"sideDialogWidth-helper"}
|
|
245
|
+
onChange={(e) => {
|
|
246
|
+
setFieldTouched("sideDialogWidth", true);
|
|
247
|
+
const value = e.target.value;
|
|
248
|
+
if (!value) {
|
|
249
|
+
setFieldValue("sideDialogWidth", null);
|
|
250
|
+
} else if (!isNaN(Number(value))) {
|
|
251
|
+
setFieldValue("sideDialogWidth", Number(value));
|
|
252
|
+
}
|
|
253
|
+
}}
|
|
254
|
+
endAdornment={<IconButton
|
|
255
|
+
size={"small"}
|
|
256
|
+
onClick={() => {
|
|
257
|
+
setFieldValue("sideDialogWidth", null);
|
|
258
|
+
}}
|
|
259
|
+
disabled={!values.sideDialogWidth}>
|
|
260
|
+
<ClearIcon size={"small"}/>
|
|
261
|
+
</IconButton>}
|
|
262
|
+
value={values.sideDialogWidth ?? ""}
|
|
263
|
+
label={"Side dialog width"}/>
|
|
264
|
+
<FieldCaption error={showErrors && Boolean(errors.singularName)}>
|
|
265
|
+
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define the width (in pixels) of entities side dialog. Default is 768px"}
|
|
266
|
+
</FieldCaption>
|
|
267
|
+
</div>
|
|
238
268
|
<div className={"col-span-12"}>
|
|
239
269
|
<TextField
|
|
240
270
|
error={showErrors && Boolean(errors.description)}
|
|
@@ -272,7 +302,7 @@ export function CollectionDetailsForm({
|
|
|
272
302
|
<div className={"col-span-12"}>
|
|
273
303
|
<Select
|
|
274
304
|
name="customId"
|
|
275
|
-
label="
|
|
305
|
+
label="Document IDs generation"
|
|
276
306
|
position={"item-aligned"}
|
|
277
307
|
disabled={customIdValue === "code_defined"}
|
|
278
308
|
onValueChange={(v) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import {
|
|
4
4
|
CircularProgressCenter,
|
|
5
5
|
EntityCollection,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
ArrowBackIcon,
|
|
27
27
|
Button,
|
|
28
|
-
|
|
28
|
+
cls,
|
|
29
29
|
coolIconKeys,
|
|
30
30
|
defaultBorderMixin,
|
|
31
31
|
Dialog,
|
|
@@ -88,13 +88,13 @@ export function CollectionEditorDialog(props: CollectionEditorDialogProps) {
|
|
|
88
88
|
const [formDirty, setFormDirty] = React.useState<boolean>(false);
|
|
89
89
|
const [unsavedChangesDialogOpen, setUnsavedChangesDialogOpen] = React.useState<boolean>(false);
|
|
90
90
|
|
|
91
|
-
const handleCancel =
|
|
91
|
+
const handleCancel = () => {
|
|
92
92
|
if (!formDirty) {
|
|
93
93
|
props.handleClose(undefined);
|
|
94
94
|
} else {
|
|
95
95
|
setUnsavedChangesDialogOpen(true);
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
};
|
|
98
98
|
|
|
99
99
|
useEffect(() => {
|
|
100
100
|
if (!open) {
|
|
@@ -170,7 +170,7 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
|
170
170
|
} catch (e) {
|
|
171
171
|
console.error(e);
|
|
172
172
|
}
|
|
173
|
-
}, [props.editedCollectionId, props.parentCollectionIds, navigation]);
|
|
173
|
+
}, [props.editedCollectionId, props.parentCollectionIds, navigation.initialised, navigation.getCollectionFromPaths]);
|
|
174
174
|
|
|
175
175
|
if (!topLevelNavigation) {
|
|
176
176
|
throw Error("Internal: Navigation not ready in collection editor");
|
|
@@ -294,7 +294,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
294
294
|
});
|
|
295
295
|
};
|
|
296
296
|
|
|
297
|
-
const setNextMode =
|
|
297
|
+
const setNextMode = () => {
|
|
298
298
|
if (currentView === "details") {
|
|
299
299
|
if (importConfig.inUse) {
|
|
300
300
|
setCurrentView("import_data_saving");
|
|
@@ -315,14 +315,14 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
315
315
|
setCurrentView("details");
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
}
|
|
318
|
+
};
|
|
319
319
|
|
|
320
|
-
const doCollectionInference =
|
|
320
|
+
const doCollectionInference = (collection: PersistedCollection<any>) => {
|
|
321
321
|
if (!collectionInference) return undefined;
|
|
322
322
|
return collectionInference?.(collection.path, collection.collectionGroup ?? false, parentCollectionIds ?? []);
|
|
323
|
-
}
|
|
323
|
+
};
|
|
324
324
|
|
|
325
|
-
const inferCollectionFromData =
|
|
325
|
+
const inferCollectionFromData = async (newCollection: PersistedCollection<M>) => {
|
|
326
326
|
|
|
327
327
|
try {
|
|
328
328
|
if (!doCollectionInference) {
|
|
@@ -366,10 +366,10 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
366
366
|
});
|
|
367
367
|
return newCollection;
|
|
368
368
|
}
|
|
369
|
-
}
|
|
369
|
+
};
|
|
370
370
|
|
|
371
371
|
const onSubmit = (newCollectionState: PersistedCollection<M>, formexController: FormexController<PersistedCollection<M>>) => {
|
|
372
|
-
console.
|
|
372
|
+
console.debug("Submitting collection", newCollectionState);
|
|
373
373
|
try {
|
|
374
374
|
|
|
375
375
|
if (!isNewCollection) {
|
|
@@ -526,7 +526,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
526
526
|
|
|
527
527
|
<>
|
|
528
528
|
{!isNewCollection && <Tabs value={currentView}
|
|
529
|
-
className={
|
|
529
|
+
className={cls(defaultBorderMixin, "justify-end bg-gray-50 dark:bg-gray-950 border-b")}
|
|
530
530
|
onValueChange={(v) => setCurrentView(v as EditorView)}>
|
|
531
531
|
<Tab value={"details"}>
|
|
532
532
|
Details
|
|
@@ -541,7 +541,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
541
541
|
|
|
542
542
|
<form noValidate
|
|
543
543
|
onSubmit={formController.handleSubmit}
|
|
544
|
-
className={
|
|
544
|
+
className={cls(
|
|
545
545
|
isNewCollection ? "h-full" : "h-[calc(100%-48px)]",
|
|
546
546
|
"flex-grow flex flex-col relative")}>
|
|
547
547
|
|
|
@@ -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
|
<>
|