@firecms/collection_editor 3.0.0-canary.2 → 3.0.0-canary.21
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 +390 -397
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/persisted_collection.d.ts +1 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +1 -1
- package/dist/ui/collection_editor/utils/supported_fields.d.ts +2 -2
- package/package.json +18 -18
- package/src/ConfigControllerProvider.tsx +1 -1
- package/src/types/persisted_collection.ts +1 -1
- package/src/ui/MissingReferenceWidget.tsx +2 -1
- package/src/ui/NewCollectionButton.tsx +12 -10
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +17 -18
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +13 -9
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +1 -1
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +1 -1
- package/src/ui/collection_editor/EnumForm.tsx +3 -4
- package/src/ui/collection_editor/PropertyEditView.tsx +4 -4
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +1 -1
- package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +7 -8
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +7 -8
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +3 -4
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +3 -4
- package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +3 -4
- package/src/ui/collection_editor/utils/supported_fields.tsx +3 -3
- package/src/useCollectionEditorPlugin.tsx +2 -4
- package/dist/ui/collection_editor/properties/FieldHelperView.d.ts +0 -4
- package/src/ui/collection_editor/properties/FieldHelperView.tsx +0 -13
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EntityCollection, User } from "@firecms/core";
|
|
2
2
|
export type PersistedCollection<M extends Record<string, any> = any, UserType extends User = User> = Omit<EntityCollection<M, UserType>, "subcollections"> & {
|
|
3
|
-
ownerId
|
|
3
|
+
ownerId?: string;
|
|
4
4
|
subcollections?: PersistedCollection<any, any>[];
|
|
5
5
|
editable?: boolean;
|
|
6
6
|
};
|
|
@@ -30,7 +30,7 @@ export interface CollectionEditorDialogProps {
|
|
|
30
30
|
parentCollection?: PersistedCollection;
|
|
31
31
|
}
|
|
32
32
|
export declare function CollectionEditorDialog(props: CollectionEditorDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
export declare function CollectionEditor
|
|
33
|
+
export declare function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
34
34
|
handleCancel: () => void;
|
|
35
35
|
setFormDirty: (dirty: boolean) => void;
|
|
36
36
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const supportedFieldsIds:
|
|
1
|
+
import { PropertyConfigId, PropertyConfig } from "@firecms/core";
|
|
2
|
+
export declare const supportedFieldsIds: PropertyConfigId[];
|
|
3
3
|
export declare const supportedFields: Record<string, PropertyConfig>;
|
package/package.json
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-canary.
|
|
4
|
+
"version": "3.0.0-canary.21",
|
|
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-canary.
|
|
11
|
-
"@firecms/formex": "^3.0.0-canary.
|
|
12
|
-
"@firecms/schema_inference": "^3.0.0-canary.
|
|
13
|
-
"@firecms/ui": "^3.0.0-canary.
|
|
10
|
+
"@firecms/data_import_export": "^3.0.0-canary.21",
|
|
11
|
+
"@firecms/formex": "^3.0.0-canary.21",
|
|
12
|
+
"@firecms/schema_inference": "^3.0.0-canary.21",
|
|
13
|
+
"@firecms/ui": "^3.0.0-canary.21",
|
|
14
14
|
"json5": "^2.2.3",
|
|
15
15
|
"prism-react-renderer": "^2.3.1"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"react": "^18.2.0",
|
|
19
19
|
"react-dom": "^18.2.0",
|
|
20
|
-
"react-router": "^6.
|
|
21
|
-
"react-router-dom": "^6.
|
|
20
|
+
"react-router": "^6.22.0",
|
|
21
|
+
"react-router-dom": "^6.22.0"
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"import": "./dist/index.es.js",
|
|
26
26
|
"require": "./dist/index.umd.js",
|
|
27
|
-
"types": "./dist/
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
28
|
},
|
|
29
29
|
"./package.json": "./package.json"
|
|
30
30
|
},
|
|
@@ -54,24 +54,24 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@jest/globals": "^29.7.0",
|
|
57
|
-
"@types/react": "^18.2.
|
|
58
|
-
"@types/react-dom": "^18.2.
|
|
59
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
60
|
-
"@typescript-eslint/parser": "^
|
|
57
|
+
"@types/react": "^18.2.67",
|
|
58
|
+
"@types/react-dom": "^18.2.22",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
|
60
|
+
"@typescript-eslint/parser": "^7.3.1",
|
|
61
61
|
"@vitejs/plugin-react": "^4.2.1",
|
|
62
|
-
"eslint": "^8.
|
|
62
|
+
"eslint": "^8.57.0",
|
|
63
63
|
"eslint-config-standard": "^17.1.0",
|
|
64
64
|
"eslint-plugin-import": "^2.29.1",
|
|
65
|
-
"eslint-plugin-n": "^
|
|
65
|
+
"eslint-plugin-n": "^16.6.2",
|
|
66
66
|
"eslint-plugin-promise": "^6.1.1",
|
|
67
|
-
"eslint-plugin-react": "^7.
|
|
67
|
+
"eslint-plugin-react": "^7.34.1",
|
|
68
68
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
69
69
|
"jest": "^29.7.0",
|
|
70
70
|
"react-router": "^6.22.0",
|
|
71
71
|
"react-router-dom": "^6.22.0",
|
|
72
72
|
"ts-jest": "^29.1.2",
|
|
73
|
-
"typescript": "^5.
|
|
74
|
-
"vite": "^5.
|
|
73
|
+
"typescript": "^5.4.2",
|
|
74
|
+
"vite": "^5.2.3",
|
|
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": "e451246cf15bdd8d934b5e2a70d86f606f6292f5"
|
|
85
85
|
}
|
|
@@ -161,7 +161,7 @@ export const ConfigControllerProvider = React.memo(
|
|
|
161
161
|
parentCollectionIds: string[],
|
|
162
162
|
collection: PersistedCollection,
|
|
163
163
|
}) => {
|
|
164
|
-
console.debug("
|
|
164
|
+
console.debug("Edit property", propertyKey, property, editedCollectionId, currentPropertiesOrder, parentCollectionIds, collection);
|
|
165
165
|
onAnalyticsEvent?.("edit_property", { propertyKey, editedCollectionId });
|
|
166
166
|
// namespace is all the path until the last dot
|
|
167
167
|
const namespace = propertyKey && propertyKey.includes(".")
|
|
@@ -3,7 +3,7 @@ import { EntityCollection, User } from "@firecms/core";
|
|
|
3
3
|
export type PersistedCollection<M extends Record<string, any> = any, UserType extends User = User>
|
|
4
4
|
= Omit<EntityCollection<M, UserType>, "subcollections"> & {
|
|
5
5
|
// properties: Properties<M>;
|
|
6
|
-
ownerId
|
|
6
|
+
ownerId?: string;
|
|
7
7
|
subcollections?: PersistedCollection<any, any>[];
|
|
8
8
|
editable?: boolean;
|
|
9
9
|
}
|
|
@@ -11,7 +11,8 @@ export function MissingReferenceWidget({ path: pathProp }: {
|
|
|
11
11
|
const collectionEditor = useCollectionEditorController();
|
|
12
12
|
return <div className={"p-1 flex flex-col items-center"}>
|
|
13
13
|
<ErrorView error={"No collection for path: " + path}/>
|
|
14
|
-
<Button className={"mx-2"} variant={"outlined"}
|
|
14
|
+
<Button className={"mx-2"} variant={"outlined"}
|
|
15
|
+
size={"small"}
|
|
15
16
|
onClick={() => {
|
|
16
17
|
collectionEditor.createCollection({
|
|
17
18
|
initialValues: { path, name: unslugify(path) },
|
|
@@ -3,14 +3,16 @@ import { useCollectionEditorController } from "../useCollectionEditorController"
|
|
|
3
3
|
|
|
4
4
|
export function NewCollectionButton() {
|
|
5
5
|
const collectionEditorController = useCollectionEditorController();
|
|
6
|
-
return <
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
return <div className={"bg-gray-50 dark:bg-gray-900 min-w-fit rounded"}>
|
|
7
|
+
<Button className={"min-w-fit"}
|
|
8
|
+
variant={"outlined"}
|
|
9
|
+
onClick={() => collectionEditorController.createCollection({
|
|
10
|
+
parentCollectionIds: [],
|
|
11
|
+
redirect: true,
|
|
12
|
+
sourceClick: "new_collection_button"
|
|
13
|
+
})}>
|
|
14
|
+
<AddIcon/>
|
|
15
|
+
New collection
|
|
16
|
+
</Button>
|
|
17
|
+
</div>
|
|
16
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { EntityCollection, IconForView, SearchIconsView, singular, toSnakeCase, } from "@firecms/core";
|
|
2
|
+
import { EntityCollection, FieldCaption, IconForView, SearchIconsView, singular, toSnakeCase, } from "@firecms/core";
|
|
3
3
|
import {
|
|
4
4
|
Autocomplete,
|
|
5
5
|
AutocompleteItem,
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
useAutoComplete
|
|
21
21
|
} from "@firecms/ui";
|
|
22
22
|
|
|
23
|
-
import { FieldHelperView } from "./properties/FieldHelperView";
|
|
24
23
|
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
25
24
|
|
|
26
25
|
export function CollectionDetailsForm({
|
|
@@ -142,9 +141,9 @@ export function CollectionDetailsForm({
|
|
|
142
141
|
label={"Name"}
|
|
143
142
|
required
|
|
144
143
|
error={showErrors && Boolean(errors.name)}/>
|
|
145
|
-
<
|
|
144
|
+
<FieldCaption error={touched.name && Boolean(errors.name)}>
|
|
146
145
|
{touched.name && Boolean(errors.name) ? errors.name : "Name of in this collection, usually a plural name (e.g. Products)"}
|
|
147
|
-
</
|
|
146
|
+
</FieldCaption>
|
|
148
147
|
</div>
|
|
149
148
|
|
|
150
149
|
<div className={cn("col-span-12 ", isSubcollection ? "" : "sm:col-span-8")}>
|
|
@@ -155,11 +154,11 @@ export function CollectionDetailsForm({
|
|
|
155
154
|
required
|
|
156
155
|
error={showErrors && Boolean(errors.path)}/>
|
|
157
156
|
|
|
158
|
-
<
|
|
157
|
+
<FieldCaption error={touched.path && Boolean(errors.path)}>
|
|
159
158
|
{touched.path && Boolean(errors.path)
|
|
160
159
|
? errors.path
|
|
161
160
|
: isSubcollection ? "Relative path to the parent (no need to include the parent path)" : "Path that this collection is stored in, in the database"}
|
|
162
|
-
</
|
|
161
|
+
</FieldCaption>
|
|
163
162
|
|
|
164
163
|
</div>
|
|
165
164
|
|
|
@@ -190,9 +189,9 @@ export function CollectionDetailsForm({
|
|
|
190
189
|
</AutocompleteItem>;
|
|
191
190
|
})}
|
|
192
191
|
</Autocomplete>
|
|
193
|
-
<
|
|
192
|
+
<FieldCaption>
|
|
194
193
|
{showErrors && Boolean(errors.group) ? errors.group : "Group of the collection"}
|
|
195
|
-
</
|
|
194
|
+
</FieldCaption>
|
|
196
195
|
</div>}
|
|
197
196
|
|
|
198
197
|
<div className={"col-span-12"}>
|
|
@@ -216,9 +215,9 @@ export function CollectionDetailsForm({
|
|
|
216
215
|
disabled={!isNewCollection}
|
|
217
216
|
label={"Collection id"}
|
|
218
217
|
error={showErrors && Boolean(errors.id)}/>
|
|
219
|
-
<
|
|
218
|
+
<FieldCaption error={touched.id && Boolean(errors.id)}>
|
|
220
219
|
{touched.id && Boolean(errors.id) ? errors.id : "This id identifies this collection"}
|
|
221
|
-
</
|
|
220
|
+
</FieldCaption>
|
|
222
221
|
</div>
|
|
223
222
|
|
|
224
223
|
<div className={"col-span-12"}>
|
|
@@ -232,9 +231,9 @@ export function CollectionDetailsForm({
|
|
|
232
231
|
}}
|
|
233
232
|
value={values.singularName ?? ""}
|
|
234
233
|
label={"Singular name"}/>
|
|
235
|
-
<
|
|
234
|
+
<FieldCaption error={showErrors && Boolean(errors.singularName)}>
|
|
236
235
|
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define a singular name for your entities"}
|
|
237
|
-
</
|
|
236
|
+
</FieldCaption>
|
|
238
237
|
</div>
|
|
239
238
|
<div className={"col-span-12"}>
|
|
240
239
|
<TextField
|
|
@@ -247,9 +246,9 @@ export function CollectionDetailsForm({
|
|
|
247
246
|
aria-describedby="description-helper-text"
|
|
248
247
|
label="Description"
|
|
249
248
|
/>
|
|
250
|
-
<
|
|
249
|
+
<FieldCaption error={showErrors && Boolean(errors.description)}>
|
|
251
250
|
{showErrors && Boolean(errors.description) ? errors.description : "Description of the collection, you can use markdown"}
|
|
252
|
-
</
|
|
251
|
+
</FieldCaption>
|
|
253
252
|
</div>
|
|
254
253
|
|
|
255
254
|
<div className={"col-span-12"}>
|
|
@@ -316,11 +315,11 @@ export function CollectionDetailsForm({
|
|
|
316
315
|
onValueChange={(v) => setFieldValue("collectionGroup", v)}
|
|
317
316
|
value={values.collectionGroup ?? false}
|
|
318
317
|
/>
|
|
319
|
-
<
|
|
318
|
+
<FieldCaption>
|
|
320
319
|
A collection group consists of all collections with the same path. This allows
|
|
321
320
|
you
|
|
322
321
|
to query over multiple collections at once.
|
|
323
|
-
</
|
|
322
|
+
</FieldCaption>
|
|
324
323
|
</div>
|
|
325
324
|
<div className={"col-span-12"}>
|
|
326
325
|
<BooleanSwitchWithLabel
|
|
@@ -329,11 +328,11 @@ export function CollectionDetailsForm({
|
|
|
329
328
|
onValueChange={(v) => setFieldValue("textSearchEnabled", v)}
|
|
330
329
|
value={values.textSearchEnabled ?? false}
|
|
331
330
|
/>
|
|
332
|
-
<
|
|
331
|
+
<FieldCaption>
|
|
333
332
|
Allow text search for this collection. If you have not specified a text search
|
|
334
333
|
delegate, this will use the built-in local text search. This is not recommended
|
|
335
334
|
for large collections, as it may incur in performance and cost issues.
|
|
336
|
-
</
|
|
335
|
+
</FieldCaption>
|
|
337
336
|
</div>
|
|
338
337
|
</div>
|
|
339
338
|
</ExpandablePanel>
|
|
@@ -136,7 +136,7 @@ type EditorView = "welcome"
|
|
|
136
136
|
| "extra_view"
|
|
137
137
|
| "subcollections";
|
|
138
138
|
|
|
139
|
-
export function CollectionEditor
|
|
139
|
+
export function CollectionEditor(props: CollectionEditorDialogProps & {
|
|
140
140
|
handleCancel: () => void,
|
|
141
141
|
setFormDirty: (dirty: boolean) => void
|
|
142
142
|
}) {
|
|
@@ -154,14 +154,14 @@ export function CollectionEditor<M extends Record<string, any>>(props: Collectio
|
|
|
154
154
|
const collectionsInThisLevel = (props.parentCollection ? props.parentCollection.subcollections : collections) ?? [];
|
|
155
155
|
const existingPaths = collectionsInThisLevel.map(col => col.path.trim().toLowerCase());
|
|
156
156
|
const existingIds = collectionsInThisLevel.map(col => col.id?.trim().toLowerCase()).filter(Boolean) as string[];
|
|
157
|
-
const [collection, setCollection] = React.useState<PersistedCollection<
|
|
157
|
+
const [collection, setCollection] = React.useState<PersistedCollection<any> | undefined>();
|
|
158
158
|
const [initialLoadingCompleted, setInitialLoadingCompleted] = React.useState(false);
|
|
159
159
|
|
|
160
160
|
useEffect(() => {
|
|
161
161
|
try {
|
|
162
162
|
if (navigation.initialised) {
|
|
163
163
|
if (props.editedCollectionId) {
|
|
164
|
-
setCollection(navigation.getCollectionFromPaths
|
|
164
|
+
setCollection(navigation.getCollectionFromPaths([...(props.parentCollectionIds ?? []), props.editedCollectionId]));
|
|
165
165
|
} else {
|
|
166
166
|
setCollection(undefined);
|
|
167
167
|
}
|
|
@@ -186,14 +186,14 @@ export function CollectionEditor<M extends Record<string, any>>(props: Collectio
|
|
|
186
186
|
}
|
|
187
187
|
: undefined;
|
|
188
188
|
|
|
189
|
-
const initialValues: PersistedCollection<
|
|
189
|
+
const initialValues: PersistedCollection<any> = initialCollection
|
|
190
190
|
? applyPropertyConfigs(initialCollection, propertyConfigs)
|
|
191
191
|
: {
|
|
192
192
|
id: initialValuesProp?.path ?? randomString(16),
|
|
193
193
|
path: initialValuesProp?.path ?? "",
|
|
194
194
|
name: initialValuesProp?.name ?? "",
|
|
195
195
|
group: initialValuesProp?.group ?? "",
|
|
196
|
-
properties: {} as PropertiesOrBuilders
|
|
196
|
+
properties: {} as PropertiesOrBuilders,
|
|
197
197
|
propertiesOrder: [],
|
|
198
198
|
icon: coolIconKeys[Math.floor(Math.random() * coolIconKeys.length)],
|
|
199
199
|
ownerId: authController.user?.uid ?? ""
|
|
@@ -473,7 +473,8 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
473
473
|
submitCount
|
|
474
474
|
} = formController;
|
|
475
475
|
|
|
476
|
-
|
|
476
|
+
// TODO: getting data is only working in root collections with this code
|
|
477
|
+
const path = values.path;
|
|
477
478
|
const updatedFullPath = fullPath?.includes("/") ? fullPath?.split("/").slice(0, -1).join("/") + "/" + path : path; // TODO: this path is wrong
|
|
478
479
|
const pathError = validatePath(path, isNewCollection, existingPaths, values.id);
|
|
479
480
|
|
|
@@ -575,6 +576,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
575
576
|
{currentView === "import_data_saving" && importConfig &&
|
|
576
577
|
<ImportSaveInProgress importConfig={importConfig}
|
|
577
578
|
collection={values}
|
|
579
|
+
path={path}
|
|
578
580
|
onImportSuccess={async (importedCollection) => {
|
|
579
581
|
snackbarController.open({
|
|
580
582
|
type: "info",
|
|
@@ -733,9 +735,11 @@ function CollectionEditorInternal<M extends Record<string, any>>({
|
|
|
733
735
|
function applyPropertyConfigs<M extends Record<string, any> = any>(collection: PersistedCollection<M>, propertyConfigs: Record<string, PropertyConfig<any>>): PersistedCollection<M> {
|
|
734
736
|
const { properties, ...rest } = collection;
|
|
735
737
|
const propertiesResult: PropertiesOrBuilders<any> = {};
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
738
|
+
if (properties) {
|
|
739
|
+
Object.keys(properties).forEach((key) => {
|
|
740
|
+
propertiesResult[key] = applyPropertiesConfig(properties[key] as PropertyOrBuilder, propertyConfigs);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
739
743
|
|
|
740
744
|
return { ...rest, properties: propertiesResult };
|
|
741
745
|
}
|
|
@@ -190,7 +190,7 @@ export function TemplateButton({
|
|
|
190
190
|
onClick={onClick}
|
|
191
191
|
className={cn(
|
|
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
|
-
"text-gray-700 dark:text-
|
|
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",
|
|
195
195
|
"border-gray-400 dark:border-gray-600 "
|
|
196
196
|
)}
|
|
@@ -301,7 +301,7 @@ export function CollectionPropertiesEditorForm({
|
|
|
301
301
|
? values.propertiesOrder
|
|
302
302
|
: Object.keys(values.properties)) as string[];
|
|
303
303
|
|
|
304
|
-
const owner = useMemo(() => getUser(values.ownerId), [getUser, values.ownerId]);
|
|
304
|
+
const owner = useMemo(() => values.ownerId ? getUser(values.ownerId) : null, [getUser, values.ownerId]);
|
|
305
305
|
|
|
306
306
|
const onPropertyClick = useCallback((propertyKey: string, namespace?: string) => {
|
|
307
307
|
console.debug("CollectionEditor: onPropertyClick", {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect } from "react";
|
|
2
2
|
import equal from "react-fast-compare"
|
|
3
3
|
|
|
4
|
-
import { ArrayContainer, EnumValueConfig, EnumValues, } from "@firecms/core";
|
|
4
|
+
import { ArrayContainer, EnumValueConfig, EnumValues, FieldCaption, } from "@firecms/core";
|
|
5
5
|
import {
|
|
6
6
|
AutoAwesomeIcon,
|
|
7
7
|
Badge,
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
SettingsIcon,
|
|
18
18
|
Typography
|
|
19
19
|
} from "@firecms/ui";
|
|
20
|
-
import { FieldHelperView } from "./properties/FieldHelperView";
|
|
21
20
|
import { extractEnumFromValues } from "@firecms/schema_inference";
|
|
22
21
|
import { Field, Formex, getIn, useCreateFormex, useFormex } from "@firecms/formex";
|
|
23
22
|
|
|
@@ -337,9 +336,9 @@ function EnumEntryDialog({
|
|
|
337
336
|
autoComplete="off"
|
|
338
337
|
error={Boolean(idError)}/>
|
|
339
338
|
|
|
340
|
-
<
|
|
339
|
+
<FieldCaption error={Boolean(idError)}>
|
|
341
340
|
{idError ?? "Value saved in the data source"}
|
|
342
|
-
</
|
|
341
|
+
</FieldCaption>
|
|
343
342
|
</div>}
|
|
344
343
|
</DialogContent>
|
|
345
344
|
|
|
@@ -5,7 +5,7 @@ import { Formex, FormexController, getIn, useCreateFormex } from "@firecms/forme
|
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_FIELD_CONFIGS,
|
|
7
7
|
DeleteConfirmationDialog,
|
|
8
|
-
|
|
8
|
+
PropertyConfigId,
|
|
9
9
|
getFieldConfig,
|
|
10
10
|
getFieldId,
|
|
11
11
|
isPropertyBuilder,
|
|
@@ -375,7 +375,7 @@ function PropertyEditFormFields({
|
|
|
375
375
|
}
|
|
376
376
|
}, [errors, onError, propertyNamespace, values?.id]);
|
|
377
377
|
|
|
378
|
-
const onWidgetSelectChanged = (newSelectedWidgetId:
|
|
378
|
+
const onWidgetSelectChanged = (newSelectedWidgetId: PropertyConfigId) => {
|
|
379
379
|
setSelectedFieldConfigId(newSelectedWidgetId);
|
|
380
380
|
setValues(updatePropertyFromWidget(values, newSelectedWidgetId, propertyConfigs));
|
|
381
381
|
// Ugly hack to autofocus the name field
|
|
@@ -495,7 +495,7 @@ function PropertyEditFormFields({
|
|
|
495
495
|
return <em>Select a property
|
|
496
496
|
widget</em>;
|
|
497
497
|
}
|
|
498
|
-
const key = value as
|
|
498
|
+
const key = value as PropertyConfigId;
|
|
499
499
|
const propertyConfig = DEFAULT_FIELD_CONFIGS[key] ?? propertyConfigs[key];
|
|
500
500
|
const baseProperty = propertyConfig.property;
|
|
501
501
|
const baseFieldConfig = baseProperty && !isPropertyBuilder(baseProperty) ? getFieldConfig(baseProperty, propertyConfigs) : undefined;
|
|
@@ -524,7 +524,7 @@ function PropertyEditFormFields({
|
|
|
524
524
|
</div>
|
|
525
525
|
}}
|
|
526
526
|
onValueChange={(value) => {
|
|
527
|
-
onWidgetSelectChanged(value as
|
|
527
|
+
onWidgetSelectChanged(value as PropertyConfigId);
|
|
528
528
|
}}>
|
|
529
529
|
{displayedWidgets.map(([key, propertyConfig]) => {
|
|
530
530
|
const baseProperty = propertyConfig.property;
|
|
@@ -149,7 +149,7 @@ export function CollectionEditorImportMapping({
|
|
|
149
149
|
idColumn={importConfig.idColumn}
|
|
150
150
|
originProperties={importConfig.originProperties}
|
|
151
151
|
destinationProperties={values.properties as Properties}
|
|
152
|
-
onIdPropertyChanged={(value) => importConfig.setIdColumn(value)}
|
|
152
|
+
onIdPropertyChanged={(value) => importConfig.setIdColumn(value ?? undefined)}
|
|
153
153
|
buildPropertyView={({
|
|
154
154
|
property,
|
|
155
155
|
propertyKey,
|
|
@@ -2,8 +2,7 @@ import { Field, getIn, useFormex } from "@firecms/formex";
|
|
|
2
2
|
import { DebouncedTextField } from "@firecms/ui";
|
|
3
3
|
import { PropertyWithId } from "../PropertyEditView";
|
|
4
4
|
import React from "react";
|
|
5
|
-
import {
|
|
6
|
-
import { toSnakeCase, unslugify } from "@firecms/core";
|
|
5
|
+
import { FieldCaption, toSnakeCase, unslugify } from "@firecms/core";
|
|
7
6
|
|
|
8
7
|
type CommonPropertyFieldsProps = {
|
|
9
8
|
showErrors: boolean,
|
|
@@ -64,9 +63,9 @@ export const CommonPropertyFields = React.forwardRef<HTMLDivElement, CommonPrope
|
|
|
64
63
|
disabled={disabled}
|
|
65
64
|
error={Boolean(nameError)}/>
|
|
66
65
|
|
|
67
|
-
<
|
|
66
|
+
<FieldCaption error={Boolean(nameError)}>
|
|
68
67
|
{nameError}
|
|
69
|
-
</
|
|
68
|
+
</FieldCaption>
|
|
70
69
|
</div>
|
|
71
70
|
|
|
72
71
|
<div>
|
|
@@ -88,9 +87,9 @@ export const CommonPropertyFields = React.forwardRef<HTMLDivElement, CommonPrope
|
|
|
88
87
|
required
|
|
89
88
|
size="small"
|
|
90
89
|
error={Boolean(idError)}/>
|
|
91
|
-
<
|
|
90
|
+
<FieldCaption error={Boolean(idError)}>
|
|
92
91
|
{idError}
|
|
93
|
-
</
|
|
92
|
+
</FieldCaption>
|
|
94
93
|
</div>
|
|
95
94
|
|
|
96
95
|
<div>
|
|
@@ -99,9 +98,9 @@ export const CommonPropertyFields = React.forwardRef<HTMLDivElement, CommonPrope
|
|
|
99
98
|
label={"Description"}
|
|
100
99
|
disabled={disabled}
|
|
101
100
|
error={Boolean(descriptionError)}/>
|
|
102
|
-
<
|
|
101
|
+
<FieldCaption error={Boolean(descriptionError)}>
|
|
103
102
|
{descriptionError}
|
|
104
|
-
</
|
|
103
|
+
</FieldCaption>
|
|
105
104
|
</div>
|
|
106
105
|
|
|
107
106
|
</div>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { getIn, useFormex } from "@firecms/formex";
|
|
3
|
-
import { NumberProperty, StringProperty } from "@firecms/core";
|
|
3
|
+
import { FieldCaption, NumberProperty, StringProperty } from "@firecms/core";
|
|
4
4
|
import { Select, SelectItem } from "@firecms/ui";
|
|
5
5
|
import { GeneralPropertyValidation } from "./validation/GeneralPropertyValidation";
|
|
6
6
|
import { ValidationPanel } from "./validation/ValidationPanel";
|
|
7
|
-
import { FieldHelperView } from "./FieldHelperView";
|
|
8
7
|
|
|
9
8
|
export function DateTimePropertyField({ disabled }: {
|
|
10
9
|
disabled: boolean;
|
|
@@ -47,14 +46,14 @@ export function DateTimePropertyField({ disabled }: {
|
|
|
47
46
|
<SelectItem value={"date_time"}> Date/Time </SelectItem>
|
|
48
47
|
<SelectItem value={"date"}> Date </SelectItem>
|
|
49
48
|
</Select>
|
|
50
|
-
<
|
|
49
|
+
<FieldCaption error={Boolean(modeError)}>
|
|
51
50
|
{modeError}
|
|
52
|
-
</
|
|
51
|
+
</FieldCaption>
|
|
53
52
|
|
|
54
53
|
<Select name={autoValuePath}
|
|
55
54
|
disabled={disabled}
|
|
56
55
|
value={autoValueValue ?? ""}
|
|
57
|
-
onValueChange={(v) => setFieldValue(autoValuePath, v)}
|
|
56
|
+
onValueChange={(v) => setFieldValue(autoValuePath, v === "none" ? null : v)}
|
|
58
57
|
renderValue={(v) => {
|
|
59
58
|
switch (v) {
|
|
60
59
|
case "on_create":
|
|
@@ -67,13 +66,13 @@ export function DateTimePropertyField({ disabled }: {
|
|
|
67
66
|
}}
|
|
68
67
|
error={Boolean(autoValueError)}
|
|
69
68
|
label={"Automatic value"}>
|
|
70
|
-
<SelectItem value={""}> None </SelectItem>
|
|
69
|
+
<SelectItem value={"none"}> None </SelectItem>
|
|
71
70
|
<SelectItem value={"on_create"}> On create </SelectItem>
|
|
72
71
|
<SelectItem value={"on_update"}> On any update </SelectItem>
|
|
73
72
|
</Select>
|
|
74
|
-
<
|
|
73
|
+
<FieldCaption error={Boolean(autoValueError)}>
|
|
75
74
|
{autoValueError ?? "Update this field automatically when creating or updating the entity"}
|
|
76
|
-
</
|
|
75
|
+
</FieldCaption>
|
|
77
76
|
|
|
78
77
|
</div>
|
|
79
78
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback, useState } from "react";
|
|
2
|
-
import { MapProperty, Property, PropertyConfig, } from "@firecms/core";
|
|
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";
|
|
5
5
|
import { getIn, useFormex } from "@firecms/formex";
|
|
6
6
|
import { PropertyTree } from "../PropertyTree";
|
|
7
7
|
import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
|
|
8
|
-
import { FieldHelperView } from "./FieldHelperView";
|
|
9
8
|
|
|
10
9
|
export function MapPropertyField({ disabled, getData, allowDataInference, propertyConfigs, collectionEditable }: {
|
|
11
10
|
disabled: boolean;
|
|
@@ -113,9 +112,9 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
|
|
|
113
112
|
onValueChange={(v) => setFieldValue("spreadChildren", v)}
|
|
114
113
|
value={values.spreadChildren ?? false}
|
|
115
114
|
/>
|
|
116
|
-
<
|
|
115
|
+
<FieldCaption>
|
|
117
116
|
Set this flag to true if you want to display the children of this group as individual columns.
|
|
118
|
-
</
|
|
117
|
+
</FieldCaption>
|
|
119
118
|
</div>
|
|
120
119
|
|
|
121
120
|
<PropertyFormDialog
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
3
|
-
import { IconForView, NumberProperty, StringProperty, useNavigationController } from "@firecms/core";
|
|
3
|
+
import { FieldCaption, IconForView, NumberProperty, StringProperty, useNavigationController } from "@firecms/core";
|
|
4
4
|
import { CircularProgress, Select, SelectGroup, SelectItem, Typography, } from "@firecms/ui";
|
|
5
|
-
import { FieldHelperView } from "./FieldHelperView";
|
|
6
5
|
|
|
7
6
|
export function ReferencePropertyField({
|
|
8
7
|
existing,
|
|
@@ -152,10 +151,10 @@ export function CollectionsSelect({
|
|
|
152
151
|
|
|
153
152
|
</Select>
|
|
154
153
|
|
|
155
|
-
<
|
|
154
|
+
<FieldCaption>
|
|
156
155
|
You can only edit the reference collection upon field
|
|
157
156
|
creation.
|
|
158
|
-
</
|
|
157
|
+
</FieldCaption>
|
|
159
158
|
</>
|
|
160
159
|
);
|
|
161
160
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { Field, FormexFieldProps, getIn, useFormex } from "@firecms/formex";
|
|
4
|
-
import { serializeRegExp } from "@firecms/core";
|
|
4
|
+
import { FieldCaption, serializeRegExp } from "@firecms/core";
|
|
5
5
|
import { DebouncedTextField, } from "@firecms/ui";
|
|
6
6
|
import { GeneralPropertyValidation } from "./GeneralPropertyValidation";
|
|
7
|
-
import { FieldHelperView } from "../FieldHelperView";
|
|
8
7
|
import { SwitchControl } from "../../SwitchControl";
|
|
9
8
|
|
|
10
9
|
export function StringPropertyValidation({
|
|
@@ -140,9 +139,9 @@ export function StringPropertyValidation({
|
|
|
140
139
|
disabled={disabled}
|
|
141
140
|
value={matchesStringValue}
|
|
142
141
|
error={Boolean(matchesError)}/>
|
|
143
|
-
<
|
|
142
|
+
<FieldCaption error={Boolean(matchesError)}>
|
|
144
143
|
{matchesError ? "Not a valid regexp" : "e.g. /^\\d+$/ for digits only"}
|
|
145
|
-
</
|
|
144
|
+
</FieldCaption>
|
|
146
145
|
</div>}
|
|
147
146
|
|
|
148
147
|
</div>
|