@firecms/collection_editor 3.0.0-canary.12 → 3.0.0-canary.121
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 +11 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +4675 -3456
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6680 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +14 -2
- package/dist/ui/CollectionViewHeaderAction.d.ts +3 -2
- package/dist/ui/EditorCollectionActionStart.d.ts +2 -0
- package/dist/ui/PropertyAddColumnComponent.d.ts +3 -1
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +4 -3
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +1 -1
- package/dist/ui/collection_editor/CollectionPropertiesEditorForm.d.ts +1 -1
- package/dist/ui/collection_editor/PropertyTree.d.ts +9 -9
- package/dist/ui/collection_editor/SubcollectionsEditTab.d.ts +1 -1
- package/dist/ui/collection_editor/properties/MarkdownPropertyField.d.ts +4 -0
- package/dist/ui/collection_editor/properties/StringPropertyField.d.ts +1 -1
- package/dist/useCollectionEditorPlugin.d.ts +15 -9
- package/dist/utils/collections.d.ts +6 -0
- package/package.json +20 -34
- package/src/ConfigControllerProvider.tsx +75 -63
- package/src/index.ts +1 -0
- package/src/types/collection_editor_controller.tsx +14 -4
- package/src/ui/CollectionViewHeaderAction.tsx +9 -4
- package/src/ui/EditorCollectionAction.tsx +10 -63
- package/src/ui/EditorCollectionActionStart.tsx +88 -0
- package/src/ui/HomePageEditorCollectionAction.tsx +16 -11
- package/src/ui/NewCollectionButton.tsx +12 -10
- package/src/ui/NewCollectionCard.tsx +3 -3
- package/src/ui/PropertyAddColumnComponent.tsx +9 -4
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +67 -7
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +56 -31
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +6 -5
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +33 -27
- package/src/ui/collection_editor/GetCodeDialog.tsx +15 -3
- package/src/ui/collection_editor/PropertyEditView.tsx +15 -7
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +3 -6
- package/src/ui/collection_editor/PropertySelectItem.tsx +3 -3
- package/src/ui/collection_editor/PropertyTree.tsx +7 -5
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +6 -4
- package/src/ui/collection_editor/import/CollectionEditorImportDataPreview.tsx +25 -9
- package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +9 -7
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +14 -8
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +5 -5
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +139 -0
- package/src/ui/collection_editor/properties/RepeatPropertyField.tsx +0 -1
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +31 -16
- package/src/ui/collection_editor/properties/StringPropertyField.tsx +1 -10
- package/src/useCollectionEditorPlugin.tsx +37 -27
- package/src/utils/collections.ts +30 -0
- package/dist/ui/RootCollectionSuggestions.d.ts +0 -3
- package/src/ui/RootCollectionSuggestions.tsx +0 -63
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
CollectionActionsProps,
|
|
5
|
-
mergeDeep,
|
|
6
|
-
useAuthController,
|
|
7
|
-
useNavigationController,
|
|
8
|
-
useSnackbarController
|
|
9
|
-
} from "@firecms/core";
|
|
10
|
-
import { Button, IconButton, SaveIcon, SettingsIcon, Tooltip, UndoIcon, } from "@firecms/ui";
|
|
1
|
+
import { CollectionActionsProps, useAuthController, useNavigationController } from "@firecms/core";
|
|
2
|
+
import { IconButton, SettingsIcon, Tooltip, } from "@firecms/ui";
|
|
11
3
|
|
|
12
4
|
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
13
|
-
import { useCollectionsConfigController } from "../useCollectionsConfigController";
|
|
14
5
|
import { PersistedCollection } from "../types/persisted_collection";
|
|
15
6
|
|
|
16
7
|
export function EditorCollectionAction({
|
|
@@ -23,8 +14,6 @@ export function EditorCollectionAction({
|
|
|
23
14
|
const authController = useAuthController();
|
|
24
15
|
const navigationController = useNavigationController();
|
|
25
16
|
const collectionEditorController = useCollectionEditorController();
|
|
26
|
-
const configController = useCollectionsConfigController();
|
|
27
|
-
const snackbarController = useSnackbarController();
|
|
28
17
|
|
|
29
18
|
const parentCollection = navigationController.getCollectionFromIds(parentCollectionIds);
|
|
30
19
|
|
|
@@ -35,68 +24,26 @@ export function EditorCollectionAction({
|
|
|
35
24
|
}).editCollections
|
|
36
25
|
: true;
|
|
37
26
|
|
|
38
|
-
let saveDefaultFilterButton = null;
|
|
39
|
-
if (!equal(getObjectOrNull(tableController.filterValues), getObjectOrNull(collection.initialFilter)) ||
|
|
40
|
-
!equal(getObjectOrNull(tableController.sortBy), getObjectOrNull(collection.initialSort))) {
|
|
41
|
-
saveDefaultFilterButton = <>
|
|
42
|
-
{(collection.initialFilter || collection.initialSort) && <Tooltip
|
|
43
|
-
title={"Reset to default filter and sort"}>
|
|
44
|
-
<Button
|
|
45
|
-
color={"primary"}
|
|
46
|
-
size={"small"}
|
|
47
|
-
variant={"text"}
|
|
48
|
-
onClick={() => {
|
|
49
|
-
tableController.clearFilter?.();
|
|
50
|
-
if (collection?.initialFilter)
|
|
51
|
-
tableController.setFilterValues?.(collection?.initialFilter);
|
|
52
|
-
if (collection?.initialSort)
|
|
53
|
-
tableController.setSortBy?.(collection?.initialSort);
|
|
54
|
-
}}>
|
|
55
|
-
<UndoIcon/>
|
|
56
|
-
</Button>
|
|
57
|
-
</Tooltip>}
|
|
58
|
-
|
|
59
|
-
<Tooltip
|
|
60
|
-
title={tableController.sortBy || tableController.filterValues ? "Save default filter and sort" : "Clear default filter and sort"}>
|
|
61
|
-
<Button
|
|
62
|
-
color={"primary"}
|
|
63
|
-
size={"small"}
|
|
64
|
-
variant={"outlined"}
|
|
65
|
-
onClick={() => configController
|
|
66
|
-
?.saveCollection({
|
|
67
|
-
id: collection.id,
|
|
68
|
-
parentCollectionIds,
|
|
69
|
-
collectionData: mergeDeep(collection as PersistedCollection,
|
|
70
|
-
{
|
|
71
|
-
initialFilter: tableController.filterValues ?? null,
|
|
72
|
-
initialSort: tableController.sortBy ?? null
|
|
73
|
-
})
|
|
74
|
-
}).then(() => {
|
|
75
|
-
snackbarController.open({
|
|
76
|
-
type: "success",
|
|
77
|
-
message: "Default config saved"
|
|
78
|
-
});
|
|
79
|
-
})}>
|
|
80
|
-
<SaveIcon/>
|
|
81
|
-
</Button>
|
|
82
|
-
</Tooltip>
|
|
83
|
-
</>;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
27
|
const editorButton = <Tooltip
|
|
28
|
+
asChild={true}
|
|
87
29
|
title={canEditCollection ? "Edit collection" : "You don't have permissions to edit this collection"}>
|
|
88
30
|
<IconButton
|
|
89
31
|
color={"primary"}
|
|
90
32
|
disabled={!canEditCollection}
|
|
91
33
|
onClick={canEditCollection
|
|
92
|
-
? () => collectionEditorController?.editCollection({
|
|
34
|
+
? () => collectionEditorController?.editCollection({
|
|
35
|
+
id: collection.id,
|
|
36
|
+
fullPath,
|
|
37
|
+
parentCollectionIds,
|
|
38
|
+
parentCollection: parentCollection as PersistedCollection,
|
|
39
|
+
existingEntities: tableController?.data ?? []
|
|
40
|
+
})
|
|
93
41
|
: undefined}>
|
|
94
42
|
<SettingsIcon/>
|
|
95
43
|
</IconButton>
|
|
96
44
|
</Tooltip>;
|
|
97
45
|
|
|
98
46
|
return <>
|
|
99
|
-
{canEditCollection && saveDefaultFilterButton}
|
|
100
47
|
{editorButton}
|
|
101
48
|
</>
|
|
102
49
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import equal from "react-fast-compare"
|
|
2
|
+
|
|
3
|
+
import { CollectionActionsProps, mergeDeep, useAuthController, useSnackbarController } from "@firecms/core";
|
|
4
|
+
import { Button, SaveIcon, Tooltip, UndoIcon, } from "@firecms/ui";
|
|
5
|
+
|
|
6
|
+
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
7
|
+
import { useCollectionsConfigController } from "../useCollectionsConfigController";
|
|
8
|
+
import { PersistedCollection } from "../types/persisted_collection";
|
|
9
|
+
|
|
10
|
+
export function EditorCollectionActionStart({
|
|
11
|
+
path: fullPath,
|
|
12
|
+
parentCollectionIds,
|
|
13
|
+
collection,
|
|
14
|
+
tableController
|
|
15
|
+
}: CollectionActionsProps) {
|
|
16
|
+
|
|
17
|
+
const authController = useAuthController();
|
|
18
|
+
const collectionEditorController = useCollectionEditorController();
|
|
19
|
+
const configController = useCollectionsConfigController();
|
|
20
|
+
const snackbarController = useSnackbarController();
|
|
21
|
+
|
|
22
|
+
const canEditCollection = collectionEditorController.configPermissions
|
|
23
|
+
? collectionEditorController.configPermissions({
|
|
24
|
+
user: authController.user,
|
|
25
|
+
collection
|
|
26
|
+
}).editCollections
|
|
27
|
+
: true;
|
|
28
|
+
|
|
29
|
+
let saveDefaultFilterButton = null;
|
|
30
|
+
if (!equal(getObjectOrNull(tableController.filterValues), getObjectOrNull(collection.initialFilter)) ||
|
|
31
|
+
!equal(getObjectOrNull(tableController.sortBy), getObjectOrNull(collection.initialSort))) {
|
|
32
|
+
saveDefaultFilterButton = <>
|
|
33
|
+
<Tooltip
|
|
34
|
+
asChild={true}
|
|
35
|
+
title={tableController.sortBy || tableController.filterValues ? "Save default filter and sort" : "Clear default filter and sort"}>
|
|
36
|
+
<Button
|
|
37
|
+
color={"primary"}
|
|
38
|
+
size={"small"}
|
|
39
|
+
variant={"outlined"}
|
|
40
|
+
onClick={() => configController
|
|
41
|
+
?.saveCollection({
|
|
42
|
+
id: collection.id,
|
|
43
|
+
parentCollectionIds,
|
|
44
|
+
collectionData: mergeDeep(collection as PersistedCollection,
|
|
45
|
+
{
|
|
46
|
+
initialFilter: tableController.filterValues ?? null,
|
|
47
|
+
initialSort: tableController.sortBy ?? null
|
|
48
|
+
})
|
|
49
|
+
}).then(() => {
|
|
50
|
+
snackbarController.open({
|
|
51
|
+
type: "success",
|
|
52
|
+
message: "Default config saved"
|
|
53
|
+
});
|
|
54
|
+
})}>
|
|
55
|
+
<SaveIcon/>
|
|
56
|
+
</Button>
|
|
57
|
+
</Tooltip>
|
|
58
|
+
|
|
59
|
+
{(collection.initialFilter || collection.initialSort) && <Tooltip
|
|
60
|
+
title={"Reset to default filter and sort"}>
|
|
61
|
+
<Button
|
|
62
|
+
color={"primary"}
|
|
63
|
+
size={"small"}
|
|
64
|
+
variant={"text"}
|
|
65
|
+
onClick={() => {
|
|
66
|
+
tableController.clearFilter?.();
|
|
67
|
+
if (collection?.initialFilter)
|
|
68
|
+
tableController.setFilterValues?.(collection?.initialFilter);
|
|
69
|
+
if (collection?.initialSort)
|
|
70
|
+
tableController.setSortBy?.(collection?.initialSort);
|
|
71
|
+
}}>
|
|
72
|
+
<UndoIcon/>
|
|
73
|
+
</Button>
|
|
74
|
+
</Tooltip>}
|
|
75
|
+
</>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return <>
|
|
79
|
+
{canEditCollection && saveDefaultFilterButton}
|
|
80
|
+
</>
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function getObjectOrNull(o?: object): object | null {
|
|
85
|
+
if (o && Object.keys(o).length === 0)
|
|
86
|
+
return o
|
|
87
|
+
return o ?? null;
|
|
88
|
+
}
|
|
@@ -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,16 @@ export function HomePageEditorCollectionAction({
|
|
|
24
24
|
collection
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
const onEditCollectionClicked =
|
|
28
|
-
collectionEditorController?.editCollection({
|
|
29
|
-
|
|
27
|
+
const onEditCollectionClicked = () => {
|
|
28
|
+
collectionEditorController?.editCollection({
|
|
29
|
+
id: collection.id,
|
|
30
|
+
parentCollectionIds: []
|
|
31
|
+
});
|
|
32
|
+
};
|
|
30
33
|
|
|
31
34
|
const [deleteRequested, setDeleteRequested] = useState(false);
|
|
32
35
|
|
|
33
|
-
const deleteCollection =
|
|
36
|
+
const deleteCollection = () => {
|
|
34
37
|
configController?.deleteCollection({ id: collection.id }).then(() => {
|
|
35
38
|
setDeleteRequested(false);
|
|
36
39
|
snackbarController.open({
|
|
@@ -38,7 +41,7 @@ export function HomePageEditorCollectionAction({
|
|
|
38
41
|
type: "success"
|
|
39
42
|
});
|
|
40
43
|
});
|
|
41
|
-
}
|
|
44
|
+
};
|
|
42
45
|
|
|
43
46
|
return <>
|
|
44
47
|
|
|
@@ -49,11 +52,13 @@ export function HomePageEditorCollectionAction({
|
|
|
49
52
|
<MoreVertIcon size={"small"}/>
|
|
50
53
|
</IconButton>}
|
|
51
54
|
>
|
|
52
|
-
<MenuItem
|
|
53
|
-
|
|
54
|
-
event
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
<MenuItem
|
|
56
|
+
dense={true}
|
|
57
|
+
onClick={(event) => {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
setDeleteRequested(true);
|
|
61
|
+
}}>
|
|
57
62
|
<DeleteIcon/>
|
|
58
63
|
Delete
|
|
59
64
|
</MenuItem>
|
|
@@ -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 { 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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDefaultPropertiesOrder, useAuthController } from "@firecms/core";
|
|
1
|
+
import { EntityTableController, getDefaultPropertiesOrder, useAuthController } from "@firecms/core";
|
|
2
2
|
import { AddIcon, Tooltip } from "@firecms/ui";
|
|
3
3
|
import { useCollectionEditorController } from "../useCollectionEditorController";
|
|
4
4
|
import { PersistedCollection } from "../types/persisted_collection";
|
|
@@ -6,11 +6,13 @@ import { PersistedCollection } from "../types/persisted_collection";
|
|
|
6
6
|
export function PropertyAddColumnComponent({
|
|
7
7
|
fullPath,
|
|
8
8
|
parentCollectionIds,
|
|
9
|
-
collection
|
|
9
|
+
collection,
|
|
10
|
+
tableController
|
|
10
11
|
}: {
|
|
11
12
|
fullPath: string,
|
|
12
13
|
parentCollectionIds: string[],
|
|
13
14
|
collection: PersistedCollection;
|
|
15
|
+
tableController: EntityTableController;
|
|
14
16
|
}) {
|
|
15
17
|
|
|
16
18
|
const authController = useAuthController();
|
|
@@ -23,7 +25,9 @@ export function PropertyAddColumnComponent({
|
|
|
23
25
|
: true;
|
|
24
26
|
|
|
25
27
|
return (
|
|
26
|
-
<Tooltip
|
|
28
|
+
<Tooltip
|
|
29
|
+
asChild={true}
|
|
30
|
+
title={canEditCollection ? "Add new property" : "You don't have permission to add new properties"}>
|
|
27
31
|
<div
|
|
28
32
|
className={"p-0.5 w-20 h-full flex items-center justify-center cursor-pointer bg-gray-100 bg-opacity-40 hover:bg-gray-100 dark:bg-gray-950 dark:bg-opacity-40 dark:hover:bg-gray-950"}
|
|
29
33
|
// className={onHover ? "bg-white dark:bg-gray-950" : undefined}
|
|
@@ -32,7 +36,8 @@ export function PropertyAddColumnComponent({
|
|
|
32
36
|
editedCollectionId: collection.id,
|
|
33
37
|
parentCollectionIds,
|
|
34
38
|
currentPropertiesOrder: getDefaultPropertiesOrder(collection),
|
|
35
|
-
collection
|
|
39
|
+
collection,
|
|
40
|
+
existingEntities: tableController.data
|
|
36
41
|
});
|
|
37
42
|
}}>
|
|
38
43
|
<AddIcon color={"inherit"}/>
|
|
@@ -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,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
} from "@firecms/ui";
|
|
22
23
|
|
|
23
24
|
import { Field, getIn, useFormex } from "@firecms/formex";
|
|
25
|
+
import { useCollectionEditorController } from "../../useCollectionEditorController";
|
|
24
26
|
|
|
25
27
|
export function CollectionDetailsForm({
|
|
26
28
|
isNewCollection,
|
|
@@ -51,9 +53,15 @@ export function CollectionDetailsForm({
|
|
|
51
53
|
submitCount
|
|
52
54
|
} = useFormex<EntityCollection>();
|
|
53
55
|
|
|
56
|
+
const collectionEditor = useCollectionEditorController();
|
|
57
|
+
|
|
54
58
|
const [iconDialogOpen, setIconDialogOpen] = useState(false);
|
|
55
59
|
const [advancedPanelExpanded, setAdvancedPanelExpanded] = useState(false);
|
|
56
60
|
|
|
61
|
+
const updateDatabaseId = (databaseId: string) => {
|
|
62
|
+
setFieldValue("databaseId", databaseId ?? undefined);
|
|
63
|
+
}
|
|
64
|
+
|
|
57
65
|
const updateName = (name: string) => {
|
|
58
66
|
setFieldValue("name", name);
|
|
59
67
|
|
|
@@ -80,6 +88,8 @@ export function CollectionDetailsForm({
|
|
|
80
88
|
}
|
|
81
89
|
}, [errors.id]);
|
|
82
90
|
|
|
91
|
+
const DatabaseField = collectionEditor.components?.DatabaseField ?? DefaultDatabaseField;
|
|
92
|
+
|
|
83
93
|
const collectionIcon = <IconForView collectionOrView={values}/>;
|
|
84
94
|
|
|
85
95
|
const groupOptions = groups?.filter((group) => !reservedGroups?.includes(group));
|
|
@@ -112,11 +122,15 @@ export function CollectionDetailsForm({
|
|
|
112
122
|
|
|
113
123
|
<div>
|
|
114
124
|
<div
|
|
115
|
-
className="flex flex-row py-2 pt-3 items-center">
|
|
125
|
+
className="flex flex-row gap-2 py-2 pt-3 items-center">
|
|
116
126
|
<Typography variant={!isNewCollection ? "h5" : "h4"} className={"flex-grow"}>
|
|
117
127
|
{isNewCollection ? "New collection" : `${values?.name} collection`}
|
|
118
128
|
</Typography>
|
|
119
|
-
<
|
|
129
|
+
<DatabaseField databaseId={values.databaseId}
|
|
130
|
+
onDatabaseIdUpdate={updateDatabaseId}/>
|
|
131
|
+
|
|
132
|
+
<Tooltip title={"Change icon"}
|
|
133
|
+
asChild={true}>
|
|
120
134
|
<IconButton
|
|
121
135
|
shape={"square"}
|
|
122
136
|
onClick={() => setIconDialogOpen(true)}>
|
|
@@ -146,7 +160,7 @@ export function CollectionDetailsForm({
|
|
|
146
160
|
</FieldCaption>
|
|
147
161
|
</div>
|
|
148
162
|
|
|
149
|
-
<div className={
|
|
163
|
+
<div className={cls("col-span-12 ", isSubcollection ? "" : "sm:col-span-8")}>
|
|
150
164
|
<Field name={"path"}
|
|
151
165
|
as={DebouncedTextField}
|
|
152
166
|
label={"Path"}
|
|
@@ -190,7 +204,7 @@ export function CollectionDetailsForm({
|
|
|
190
204
|
})}
|
|
191
205
|
</Autocomplete>
|
|
192
206
|
<FieldCaption>
|
|
193
|
-
{showErrors && Boolean(errors.group) ? errors.group : "Group
|
|
207
|
+
{showErrors && Boolean(errors.group) ? errors.group : "Group in the home page"}
|
|
194
208
|
</FieldCaption>
|
|
195
209
|
</div>}
|
|
196
210
|
|
|
@@ -216,7 +230,7 @@ export function CollectionDetailsForm({
|
|
|
216
230
|
label={"Collection id"}
|
|
217
231
|
error={showErrors && Boolean(errors.id)}/>
|
|
218
232
|
<FieldCaption error={touched.id && Boolean(errors.id)}>
|
|
219
|
-
{touched.id && Boolean(errors.id) ? errors.id : "This id identifies this collection"}
|
|
233
|
+
{touched.id && Boolean(errors.id) ? errors.id : "This id identifies this collection. Typically the same as the path."}
|
|
220
234
|
</FieldCaption>
|
|
221
235
|
</div>
|
|
222
236
|
|
|
@@ -235,6 +249,35 @@ export function CollectionDetailsForm({
|
|
|
235
249
|
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define a singular name for your entities"}
|
|
236
250
|
</FieldCaption>
|
|
237
251
|
</div>
|
|
252
|
+
<div className={"col-span-12"}>
|
|
253
|
+
<TextField
|
|
254
|
+
error={showErrors && Boolean(errors.sideDialogWidth)}
|
|
255
|
+
name={"sideDialogWidth"}
|
|
256
|
+
type={"number"}
|
|
257
|
+
aria-describedby={"sideDialogWidth-helper"}
|
|
258
|
+
onChange={(e) => {
|
|
259
|
+
setFieldTouched("sideDialogWidth", true);
|
|
260
|
+
const value = e.target.value;
|
|
261
|
+
if (!value) {
|
|
262
|
+
setFieldValue("sideDialogWidth", null);
|
|
263
|
+
} else if (!isNaN(Number(value))) {
|
|
264
|
+
setFieldValue("sideDialogWidth", Number(value));
|
|
265
|
+
}
|
|
266
|
+
}}
|
|
267
|
+
endAdornment={<IconButton
|
|
268
|
+
size={"small"}
|
|
269
|
+
onClick={() => {
|
|
270
|
+
setFieldValue("sideDialogWidth", null);
|
|
271
|
+
}}
|
|
272
|
+
disabled={!values.sideDialogWidth}>
|
|
273
|
+
<ClearIcon size={"small"}/>
|
|
274
|
+
</IconButton>}
|
|
275
|
+
value={values.sideDialogWidth ?? ""}
|
|
276
|
+
label={"Side dialog width"}/>
|
|
277
|
+
<FieldCaption error={showErrors && Boolean(errors.singularName)}>
|
|
278
|
+
{showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define the width (in pixels) of entities side dialog. Default is 768px"}
|
|
279
|
+
</FieldCaption>
|
|
280
|
+
</div>
|
|
238
281
|
<div className={"col-span-12"}>
|
|
239
282
|
<TextField
|
|
240
283
|
error={showErrors && Boolean(errors.description)}
|
|
@@ -272,7 +315,7 @@ export function CollectionDetailsForm({
|
|
|
272
315
|
<div className={"col-span-12"}>
|
|
273
316
|
<Select
|
|
274
317
|
name="customId"
|
|
275
|
-
label="
|
|
318
|
+
label="Document IDs generation"
|
|
276
319
|
position={"item-aligned"}
|
|
277
320
|
disabled={customIdValue === "code_defined"}
|
|
278
321
|
onValueChange={(v) => {
|
|
@@ -363,3 +406,20 @@ export function CollectionDetailsForm({
|
|
|
363
406
|
</div>
|
|
364
407
|
);
|
|
365
408
|
}
|
|
409
|
+
|
|
410
|
+
function DefaultDatabaseField({
|
|
411
|
+
databaseId,
|
|
412
|
+
onDatabaseIdUpdate
|
|
413
|
+
}: { databaseId?: string, onDatabaseIdUpdate: (databaseId: string) => void }) {
|
|
414
|
+
|
|
415
|
+
return <Tooltip title={"Database ID"}
|
|
416
|
+
side={"top"}
|
|
417
|
+
align={"start"}>
|
|
418
|
+
<TextField size={"smallest"}
|
|
419
|
+
invisible={true}
|
|
420
|
+
inputClassName={"text-end"}
|
|
421
|
+
value={databaseId ?? ""}
|
|
422
|
+
onChange={(e: any) => onDatabaseIdUpdate(e.target.value)}
|
|
423
|
+
placeholder={"(default)"}></TextField>
|
|
424
|
+
</Tooltip>
|
|
425
|
+
}
|