@firecms/collection_editor 3.0.0-beta.2 → 3.0.0-beta.4.pre.1
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 +579 -567
- 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/utils/supported_fields.d.ts +2 -2
- package/package.json +27 -19
- package/src/ConfigControllerProvider.tsx +1 -1
- package/src/types/persisted_collection.ts +1 -1
- package/src/ui/MissingReferenceWidget.tsx +2 -1
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +17 -18
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +8 -4
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +1 -1
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +26 -9
- package/src/ui/collection_editor/EnumForm.tsx +3 -4
- package/src/ui/collection_editor/PropertyEditView.tsx +4 -4
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +1 -2
- 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 +4 -6
- 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 +1 -3
- 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
|
};
|
|
@@ -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,24 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/collection_editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.4.pre.1",
|
|
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.4.pre.1",
|
|
11
|
+
"@firecms/formex": "^3.0.0-beta.4.pre.1",
|
|
12
|
+
"@firecms/schema_inference": "^3.0.0-beta.4.pre.1",
|
|
13
|
+
"@firecms/ui": "^3.0.0-beta.4.pre.1",
|
|
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.2",
|
|
21
|
+
"react-router-dom": "^6.22.2"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./dist/index.es.js",
|
|
26
|
+
"require": "./dist/index.umd.js",
|
|
27
|
+
"types": "./dist/src/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
22
30
|
},
|
|
23
31
|
"scripts": {
|
|
24
32
|
"dev": "vite",
|
|
@@ -46,24 +54,24 @@
|
|
|
46
54
|
},
|
|
47
55
|
"devDependencies": {
|
|
48
56
|
"@jest/globals": "^29.7.0",
|
|
49
|
-
"@types/react": "^18.2.
|
|
50
|
-
"@types/react-dom": "^18.2.
|
|
51
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
52
|
-
"@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",
|
|
53
61
|
"@vitejs/plugin-react": "^4.2.1",
|
|
54
|
-
"eslint": "^8.
|
|
62
|
+
"eslint": "^8.57.0",
|
|
55
63
|
"eslint-config-standard": "^17.1.0",
|
|
56
64
|
"eslint-plugin-import": "^2.29.1",
|
|
57
|
-
"eslint-plugin-n": "^
|
|
65
|
+
"eslint-plugin-n": "^16.6.2",
|
|
58
66
|
"eslint-plugin-promise": "^6.1.1",
|
|
59
|
-
"eslint-plugin-react": "^7.
|
|
67
|
+
"eslint-plugin-react": "^7.34.1",
|
|
60
68
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
61
69
|
"jest": "^29.7.0",
|
|
62
|
-
"react-router": "^6.22.
|
|
63
|
-
"react-router-dom": "^6.22.
|
|
70
|
+
"react-router": "^6.22.3",
|
|
71
|
+
"react-router-dom": "^6.22.3",
|
|
64
72
|
"ts-jest": "^29.1.2",
|
|
65
|
-
"typescript": "^5.
|
|
66
|
-
"vite": "^5.1.
|
|
73
|
+
"typescript": "^5.4.2",
|
|
74
|
+
"vite": "^5.1.6",
|
|
67
75
|
"vite-plugin-fonts": "^0.7.0"
|
|
68
76
|
},
|
|
69
77
|
"files": [
|
|
@@ -73,5 +81,5 @@
|
|
|
73
81
|
"publishConfig": {
|
|
74
82
|
"access": "public"
|
|
75
83
|
},
|
|
76
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "a197c6698a64aeb8f9608e6a177a7ecd149920de"
|
|
77
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) },
|
|
@@ -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>
|
|
@@ -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
|
)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { Field, getIn } from "@firecms/formex";
|
|
3
|
+
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
4
4
|
import {
|
|
5
5
|
EntityCollection,
|
|
6
6
|
ErrorBoundary,
|
|
@@ -34,7 +34,6 @@ import { OnPropertyChangedParams, PropertyForm, PropertyFormDialog } from "./Pro
|
|
|
34
34
|
import { PropertyTree } from "./PropertyTree";
|
|
35
35
|
import { PersistedCollection } from "../../types/persisted_collection";
|
|
36
36
|
import { GetCodeDialog } from "./GetCodeDialog";
|
|
37
|
-
import { useFormex } from "@firecms/formex";
|
|
38
37
|
|
|
39
38
|
type CollectionEditorFormProps = {
|
|
40
39
|
showErrors: boolean;
|
|
@@ -138,7 +137,9 @@ export function CollectionPropertiesEditorForm({
|
|
|
138
137
|
...newPropertyKeys.reduce((acc, propertyKey) => {
|
|
139
138
|
acc[propertyKey] = (newCollection.properties ?? {})[propertyKey];
|
|
140
139
|
return acc;
|
|
141
|
-
}, {} as {
|
|
140
|
+
}, {} as {
|
|
141
|
+
[key: string]: PropertyOrBuilder
|
|
142
|
+
}),
|
|
142
143
|
...values.properties
|
|
143
144
|
};
|
|
144
145
|
const updatedPropertiesOrder = [
|
|
@@ -224,11 +225,19 @@ export function CollectionPropertiesEditorForm({
|
|
|
224
225
|
previousId,
|
|
225
226
|
namespace
|
|
226
227
|
}: OnPropertyChangedParams) => {
|
|
228
|
+
|
|
227
229
|
const fullId = id ? getFullId(id, namespace) : undefined;
|
|
228
230
|
const propertyPath = fullId ? idToPropertiesPath(fullId) : undefined;
|
|
229
231
|
|
|
230
232
|
// If the id has changed we need to a little cleanup
|
|
231
233
|
if (previousId && previousId !== id) {
|
|
234
|
+
console.debug("onPropertyChanged, id change", {
|
|
235
|
+
id,
|
|
236
|
+
property,
|
|
237
|
+
previousId,
|
|
238
|
+
namespace
|
|
239
|
+
})
|
|
240
|
+
|
|
232
241
|
const previousFullId = getFullId(previousId, namespace);
|
|
233
242
|
const previousPropertyPath = idToPropertiesPath(previousFullId);
|
|
234
243
|
|
|
@@ -292,7 +301,7 @@ export function CollectionPropertiesEditorForm({
|
|
|
292
301
|
? values.propertiesOrder
|
|
293
302
|
: Object.keys(values.properties)) as string[];
|
|
294
303
|
|
|
295
|
-
const owner = useMemo(() => getUser(values.ownerId), [getUser, values.ownerId]);
|
|
304
|
+
const owner = useMemo(() => values.ownerId ? getUser(values.ownerId) : null, [getUser, values.ownerId]);
|
|
296
305
|
|
|
297
306
|
const onPropertyClick = useCallback((propertyKey: string, namespace?: string) => {
|
|
298
307
|
console.debug("CollectionEditor: onPropertyClick", {
|
|
@@ -420,11 +429,19 @@ export function CollectionPropertiesEditorForm({
|
|
|
420
429
|
/>}
|
|
421
430
|
|
|
422
431
|
{!selectedProperty &&
|
|
423
|
-
<
|
|
424
|
-
{
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
432
|
+
<div className={"w-full flex flex-col items-center justify-center h-full gap-4"}>
|
|
433
|
+
<Typography variant={"label"} className="">
|
|
434
|
+
{emptyCollection
|
|
435
|
+
? "Now you can add your first property"
|
|
436
|
+
: "Select a property to edit it"}
|
|
437
|
+
</Typography>
|
|
438
|
+
<Button variant={"outlined"}
|
|
439
|
+
onClick={() => setNewPropertyDialogOpen(true)}
|
|
440
|
+
>
|
|
441
|
+
<AddIcon/>
|
|
442
|
+
Add new property
|
|
443
|
+
</Button>
|
|
444
|
+
</div>}
|
|
428
445
|
|
|
429
446
|
{selectedProperty && isPropertyBuilder(selectedProperty) &&
|
|
430
447
|
<Typography variant={"label"} className="flex items-center justify-center">
|
|
@@ -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;
|
|
@@ -132,7 +132,6 @@ export function SubcollectionsEditTab({
|
|
|
132
132
|
Custom views
|
|
133
133
|
</Typography>
|
|
134
134
|
|
|
135
|
-
|
|
136
135
|
{totalEntityViews === 0 &&
|
|
137
136
|
<Alert action={<Button variant="text"
|
|
138
137
|
size={"small"}
|
|
@@ -140,7 +139,7 @@ export function SubcollectionsEditTab({
|
|
|
140
139
|
component={"a"}
|
|
141
140
|
rel="noopener noreferrer"
|
|
142
141
|
target="_blank">More info</Button>}>
|
|
143
|
-
Define your own custom views by uploading
|
|
142
|
+
Define your own custom views by uploading them with the CLI.
|
|
144
143
|
</Alert>
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -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,
|
|
@@ -40,7 +39,7 @@ export function ReferencePropertyField({
|
|
|
40
39
|
<Field name={pathPath}
|
|
41
40
|
pathPath={pathPath}
|
|
42
41
|
type="select"
|
|
43
|
-
disabled={existing || disabled}
|
|
42
|
+
disabled={(existing && Boolean(pathValue)) || disabled}
|
|
44
43
|
value={pathValue}
|
|
45
44
|
error={pathError}
|
|
46
45
|
handleChange={handleChange}
|
|
@@ -52,7 +51,6 @@ export function ReferencePropertyField({
|
|
|
52
51
|
);
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
|
|
56
54
|
export function CollectionsSelect({
|
|
57
55
|
disabled,
|
|
58
56
|
pathPath,
|
|
@@ -153,10 +151,10 @@ export function CollectionsSelect({
|
|
|
153
151
|
|
|
154
152
|
</Select>
|
|
155
153
|
|
|
156
|
-
<
|
|
154
|
+
<FieldCaption>
|
|
157
155
|
You can only edit the reference collection upon field
|
|
158
156
|
creation.
|
|
159
|
-
</
|
|
157
|
+
</FieldCaption>
|
|
160
158
|
</>
|
|
161
159
|
);
|
|
162
160
|
}
|