@firecms/collection_editor 3.0.0-alpha.9 → 3.0.0-beta.10
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/LICENSE +114 -21
- package/dist/ConfigControllerProvider.d.ts +13 -3
- package/dist/index.d.ts +4 -2
- package/dist/index.es.js +5587 -4976
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6829 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +36 -8
- package/dist/types/collection_inference.d.ts +1 -1
- package/dist/types/config_controller.d.ts +33 -6
- package/dist/types/persisted_collection.d.ts +4 -2
- package/dist/ui/CollectionViewHeaderAction.d.ts +11 -0
- package/dist/{components → ui}/EditorCollectionAction.d.ts +1 -1
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/MissingReferenceWidget.d.ts +3 -0
- package/dist/ui/NewCollectionButton.d.ts +1 -0
- package/dist/ui/PropertyAddColumnComponent.d.ts +8 -0
- package/dist/{components → ui}/collection_editor/CollectionDetailsForm.d.ts +3 -2
- package/dist/{components → ui}/collection_editor/CollectionEditorDialog.d.ts +15 -11
- package/dist/{components → ui}/collection_editor/CollectionEditorWelcomeView.d.ts +3 -3
- package/dist/{components → ui}/collection_editor/CollectionPropertiesEditorForm.d.ts +8 -6
- package/dist/{components → ui}/collection_editor/CollectionYupValidation.d.ts +3 -0
- package/dist/ui/collection_editor/EntityCustomViewsSelectDialog.d.ts +4 -0
- package/dist/{components → ui}/collection_editor/EnumForm.d.ts +1 -2
- package/dist/ui/collection_editor/GetCodeDialog.d.ts +5 -0
- package/dist/{components → ui}/collection_editor/PropertyEditView.d.ts +21 -11
- package/dist/{components → ui}/collection_editor/PropertyFieldPreview.d.ts +4 -3
- package/dist/{components → ui}/collection_editor/PropertyTree.d.ts +11 -7
- package/dist/{components → ui}/collection_editor/SubcollectionsEditTab.d.ts +3 -3
- package/dist/ui/collection_editor/SwitchControl.d.ts +8 -0
- package/dist/{components → ui}/collection_editor/import/CollectionEditorImportDataPreview.d.ts +1 -1
- package/dist/ui/collection_editor/import/CollectionEditorImportMapping.d.ts +14 -0
- package/dist/{components → ui}/collection_editor/import/clean_import_data.d.ts +1 -1
- package/dist/{components → ui}/collection_editor/properties/BlockPropertyField.d.ts +4 -1
- package/dist/{components → ui}/collection_editor/properties/CommonPropertyFields.d.ts +1 -1
- package/dist/{components → ui}/collection_editor/properties/MapPropertyField.d.ts +4 -1
- package/dist/ui/collection_editor/properties/MarkdownPropertyField.d.ts +4 -0
- package/dist/{components → ui}/collection_editor/properties/RepeatPropertyField.d.ts +4 -1
- package/dist/{components → ui}/collection_editor/properties/StringPropertyField.d.ts +1 -1
- package/dist/ui/collection_editor/properties/UrlPropertyField.d.ts +4 -0
- package/dist/ui/collection_editor/templates/blog_template.d.ts +2 -0
- package/dist/ui/collection_editor/templates/pages_template.d.ts +2 -0
- package/dist/ui/collection_editor/templates/products_template.d.ts +2 -0
- package/dist/ui/collection_editor/templates/users_template.d.ts +2 -0
- package/dist/{components → ui}/collection_editor/util.d.ts +1 -0
- package/dist/ui/collection_editor/utils/strings.d.ts +1 -0
- package/dist/ui/collection_editor/utils/supported_fields.d.ts +3 -0
- package/dist/ui/collection_editor/utils/update_property_for_widget.d.ts +2 -0
- package/dist/useCollectionEditorPlugin.d.ts +17 -6
- package/dist/utils/collections.d.ts +6 -0
- package/dist/utils/entities.d.ts +3 -4
- package/package.json +35 -37
- package/src/ConfigControllerProvider.tsx +350 -0
- package/src/index.ts +36 -0
- package/src/types/collection_editor_controller.tsx +53 -0
- package/src/types/collection_inference.ts +3 -0
- package/src/types/config_controller.tsx +60 -0
- package/src/types/config_permissions.ts +20 -0
- package/src/types/persisted_collection.ts +9 -0
- package/src/ui/CollectionViewHeaderAction.tsx +48 -0
- package/src/ui/EditorCollectionAction.tsx +56 -0
- package/src/ui/EditorCollectionActionStart.tsx +88 -0
- package/src/ui/HomePageEditorCollectionAction.tsx +89 -0
- package/src/ui/MissingReferenceWidget.tsx +37 -0
- package/src/ui/NewCollectionButton.tsx +18 -0
- package/src/ui/NewCollectionCard.tsx +48 -0
- package/src/ui/PropertyAddColumnComponent.tsx +47 -0
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +426 -0
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +826 -0
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +214 -0
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +513 -0
- package/src/ui/collection_editor/CollectionYupValidation.tsx +7 -0
- package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +37 -0
- package/src/ui/collection_editor/EnumForm.tsx +357 -0
- package/src/ui/collection_editor/GetCodeDialog.tsx +122 -0
- package/src/ui/collection_editor/PropertyEditView.tsx +789 -0
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +204 -0
- package/src/ui/collection_editor/PropertyTree.tsx +254 -0
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +269 -0
- package/src/ui/collection_editor/SwitchControl.tsx +39 -0
- package/src/ui/collection_editor/UnsavedChangesDialog.tsx +47 -0
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +53 -0
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +299 -0
- package/src/ui/collection_editor/import/clean_import_data.ts +53 -0
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +144 -0
- package/src/ui/collection_editor/properties/BooleanPropertyField.tsx +40 -0
- package/src/ui/collection_editor/properties/CommonPropertyFields.tsx +110 -0
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +89 -0
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +114 -0
- package/src/ui/collection_editor/properties/KeyValuePropertyField.tsx +20 -0
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +150 -0
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +139 -0
- package/src/ui/collection_editor/properties/NumberPropertyField.tsx +38 -0
- package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +160 -0
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +108 -0
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +215 -0
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +70 -0
- package/src/ui/collection_editor/properties/UrlPropertyField.tsx +89 -0
- package/src/ui/collection_editor/properties/advanced/AdvancedPropertyValidation.tsx +45 -0
- package/src/ui/collection_editor/properties/validation/ArrayPropertyValidation.tsx +50 -0
- package/src/ui/collection_editor/properties/validation/GeneralPropertyValidation.tsx +61 -0
- package/src/ui/collection_editor/properties/validation/NumberPropertyValidation.tsx +115 -0
- package/src/ui/collection_editor/properties/validation/StringPropertyValidation.tsx +150 -0
- package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +28 -0
- package/src/ui/collection_editor/templates/blog_template.ts +115 -0
- package/src/ui/collection_editor/templates/pages_template.ts +183 -0
- package/src/ui/collection_editor/templates/products_template.ts +88 -0
- package/src/ui/collection_editor/templates/users_template.ts +42 -0
- package/src/ui/collection_editor/util.ts +28 -0
- package/src/ui/collection_editor/utils/strings.ts +9 -0
- package/src/ui/collection_editor/utils/supported_fields.tsx +29 -0
- package/src/ui/collection_editor/utils/update_property_for_widget.ts +271 -0
- package/src/ui/collection_editor/utils/useTraceUpdate.tsx +23 -0
- package/src/useCollectionEditorController.tsx +9 -0
- package/src/useCollectionEditorPlugin.tsx +164 -0
- package/src/useCollectionsConfigController.tsx +9 -0
- package/src/utils/arrays.ts +3 -0
- package/src/utils/collections.ts +30 -0
- package/src/utils/entities.ts +38 -0
- package/src/vite-env.d.ts +1 -0
- package/dist/components/collection_editor/PropertySelectItem.d.ts +0 -8
- package/dist/components/collection_editor/SelectIcons.d.ts +0 -6
- package/dist/components/collection_editor/import/CollectionEditorImportMapping.d.ts +0 -4
- package/dist/components/collection_editor/properties/FieldHelperView.d.ts +0 -4
- package/dist/components/collection_editor/templates/blog_template.d.ts +0 -10
- package/dist/components/collection_editor/templates/products_template.d.ts +0 -12
- package/dist/components/collection_editor/templates/users_template.d.ts +0 -7
- package/dist/components/collection_editor/utils/supported_fields.d.ts +0 -3
- package/dist/components/collection_editor/utils/update_property_for_widget.d.ts +0 -3
- package/dist/types/editable_properties.d.ts +0 -10
- package/dist/utils/icons.d.ts +0 -2
- package/dist/utils/synonyms.d.ts +0 -1951
- /package/dist/{components → ui}/HomePageEditorCollectionAction.d.ts +0 -0
- /package/dist/{components → ui}/NewCollectionCard.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/UnsavedChangesDialog.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/BooleanPropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/DateTimePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/EnumPropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/KeyValuePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/NumberPropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/ReferencePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/StoragePropertyField.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/advanced/AdvancedPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/ArrayPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/GeneralPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/NumberPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/StringPropertyValidation.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/properties/validation/ValidationPanel.d.ts +0 -0
- /package/dist/{components → ui}/collection_editor/utils/useTraceUpdate.d.ts +0 -0
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { EntityCollection, FieldCaption, IconForView, SearchIconsView, singular, toSnakeCase, } from "@firecms/core";
|
|
3
|
+
import {
|
|
4
|
+
Autocomplete,
|
|
5
|
+
AutocompleteItem,
|
|
6
|
+
BooleanSwitchWithLabel,
|
|
7
|
+
Chip,
|
|
8
|
+
ClearIcon,
|
|
9
|
+
cls,
|
|
10
|
+
Container,
|
|
11
|
+
DebouncedTextField,
|
|
12
|
+
Dialog,
|
|
13
|
+
ExpandablePanel,
|
|
14
|
+
IconButton,
|
|
15
|
+
Select,
|
|
16
|
+
SelectItem,
|
|
17
|
+
SettingsIcon,
|
|
18
|
+
TextField,
|
|
19
|
+
Tooltip,
|
|
20
|
+
Typography,
|
|
21
|
+
useAutoComplete
|
|
22
|
+
} from "@firecms/ui";
|
|
23
|
+
|
|
24
|
+
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
25
|
+
import { useCollectionEditorController } from "../../useCollectionEditorController";
|
|
26
|
+
|
|
27
|
+
export function CollectionDetailsForm({
|
|
28
|
+
isNewCollection,
|
|
29
|
+
reservedGroups,
|
|
30
|
+
existingPaths,
|
|
31
|
+
existingIds,
|
|
32
|
+
groups,
|
|
33
|
+
parentCollection
|
|
34
|
+
}: {
|
|
35
|
+
isNewCollection: boolean,
|
|
36
|
+
reservedGroups?: string[];
|
|
37
|
+
existingPaths?: string[];
|
|
38
|
+
existingIds?: string[];
|
|
39
|
+
groups: string[] | null;
|
|
40
|
+
parentCollection?: EntityCollection;
|
|
41
|
+
parentCollectionIds?: string[];
|
|
42
|
+
}) {
|
|
43
|
+
|
|
44
|
+
const groupRef = React.useRef<HTMLInputElement>(null);
|
|
45
|
+
const {
|
|
46
|
+
values,
|
|
47
|
+
setFieldValue,
|
|
48
|
+
handleChange,
|
|
49
|
+
touched,
|
|
50
|
+
errors,
|
|
51
|
+
setFieldTouched,
|
|
52
|
+
isSubmitting,
|
|
53
|
+
submitCount
|
|
54
|
+
} = useFormex<EntityCollection>();
|
|
55
|
+
|
|
56
|
+
const collectionEditor = useCollectionEditorController();
|
|
57
|
+
|
|
58
|
+
const [iconDialogOpen, setIconDialogOpen] = useState(false);
|
|
59
|
+
const [advancedPanelExpanded, setAdvancedPanelExpanded] = useState(false);
|
|
60
|
+
|
|
61
|
+
const updateDatabaseId = (databaseId: string) => {
|
|
62
|
+
setFieldValue("databaseId", databaseId ?? undefined);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const updateName = (name: string) => {
|
|
66
|
+
setFieldValue("name", name);
|
|
67
|
+
|
|
68
|
+
const pathTouched = getIn(touched, "path");
|
|
69
|
+
if (!pathTouched && isNewCollection && name) {
|
|
70
|
+
setFieldValue("path", toSnakeCase(name));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const idTouched = getIn(touched, "id");
|
|
74
|
+
if (!idTouched && isNewCollection && name) {
|
|
75
|
+
setFieldValue("id", toSnakeCase(name));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const singularNameTouched = getIn(touched, "singularName");
|
|
79
|
+
if (!singularNameTouched && isNewCollection && name) {
|
|
80
|
+
setFieldValue("singularName", singular(name));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (errors.id) {
|
|
87
|
+
setAdvancedPanelExpanded(true);
|
|
88
|
+
}
|
|
89
|
+
}, [errors.id]);
|
|
90
|
+
|
|
91
|
+
const DatabaseField = collectionEditor.components?.DatabaseField ?? DefaultDatabaseField;
|
|
92
|
+
|
|
93
|
+
const collectionIcon = <IconForView collectionOrView={values}/>;
|
|
94
|
+
|
|
95
|
+
const groupOptions = groups?.filter((group) => !reservedGroups?.includes(group));
|
|
96
|
+
|
|
97
|
+
const {
|
|
98
|
+
inputFocused,
|
|
99
|
+
autoCompleteOpen,
|
|
100
|
+
setAutoCompleteOpen
|
|
101
|
+
} = useAutoComplete({
|
|
102
|
+
ref: groupRef
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const isSubcollection = !!parentCollection;
|
|
106
|
+
|
|
107
|
+
let customIdValue: "true" | "false" | "optional" | "code_defined" | undefined;
|
|
108
|
+
if (typeof values.customId === "object") {
|
|
109
|
+
customIdValue = "code_defined";
|
|
110
|
+
} else if (values.customId === true) {
|
|
111
|
+
customIdValue = "true";
|
|
112
|
+
} else if (values.customId === false) {
|
|
113
|
+
customIdValue = "false";
|
|
114
|
+
} else if (values.customId === "optional") {
|
|
115
|
+
customIdValue = "optional";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const showErrors = submitCount > 0;
|
|
119
|
+
return (
|
|
120
|
+
<div className={"overflow-auto my-auto"}>
|
|
121
|
+
<Container maxWidth={"4xl"} className={"flex flex-col gap-4 p-8 m-auto"}>
|
|
122
|
+
|
|
123
|
+
<div>
|
|
124
|
+
<div
|
|
125
|
+
className="flex flex-row gap-2 py-2 pt-3 items-center">
|
|
126
|
+
<Typography variant={!isNewCollection ? "h5" : "h4"} className={"flex-grow"}>
|
|
127
|
+
{isNewCollection ? "New collection" : `${values?.name} collection`}
|
|
128
|
+
</Typography>
|
|
129
|
+
<DatabaseField databaseId={values.databaseId}
|
|
130
|
+
onDatabaseIdUpdate={updateDatabaseId}/>
|
|
131
|
+
|
|
132
|
+
<Tooltip title={"Change icon"}
|
|
133
|
+
asChild={true}>
|
|
134
|
+
<IconButton
|
|
135
|
+
shape={"square"}
|
|
136
|
+
onClick={() => setIconDialogOpen(true)}>
|
|
137
|
+
{collectionIcon}
|
|
138
|
+
</IconButton>
|
|
139
|
+
</Tooltip>
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
{parentCollection && <Chip colorScheme={"tealDarker"}>
|
|
143
|
+
<Typography variant={"caption"}>
|
|
144
|
+
This is a subcollection of <b>{parentCollection.name}</b>
|
|
145
|
+
</Typography>
|
|
146
|
+
</Chip>}
|
|
147
|
+
|
|
148
|
+
</div>
|
|
149
|
+
<div className={"grid grid-cols-12 gap-4"}>
|
|
150
|
+
|
|
151
|
+
<div className={"col-span-12"}>
|
|
152
|
+
<TextField
|
|
153
|
+
value={values.name ?? ""}
|
|
154
|
+
onChange={(e: any) => updateName(e.target.value)}
|
|
155
|
+
label={"Name"}
|
|
156
|
+
autoFocus={true}
|
|
157
|
+
required
|
|
158
|
+
error={showErrors && Boolean(errors.name)}/>
|
|
159
|
+
<FieldCaption error={touched.name && Boolean(errors.name)}>
|
|
160
|
+
{touched.name && Boolean(errors.name) ? errors.name : "Name of this collection, usually a plural name (e.g. Products)"}
|
|
161
|
+
</FieldCaption>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div className={cls("col-span-12 ", isSubcollection ? "" : "sm:col-span-8")}>
|
|
165
|
+
<Field name={"path"}
|
|
166
|
+
as={DebouncedTextField}
|
|
167
|
+
label={"Path"}
|
|
168
|
+
disabled={!isNewCollection}
|
|
169
|
+
required
|
|
170
|
+
error={showErrors && Boolean(errors.path)}/>
|
|
171
|
+
|
|
172
|
+
<FieldCaption error={touched.path && Boolean(errors.path)}>
|
|
173
|
+
{touched.path && Boolean(errors.path)
|
|
174
|
+
? errors.path
|
|
175
|
+
: isSubcollection ? "Relative path to the parent (no need to include the parent path)" : "Path that this collection is stored in, in the database"}
|
|
176
|
+
</FieldCaption>
|
|
177
|
+
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
{!isSubcollection && <div className={"col-span-12 sm:col-span-4 relative"}>
|
|
181
|
+
|
|
182
|
+
<TextField error={showErrors && Boolean(errors.group)}
|
|
183
|
+
disabled={isSubmitting}
|
|
184
|
+
value={values.group ?? ""}
|
|
185
|
+
autoComplete="off"
|
|
186
|
+
onChange={(event) => setFieldValue("group", event.target.value)}
|
|
187
|
+
name={"group"}
|
|
188
|
+
inputRef={groupRef}
|
|
189
|
+
label="Group"/>
|
|
190
|
+
<Autocomplete
|
|
191
|
+
open={autoCompleteOpen && (groupOptions ?? []).length > 0}
|
|
192
|
+
setOpen={setAutoCompleteOpen}>
|
|
193
|
+
{groupOptions?.map((group, index) => {
|
|
194
|
+
return <AutocompleteItem
|
|
195
|
+
key={index + "_" + group}
|
|
196
|
+
onClick={() => {
|
|
197
|
+
setAutoCompleteOpen(false);
|
|
198
|
+
setFieldValue("group", group ?? null);
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
201
|
+
<div className={"flex-grow"}>
|
|
202
|
+
{group}
|
|
203
|
+
</div>
|
|
204
|
+
</AutocompleteItem>;
|
|
205
|
+
})}
|
|
206
|
+
</Autocomplete>
|
|
207
|
+
<FieldCaption>
|
|
208
|
+
{showErrors && Boolean(errors.group) ? errors.group : "Group in the home page"}
|
|
209
|
+
</FieldCaption>
|
|
210
|
+
</div>}
|
|
211
|
+
|
|
212
|
+
<div className={"col-span-12"}>
|
|
213
|
+
<ExpandablePanel
|
|
214
|
+
expanded={advancedPanelExpanded}
|
|
215
|
+
onExpandedChange={setAdvancedPanelExpanded}
|
|
216
|
+
title={
|
|
217
|
+
<div className="flex flex-row text-gray-500">
|
|
218
|
+
<SettingsIcon/>
|
|
219
|
+
<Typography variant={"subtitle2"}
|
|
220
|
+
className="ml-2">
|
|
221
|
+
Advanced
|
|
222
|
+
</Typography>
|
|
223
|
+
</div>}
|
|
224
|
+
initiallyExpanded={false}>
|
|
225
|
+
<div className={"grid grid-cols-12 gap-4 p-4"}>
|
|
226
|
+
|
|
227
|
+
<div className={"col-span-12"}>
|
|
228
|
+
<Field name={"id"}
|
|
229
|
+
as={DebouncedTextField}
|
|
230
|
+
disabled={!isNewCollection}
|
|
231
|
+
label={"Collection id"}
|
|
232
|
+
error={showErrors && Boolean(errors.id)}/>
|
|
233
|
+
<FieldCaption error={touched.id && Boolean(errors.id)}>
|
|
234
|
+
{touched.id && Boolean(errors.id) ? errors.id : "This id identifies this collection. Typically the same as the path."}
|
|
235
|
+
</FieldCaption>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<div className={"col-span-12"}>
|
|
239
|
+
<TextField
|
|
240
|
+
error={showErrors && Boolean(errors.singularName)}
|
|
241
|
+
name={"singularName"}
|
|
242
|
+
aria-describedby={"singularName-helper"}
|
|
243
|
+
onChange={(e) => {
|
|
244
|
+
setFieldTouched("singularName", true);
|
|
245
|
+
return handleChange(e);
|
|
246
|
+
}}
|
|
247
|
+
value={values.singularName ?? ""}
|
|
248
|
+
label={"Singular name"}/>
|
|
249
|
+
<FieldCaption error={showErrors && Boolean(errors.singularName)}>
|
|
250
|
+
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define a singular name for your entities"}
|
|
251
|
+
</FieldCaption>
|
|
252
|
+
</div>
|
|
253
|
+
<div className={"col-span-12"}>
|
|
254
|
+
<TextField
|
|
255
|
+
error={showErrors && Boolean(errors.sideDialogWidth)}
|
|
256
|
+
name={"sideDialogWidth"}
|
|
257
|
+
type={"number"}
|
|
258
|
+
aria-describedby={"sideDialogWidth-helper"}
|
|
259
|
+
onChange={(e) => {
|
|
260
|
+
setFieldTouched("sideDialogWidth", true);
|
|
261
|
+
const value = e.target.value;
|
|
262
|
+
if (!value) {
|
|
263
|
+
setFieldValue("sideDialogWidth", null);
|
|
264
|
+
} else if (!isNaN(Number(value))) {
|
|
265
|
+
setFieldValue("sideDialogWidth", Number(value));
|
|
266
|
+
}
|
|
267
|
+
}}
|
|
268
|
+
endAdornment={<IconButton
|
|
269
|
+
size={"small"}
|
|
270
|
+
onClick={() => {
|
|
271
|
+
setFieldValue("sideDialogWidth", null);
|
|
272
|
+
}}
|
|
273
|
+
disabled={!values.sideDialogWidth}>
|
|
274
|
+
<ClearIcon size={"small"}/>
|
|
275
|
+
</IconButton>}
|
|
276
|
+
value={values.sideDialogWidth ?? ""}
|
|
277
|
+
label={"Side dialog width"}/>
|
|
278
|
+
<FieldCaption error={showErrors && Boolean(errors.singularName)}>
|
|
279
|
+
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define the width (in pixels) of entities side dialog. Default is 768px"}
|
|
280
|
+
</FieldCaption>
|
|
281
|
+
</div>
|
|
282
|
+
<div className={"col-span-12"}>
|
|
283
|
+
<TextField
|
|
284
|
+
error={showErrors && Boolean(errors.description)}
|
|
285
|
+
name="description"
|
|
286
|
+
value={values.description ?? ""}
|
|
287
|
+
onChange={handleChange}
|
|
288
|
+
multiline
|
|
289
|
+
rows={2}
|
|
290
|
+
aria-describedby="description-helper-text"
|
|
291
|
+
label="Description"
|
|
292
|
+
/>
|
|
293
|
+
<FieldCaption error={showErrors && Boolean(errors.description)}>
|
|
294
|
+
{showErrors && Boolean(errors.description) ? errors.description : "Description of the collection, you can use markdown"}
|
|
295
|
+
</FieldCaption>
|
|
296
|
+
</div>
|
|
297
|
+
|
|
298
|
+
<div className={"col-span-12"}>
|
|
299
|
+
<Select
|
|
300
|
+
name="defaultSize"
|
|
301
|
+
label="Default row size"
|
|
302
|
+
position={"item-aligned"}
|
|
303
|
+
onChange={handleChange}
|
|
304
|
+
value={values.defaultSize ?? ""}
|
|
305
|
+
renderValue={(value: any) => value.toUpperCase()}
|
|
306
|
+
>
|
|
307
|
+
{["xs", "s", "m", "l", "xl"].map((value) => (
|
|
308
|
+
<SelectItem
|
|
309
|
+
key={`size-select-${value}`}
|
|
310
|
+
value={value}>
|
|
311
|
+
{value.toUpperCase()}
|
|
312
|
+
</SelectItem>
|
|
313
|
+
))}
|
|
314
|
+
</Select>
|
|
315
|
+
</div>
|
|
316
|
+
<div className={"col-span-12"}>
|
|
317
|
+
<Select
|
|
318
|
+
name="customId"
|
|
319
|
+
label="Document IDs generation"
|
|
320
|
+
position={"item-aligned"}
|
|
321
|
+
disabled={customIdValue === "code_defined"}
|
|
322
|
+
onValueChange={(v) => {
|
|
323
|
+
if (v === "code_defined")
|
|
324
|
+
throw new Error("This should not happen");
|
|
325
|
+
else if (v === "true")
|
|
326
|
+
setFieldValue("customId", true);
|
|
327
|
+
else if (v === "false")
|
|
328
|
+
setFieldValue("customId", false);
|
|
329
|
+
else if (v === "optional")
|
|
330
|
+
setFieldValue("customId", "optional");
|
|
331
|
+
}}
|
|
332
|
+
value={customIdValue ?? ""}
|
|
333
|
+
renderValue={(value: any) => {
|
|
334
|
+
if (value === "code_defined")
|
|
335
|
+
return "Code defined";
|
|
336
|
+
else if (value === "true")
|
|
337
|
+
return "Users must define an ID";
|
|
338
|
+
else if (value === "optional")
|
|
339
|
+
return "Users can define an ID, but it is not required";
|
|
340
|
+
else
|
|
341
|
+
return "Document ID is generated automatically";
|
|
342
|
+
}}
|
|
343
|
+
>
|
|
344
|
+
<SelectItem value={"false"}>
|
|
345
|
+
Document ID is generated automatically
|
|
346
|
+
</SelectItem>
|
|
347
|
+
<SelectItem value={"true"}>
|
|
348
|
+
Users must define an ID
|
|
349
|
+
</SelectItem>
|
|
350
|
+
<SelectItem value={"optional"}>
|
|
351
|
+
Users can define an ID, but it is not required
|
|
352
|
+
</SelectItem>
|
|
353
|
+
</Select>
|
|
354
|
+
</div>
|
|
355
|
+
<div className={"col-span-12"}>
|
|
356
|
+
<BooleanSwitchWithLabel
|
|
357
|
+
position={"start"}
|
|
358
|
+
label="Collection group"
|
|
359
|
+
onValueChange={(v) => setFieldValue("collectionGroup", v)}
|
|
360
|
+
value={values.collectionGroup ?? false}
|
|
361
|
+
/>
|
|
362
|
+
<FieldCaption>
|
|
363
|
+
A collection group consists of all collections with the same path. This allows
|
|
364
|
+
you
|
|
365
|
+
to query over multiple collections at once.
|
|
366
|
+
</FieldCaption>
|
|
367
|
+
</div>
|
|
368
|
+
<div className={"col-span-12"}>
|
|
369
|
+
<BooleanSwitchWithLabel
|
|
370
|
+
position={"start"}
|
|
371
|
+
label="Enable text search for this collection"
|
|
372
|
+
onValueChange={(v) => setFieldValue("textSearchEnabled", v)}
|
|
373
|
+
value={values.textSearchEnabled ?? false}
|
|
374
|
+
/>
|
|
375
|
+
<FieldCaption>
|
|
376
|
+
Allow text search for this collection. If you have not specified a text search
|
|
377
|
+
delegate, this will use the built-in local text search. This is not recommended
|
|
378
|
+
for large collections, as it may incur in performance and cost issues.
|
|
379
|
+
</FieldCaption>
|
|
380
|
+
</div>
|
|
381
|
+
</div>
|
|
382
|
+
</ExpandablePanel>
|
|
383
|
+
|
|
384
|
+
</div>
|
|
385
|
+
|
|
386
|
+
</div>
|
|
387
|
+
|
|
388
|
+
<div style={{ height: "52px" }}/>
|
|
389
|
+
|
|
390
|
+
<Dialog
|
|
391
|
+
open={iconDialogOpen}
|
|
392
|
+
onOpenChange={setIconDialogOpen}
|
|
393
|
+
maxWidth={"xl"}
|
|
394
|
+
fullWidth
|
|
395
|
+
>
|
|
396
|
+
<div className={"p-4 overflow-auto min-h-[200px]"}>
|
|
397
|
+
<SearchIconsView selectedIcon={values.icon}
|
|
398
|
+
onIconSelected={(icon: string) => {
|
|
399
|
+
setIconDialogOpen(false);
|
|
400
|
+
setFieldValue("icon", icon);
|
|
401
|
+
}}/>
|
|
402
|
+
</div>
|
|
403
|
+
|
|
404
|
+
</Dialog>
|
|
405
|
+
|
|
406
|
+
</Container>
|
|
407
|
+
</div>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function DefaultDatabaseField({
|
|
412
|
+
databaseId,
|
|
413
|
+
onDatabaseIdUpdate
|
|
414
|
+
}: { databaseId?: string, onDatabaseIdUpdate: (databaseId: string) => void }) {
|
|
415
|
+
|
|
416
|
+
return <Tooltip title={"Database ID"}
|
|
417
|
+
side={"top"}
|
|
418
|
+
align={"start"}>
|
|
419
|
+
<TextField size={"smallest"}
|
|
420
|
+
invisible={true}
|
|
421
|
+
inputClassName={"text-end"}
|
|
422
|
+
value={databaseId ?? ""}
|
|
423
|
+
onChange={(e: any) => onDatabaseIdUpdate(e.target.value)}
|
|
424
|
+
placeholder={"(default)"}></TextField>
|
|
425
|
+
</Tooltip>
|
|
426
|
+
}
|