@firecms/core 3.0.0-alpha.45 → 3.0.0-alpha.47
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/components/EntityCollectionView/EntityCollectionView.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +2 -2
- package/dist/hooks/index.d.ts +0 -2
- package/dist/index.es.js +12597 -12560
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +14 -14
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/EntityView.d.ts +2 -1
- package/dist/types/collections.d.ts +8 -8
- package/dist/types/firecms.d.ts +25 -6
- package/dist/types/index.d.ts +1 -0
- package/dist/types/modify_collections.d.ts +5 -0
- package/dist/types/navigation.d.ts +9 -0
- package/dist/types/plugins.d.ts +2 -2
- package/dist/ui/ExpandablePanel.d.ts +2 -1
- package/dist/util/join_collections.d.ts +3 -7
- package/package.json +2 -2
- package/src/components/EntityCollectionTable/internal/EntityCollectionRowActions.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/common.tsx +1 -1
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +7 -7
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +6 -6
- package/src/core/EntitySidePanel.tsx +5 -0
- package/src/core/FireCMS.tsx +28 -4
- package/src/core/NavigationRoutes.tsx +5 -5
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -0
- package/src/hooks/index.tsx +0 -2
- package/src/internal/EntityView.tsx +6 -12
- package/src/{hooks → internal}/useBuildDataSource.ts +2 -4
- package/src/{hooks → internal}/useBuildNavigationController.tsx +34 -9
- package/src/internal/useBuildSideEntityController.tsx +1 -1
- package/src/preview/PropertyPreview.tsx +0 -1
- package/src/types/collections.ts +9 -9
- package/src/types/firecms.tsx +28 -8
- package/src/types/index.ts +1 -0
- package/src/types/modify_collections.tsx +6 -0
- package/src/types/navigation.ts +11 -0
- package/src/types/plugins.tsx +2 -2
- package/src/ui/ExpandablePanel.tsx +9 -2
- package/src/util/builders.ts +2 -1
- package/src/util/join_collections.ts +49 -19
- package/src/util/navigation_from_path.ts +2 -2
- package/src/util/navigation_utils.ts +3 -3
- package/src/util/parent_references_from_path.ts +2 -2
- package/src/util/property_utils.tsx +1 -7
- /package/dist/{hooks → internal}/useBuildDataSource.d.ts +0 -0
- /package/dist/{hooks → internal}/useBuildNavigationController.d.ts +0 -0
|
@@ -5,6 +5,7 @@ export interface EntityViewProps<M extends Record<string, any>> {
|
|
|
5
5
|
entityId?: string;
|
|
6
6
|
copy?: boolean;
|
|
7
7
|
selectedSubPath?: string;
|
|
8
|
+
parentCollectionIds: string[];
|
|
8
9
|
formWidth?: number | string;
|
|
9
10
|
onValuesAreModified: (modified: boolean) => void;
|
|
10
11
|
onUpdate?: (params: {
|
|
@@ -18,4 +19,4 @@ export interface EntityViewProps<M extends Record<string, any>> {
|
|
|
18
19
|
* You probably don't want to use this view directly since it is bound to the
|
|
19
20
|
* side panel. Instead, you might want to use {@link EntityForm} or {@link EntityCollectionView}
|
|
20
21
|
*/
|
|
21
|
-
export declare function EntityView<M extends Record<string, any>, UserType extends User>({ path, entityId, selectedSubPath, copy, collection, onValuesAreModified, formWidth, onUpdate, onClose }: EntityViewProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function EntityView<M extends Record<string, any>, UserType extends User>({ path, entityId, selectedSubPath, copy, collection, parentCollectionIds, onValuesAreModified, formWidth, onUpdate, onClose }: EntityViewProps<M>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -16,6 +16,13 @@ import { ExportConfig } from "./export_import";
|
|
|
16
16
|
* @group Models
|
|
17
17
|
*/
|
|
18
18
|
export interface EntityCollection<M extends Record<string, any> = any, UserType extends User = User> {
|
|
19
|
+
/**
|
|
20
|
+
* You can set an alias that will be used internally instead of the `path`.
|
|
21
|
+
* The `alias` value will be used to determine the URL of the collection,
|
|
22
|
+
* while `path` will still be used in the datasource.
|
|
23
|
+
* Note that you can use this value in reference properties too.
|
|
24
|
+
*/
|
|
25
|
+
id: string;
|
|
19
26
|
/**
|
|
20
27
|
* Name of the collection, typically plural.
|
|
21
28
|
* E.g. `Products`, `Blog`
|
|
@@ -41,13 +48,6 @@ export interface EntityCollection<M extends Record<string, any> = any, UserType
|
|
|
41
48
|
* property to `true` to indicate that this collection is a collection group.
|
|
42
49
|
*/
|
|
43
50
|
collectionGroup?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* You can set an alias that will be used internally instead of the `path`.
|
|
46
|
-
* The `alias` value will be used to determine the URL of the collection,
|
|
47
|
-
* while `path` will still be used in the datasource.
|
|
48
|
-
* Note that you can use this value in reference properties too.
|
|
49
|
-
*/
|
|
50
|
-
alias?: string;
|
|
51
51
|
/**
|
|
52
52
|
* Icon key to use in this collection.
|
|
53
53
|
* You can use any of the icons in the Material specs:
|
|
@@ -262,7 +262,7 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, Use
|
|
|
262
262
|
/**
|
|
263
263
|
* Array of the parent path segments like `['users']`
|
|
264
264
|
*/
|
|
265
|
-
|
|
265
|
+
parentCollectionIds: string[];
|
|
266
266
|
/**
|
|
267
267
|
* The collection configuration
|
|
268
268
|
*/
|
package/dist/types/firecms.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { User } from "./user";
|
|
3
3
|
import { AuthController } from "./auth";
|
|
4
|
-
import {
|
|
4
|
+
import { DataSourceDelegate } from "./datasource";
|
|
5
5
|
import { EntityCollection, EntityCustomView } from "./collections";
|
|
6
|
-
import { CMSView
|
|
6
|
+
import { CMSView } from "./navigation";
|
|
7
7
|
import { FireCMSContext } from "./firecms_context";
|
|
8
8
|
import { PropertyConfig } from "./property_config";
|
|
9
9
|
import { Locale } from "./locales";
|
|
@@ -62,6 +62,18 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
62
62
|
*/
|
|
63
63
|
loading: boolean;
|
|
64
64
|
}) => React.ReactNode;
|
|
65
|
+
/**
|
|
66
|
+
* List of the mapped collections in the CMS.
|
|
67
|
+
* Each entry relates to a collection in the root database.
|
|
68
|
+
* Each of the navigation entries in this field
|
|
69
|
+
* generates an entry in the main menu.
|
|
70
|
+
*/
|
|
71
|
+
collections?: EC[] | EntityCollectionsBuilder<EC>;
|
|
72
|
+
/**
|
|
73
|
+
* Custom additional views created by the developer, added to the main
|
|
74
|
+
* navigation
|
|
75
|
+
*/
|
|
76
|
+
views?: CMSView[] | CMSViewsBuilder;
|
|
65
77
|
/**
|
|
66
78
|
* Record of custom form fields to be used in the CMS.
|
|
67
79
|
* You can use the key to reference the custom field in
|
|
@@ -88,7 +100,7 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
88
100
|
/**
|
|
89
101
|
* Connector to your database
|
|
90
102
|
*/
|
|
91
|
-
|
|
103
|
+
dataSourceDelegate: DataSourceDelegate;
|
|
92
104
|
/**
|
|
93
105
|
* Connector to your file upload/fetch implementation
|
|
94
106
|
*/
|
|
@@ -98,10 +110,17 @@ export type FireCMSProps<UserType extends User, EC extends EntityCollection> = {
|
|
|
98
110
|
*/
|
|
99
111
|
authController: AuthController<UserType>;
|
|
100
112
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
113
|
+
* Path under the navigation routes of the CMS will be created. Defaults to `/`.
|
|
114
|
+
* Internally FireCMS uses `react-router` to create the routes, the base path is attached to the
|
|
115
|
+
* `BrowserRouter` component. If you are using FireCMS in a subpath of your website, you can use
|
|
116
|
+
* this prop to specify the base path.
|
|
117
|
+
*/
|
|
118
|
+
basePath?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Path under the collection routes of the CMS will be created.
|
|
121
|
+
* Defaults to `/c`.
|
|
103
122
|
*/
|
|
104
|
-
|
|
123
|
+
baseCollectionPath?: string;
|
|
105
124
|
/**
|
|
106
125
|
* Use this controller to access the configuration that is stored locally,
|
|
107
126
|
* and not defined in code
|
package/dist/types/index.d.ts
CHANGED
|
@@ -42,6 +42,10 @@ export type NavigationController = {
|
|
|
42
42
|
* The collection is resolved from the given path or alias.
|
|
43
43
|
*/
|
|
44
44
|
getCollection: <EC extends EntityCollection = EntityCollection<any>>(pathOrAlias: string, entityId?: string, includeUserOverride?: boolean) => EC | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Get the collection configuration from its parent path segments.
|
|
47
|
+
*/
|
|
48
|
+
getCollectionFromIds: <EC extends EntityCollection = EntityCollection<any>>(ids: string[]) => EC | undefined;
|
|
45
49
|
/**
|
|
46
50
|
* Get the collection configuration from its parent path segments.
|
|
47
51
|
*/
|
|
@@ -106,6 +110,11 @@ export type NavigationController = {
|
|
|
106
110
|
* @param path
|
|
107
111
|
*/
|
|
108
112
|
getParentReferencesFromPath: (path: string) => EntityReference[];
|
|
113
|
+
/**
|
|
114
|
+
* Retrieve all the related parent collection ids for a given path
|
|
115
|
+
* @param path
|
|
116
|
+
*/
|
|
117
|
+
getParentCollectionIds: (path: string) => string[];
|
|
109
118
|
};
|
|
110
119
|
/**
|
|
111
120
|
* Custom additional views created by the developer, added to the main
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
95
95
|
property: ResolvedProperty;
|
|
96
96
|
propertyKey: string;
|
|
97
97
|
fullPath: string;
|
|
98
|
-
|
|
98
|
+
parentCollectionIds: string[];
|
|
99
99
|
onHover: boolean;
|
|
100
100
|
collection: EC;
|
|
101
101
|
}>;
|
|
@@ -105,7 +105,7 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
105
105
|
*/
|
|
106
106
|
AddColumnComponent?: React.ComponentType<{
|
|
107
107
|
fullPath: string;
|
|
108
|
-
|
|
108
|
+
parentCollectionIds: string[];
|
|
109
109
|
collection: EC;
|
|
110
110
|
}>;
|
|
111
111
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
export declare function ExpandablePanel({ title, children, invisible,
|
|
2
|
+
export declare function ExpandablePanel({ title, children, invisible, expanded, onExpandedChange, initiallyExpanded, titleClassName, asField, className }: PropsWithChildren<{
|
|
3
3
|
title: React.ReactNode;
|
|
4
4
|
invisible?: boolean;
|
|
5
5
|
initiallyExpanded?: boolean;
|
|
6
|
+
expanded?: boolean;
|
|
6
7
|
onExpandedChange?: (expanded: boolean) => void;
|
|
7
8
|
titleClassName?: string;
|
|
8
9
|
asField?: boolean;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { EntityCollection } from "../types";
|
|
1
|
+
import { EntityCollection, ModifyCollectionProps } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
|
-
* @param storedCollections
|
|
5
|
-
* @param codedCollections
|
|
6
4
|
*/
|
|
7
|
-
export declare function joinCollectionLists(
|
|
5
|
+
export declare function joinCollectionLists(targetCollections: EntityCollection[], sourceCollections: EntityCollection[] | undefined, parentPaths?: string[], modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | undefined): EntityCollection[];
|
|
8
6
|
/**
|
|
9
7
|
*
|
|
10
|
-
* @param target
|
|
11
|
-
* @param source
|
|
12
8
|
*/
|
|
13
|
-
export declare function mergeCollection(target: EntityCollection, source: EntityCollection): EntityCollection;
|
|
9
|
+
export declare function mergeCollection(target: EntityCollection, source: EntityCollection, parentPaths?: string[], modifyCollection?: (props: ModifyCollectionProps) => EntityCollection | undefined): EntityCollection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.47",
|
|
4
4
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
5
5
|
"funding": {
|
|
6
6
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"dist",
|
|
134
134
|
"src"
|
|
135
135
|
],
|
|
136
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "1c2310776f2da9bba46ba352e9a5244118dcdc3f",
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public"
|
|
139
139
|
}
|
|
@@ -2,7 +2,7 @@ import React, { MouseEvent, useCallback } from "react";
|
|
|
2
2
|
import equal from "react-fast-compare"
|
|
3
3
|
|
|
4
4
|
import { CollectionSize, Entity, EntityAction, EntityCollection, SelectionController } from "../../../types";
|
|
5
|
-
import { Checkbox, cn, IconButton, Menu, MenuItem, Tooltip, Typography
|
|
5
|
+
import { Checkbox, cn, IconButton, Menu, MenuItem, Skeleton, Tooltip, Typography } from "../../../ui";
|
|
6
6
|
import { useFireCMSContext, useLargeLayout } from "../../../hooks";
|
|
7
7
|
import { MoreVertIcon } from "../../../icons";
|
|
8
8
|
|
|
@@ -66,5 +66,5 @@ export function getTablePropertyColumnWidth(property: ResolvedProperty): number
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export function getSubcollectionColumnId(collection: EntityCollection) {
|
|
69
|
-
return `subcollection:${collection.
|
|
69
|
+
return `subcollection:${collection.id ?? collection.path}`;
|
|
70
70
|
}
|
|
@@ -69,7 +69,7 @@ const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
|
|
|
69
69
|
*/
|
|
70
70
|
export type EntityCollectionViewProps<M extends Record<string, any>> = {
|
|
71
71
|
fullPath: string;
|
|
72
|
-
|
|
72
|
+
parentCollectionIds?: string[];
|
|
73
73
|
isSubCollection?: boolean;
|
|
74
74
|
className?: string;
|
|
75
75
|
} & EntityCollection<M>;
|
|
@@ -101,7 +101,7 @@ export type EntityCollectionViewProps<M extends Record<string, any>> = {
|
|
|
101
101
|
export const EntityCollectionView = React.memo(
|
|
102
102
|
function EntityCollectionView<M extends Record<string, any>>({
|
|
103
103
|
fullPath,
|
|
104
|
-
|
|
104
|
+
parentCollectionIds,
|
|
105
105
|
isSubCollection,
|
|
106
106
|
className,
|
|
107
107
|
...collectionProp
|
|
@@ -238,7 +238,7 @@ export const EntityCollectionView = React.memo(
|
|
|
238
238
|
|
|
239
239
|
let AddColumnComponent: React.ComponentType<{
|
|
240
240
|
fullPath: string,
|
|
241
|
-
|
|
241
|
+
parentCollectionIds: string[],
|
|
242
242
|
collection: EntityCollection;
|
|
243
243
|
}> | undefined
|
|
244
244
|
|
|
@@ -367,7 +367,7 @@ export const EntityCollectionView = React.memo(
|
|
|
367
367
|
sideEntityController.open({
|
|
368
368
|
path: fullPath,
|
|
369
369
|
entityId: entity.id,
|
|
370
|
-
selectedSubPath: subcollection.
|
|
370
|
+
selectedSubPath: subcollection.id ?? subcollection.path,
|
|
371
371
|
collection,
|
|
372
372
|
updateUrl: true
|
|
373
373
|
});
|
|
@@ -529,7 +529,7 @@ export const EntityCollectionView = React.memo(
|
|
|
529
529
|
property={property}
|
|
530
530
|
fullPath={fullPath}
|
|
531
531
|
collection={collection}
|
|
532
|
-
|
|
532
|
+
parentCollectionIds={parentCollectionIds ?? []}/>;
|
|
533
533
|
})}
|
|
534
534
|
</>;
|
|
535
535
|
}
|
|
@@ -538,7 +538,7 @@ export const EntityCollectionView = React.memo(
|
|
|
538
538
|
? function () {
|
|
539
539
|
if (typeof AddColumnComponent === "function")
|
|
540
540
|
return <AddColumnComponent fullPath={fullPath}
|
|
541
|
-
|
|
541
|
+
parentCollectionIds={parentCollectionIds ?? []}
|
|
542
542
|
collection={collection}/>;
|
|
543
543
|
return null;
|
|
544
544
|
}
|
|
@@ -565,7 +565,7 @@ export const EntityCollectionView = React.memo(
|
|
|
565
565
|
properties={resolvedCollection.properties}
|
|
566
566
|
getPropertyFor={getPropertyFor}
|
|
567
567
|
actions={<EntityCollectionViewActions
|
|
568
|
-
|
|
568
|
+
parentCollectionIds={parentCollectionIds ?? []}
|
|
569
569
|
collection={collection}
|
|
570
570
|
tableController={tableController}
|
|
571
571
|
onMultipleDeleteClick={onMultipleDeleteClick}
|
|
@@ -12,7 +12,7 @@ export type EntityCollectionViewActionsProps<M extends Record<string, any>> = {
|
|
|
12
12
|
collection: EntityCollection<M>;
|
|
13
13
|
path: string;
|
|
14
14
|
relativePath: string;
|
|
15
|
-
|
|
15
|
+
parentCollectionIds: string[];
|
|
16
16
|
selectionEnabled: boolean;
|
|
17
17
|
onNewClick: () => void;
|
|
18
18
|
onMultipleDeleteClick: () => void;
|
|
@@ -24,7 +24,7 @@ export type EntityCollectionViewActionsProps<M extends Record<string, any>> = {
|
|
|
24
24
|
export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
25
25
|
collection,
|
|
26
26
|
relativePath,
|
|
27
|
-
|
|
27
|
+
parentCollectionIds,
|
|
28
28
|
onNewClick,
|
|
29
29
|
onMultipleDeleteClick,
|
|
30
30
|
selectionEnabled,
|
|
@@ -95,7 +95,7 @@ export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
|
95
95
|
const actionProps: CollectionActionsProps = {
|
|
96
96
|
path,
|
|
97
97
|
relativePath,
|
|
98
|
-
|
|
98
|
+
parentCollectionIds,
|
|
99
99
|
collection,
|
|
100
100
|
selectionController,
|
|
101
101
|
context,
|
|
@@ -111,11 +111,11 @@ export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
|
111
111
|
));
|
|
112
112
|
|
|
113
113
|
if (plugins) {
|
|
114
|
-
plugins.forEach(plugin => {
|
|
114
|
+
plugins.forEach((plugin, i) => {
|
|
115
115
|
if (plugin.collections?.CollectionActions) {
|
|
116
116
|
actions.push(...toArray(plugin.collections?.CollectionActions)
|
|
117
|
-
.map((Action,
|
|
118
|
-
<ErrorBoundary key={`plugin_actions_${i}`}>
|
|
117
|
+
.map((Action, j) => (
|
|
118
|
+
<ErrorBoundary key={`plugin_actions_${i}_${j}`}>
|
|
119
119
|
<Action {...actionProps} {...plugin.collections?.collectionActionsProps}/>
|
|
120
120
|
</ErrorBoundary>
|
|
121
121
|
)));
|
|
@@ -25,6 +25,10 @@ export function EntitySidePanel(props: EntitySidePanelProps) {
|
|
|
25
25
|
|
|
26
26
|
const navigationController = useNavigationController();
|
|
27
27
|
|
|
28
|
+
const parentCollectionIds = useMemo(() => {
|
|
29
|
+
return navigationController.getParentCollectionIds(props.path);
|
|
30
|
+
}, [navigationController, props.path]);
|
|
31
|
+
|
|
28
32
|
const collection = useMemo(() => {
|
|
29
33
|
if (!props) return undefined;
|
|
30
34
|
let usedCollection = props.collection;
|
|
@@ -76,6 +80,7 @@ export function EntitySidePanel(props: EntitySidePanelProps) {
|
|
|
76
80
|
{...props}
|
|
77
81
|
formWidth={props.width}
|
|
78
82
|
collection={collection}
|
|
83
|
+
parentCollectionIds={parentCollectionIds}
|
|
79
84
|
onValuesAreModified={onValuesAreModified}
|
|
80
85
|
/>
|
|
81
86
|
</ErrorBoundary>
|
package/src/core/FireCMS.tsx
CHANGED
|
@@ -16,7 +16,8 @@ import { SideDialogsControllerContext } from "../contexts/SideDialogsControllerC
|
|
|
16
16
|
import { useLocaleConfig } from "../internal/useLocaleConfig";
|
|
17
17
|
import { CenteredView } from "../ui";
|
|
18
18
|
import { DialogsProvider } from "../contexts/DialogsProvider";
|
|
19
|
-
|
|
19
|
+
import { useBuildNavigationController } from "../internal/useBuildNavigationController";
|
|
20
|
+
import { useBuildDataSource } from "../internal/useBuildDataSource";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* If you are using independent components of the CMS
|
|
@@ -41,17 +42,40 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
|
|
|
41
42
|
locale,
|
|
42
43
|
authController,
|
|
43
44
|
storageSource,
|
|
44
|
-
|
|
45
|
-
navigationController,
|
|
45
|
+
dataSourceDelegate,
|
|
46
46
|
plugins,
|
|
47
47
|
onAnalyticsEvent,
|
|
48
48
|
propertyConfigs,
|
|
49
49
|
entityViews,
|
|
50
|
-
components
|
|
50
|
+
components,
|
|
51
|
+
baseCollectionPath,
|
|
52
|
+
basePath,
|
|
53
|
+
collections,
|
|
54
|
+
views
|
|
51
55
|
} = props;
|
|
52
56
|
|
|
53
57
|
useLocaleConfig(locale);
|
|
54
58
|
|
|
59
|
+
const navigationController = useBuildNavigationController({
|
|
60
|
+
basePath,
|
|
61
|
+
baseCollectionPath,
|
|
62
|
+
authController,
|
|
63
|
+
collections,
|
|
64
|
+
views,
|
|
65
|
+
userConfigPersistence,
|
|
66
|
+
dataSource: dataSourceDelegate,
|
|
67
|
+
plugins
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Controller in charge of fetching and persisting data
|
|
72
|
+
*/
|
|
73
|
+
const dataSource = useBuildDataSource({
|
|
74
|
+
delegate: dataSourceDelegate,
|
|
75
|
+
propertyConfigs,
|
|
76
|
+
navigationController
|
|
77
|
+
});
|
|
78
|
+
|
|
55
79
|
const sideDialogsController = useBuildSideDialogsController();
|
|
56
80
|
const sideEntityController = useBuildSideEntityController(navigationController, sideDialogsController);
|
|
57
81
|
|
|
@@ -67,19 +67,19 @@ export const NavigationRoutes = React.memo<NavigationRoutesProps>(
|
|
|
67
67
|
|
|
68
68
|
const collectionRoutes = sortedCollections
|
|
69
69
|
.map((collection) => {
|
|
70
|
-
const urlPath = navigation.buildUrlCollectionPath(collection.
|
|
70
|
+
const urlPath = navigation.buildUrlCollectionPath(collection.id ?? collection.path);
|
|
71
71
|
return <Route path={urlPath + "/*"}
|
|
72
|
-
key={`navigation_${collection.
|
|
72
|
+
key={`navigation_${collection.id ?? collection.path}`}
|
|
73
73
|
element={
|
|
74
74
|
<RouteWrapper
|
|
75
75
|
path={urlPath}
|
|
76
76
|
title={collection.name}
|
|
77
77
|
type={"collection"}>
|
|
78
78
|
<EntityCollectionView
|
|
79
|
-
key={`collection_view_${collection.
|
|
79
|
+
key={`collection_view_${collection.id ?? collection.path}`}
|
|
80
80
|
isSubCollection={false}
|
|
81
|
-
|
|
82
|
-
fullPath={collection.
|
|
81
|
+
parentCollectionIds={[]}
|
|
82
|
+
fullPath={collection.id ?? collection.path}
|
|
83
83
|
{...collection}
|
|
84
84
|
Actions={toArray(collection.Actions)}/>
|
|
85
85
|
</RouteWrapper>
|
|
@@ -56,6 +56,7 @@ export function ArrayOfReferencesFieldBinding({
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {
|
|
59
|
+
console.debug("onMultipleEntitiesSelected", entities);
|
|
59
60
|
setValue(entities.map(e => getReferenceFrom(e)));
|
|
60
61
|
}, [setValue]);
|
|
61
62
|
|
package/src/hooks/index.tsx
CHANGED
|
@@ -45,18 +45,13 @@ export interface EntityViewProps<M extends Record<string, any>> {
|
|
|
45
45
|
entityId?: string;
|
|
46
46
|
copy?: boolean;
|
|
47
47
|
selectedSubPath?: string;
|
|
48
|
+
parentCollectionIds: string[];
|
|
48
49
|
formWidth?: number | string;
|
|
49
50
|
onValuesAreModified: (modified: boolean) => void;
|
|
50
51
|
onUpdate?: (params: { entity: Entity<any> }) => void;
|
|
51
52
|
onClose?: () => void;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
type EntityViewView = {
|
|
55
|
-
label: string;
|
|
56
|
-
component: React.ReactNode;
|
|
57
|
-
size: "full" | "half";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
55
|
/**
|
|
61
56
|
* This is the default view that is used as the content of a side panel when
|
|
62
57
|
* an entity is opened.
|
|
@@ -69,12 +64,14 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
69
64
|
selectedSubPath,
|
|
70
65
|
copy,
|
|
71
66
|
collection,
|
|
67
|
+
parentCollectionIds,
|
|
72
68
|
onValuesAreModified,
|
|
73
69
|
formWidth,
|
|
74
70
|
onUpdate,
|
|
75
71
|
onClose
|
|
76
72
|
}: EntityViewProps<M>) {
|
|
77
73
|
|
|
74
|
+
|
|
78
75
|
if (collection.customId && collection.formAutoSave) {
|
|
79
76
|
console.warn(`The collection ${collection.path} has customId and formAutoSave enabled. This is not supported and formAutoSave will be ignored`);
|
|
80
77
|
}
|
|
@@ -343,7 +340,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
343
340
|
|
|
344
341
|
const subCollectionsViews = subcollections && subcollections.map(
|
|
345
342
|
(subcollection, colIndex) => {
|
|
346
|
-
const subcollectionId = subcollection.
|
|
343
|
+
const subcollectionId = subcollection.id ?? subcollection.path;
|
|
347
344
|
const fullPath = usedEntity ? `${path}/${usedEntity?.id}/${removeInitialAndTrailingSlashes(subcollectionId)}` : undefined;
|
|
348
345
|
if (selectedTabRef.current !== subcollectionId)
|
|
349
346
|
return null;
|
|
@@ -359,7 +356,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
359
356
|
(usedEntity && fullPath
|
|
360
357
|
? <EntityCollectionView
|
|
361
358
|
fullPath={fullPath}
|
|
362
|
-
|
|
359
|
+
parentCollectionIds={[...parentCollectionIds, collection.id]}
|
|
363
360
|
isSubCollection={true}
|
|
364
361
|
{...subcollection}/>
|
|
365
362
|
: <div
|
|
@@ -480,7 +477,7 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
480
477
|
(subcollection) =>
|
|
481
478
|
<Tab
|
|
482
479
|
className="text-sm min-w-[140px]"
|
|
483
|
-
value={subcollection.
|
|
480
|
+
value={subcollection.id}
|
|
484
481
|
key={`entity_detail_collection_tab_${subcollection.name}`}>
|
|
485
482
|
{subcollection.name}
|
|
486
483
|
</Tab>
|
|
@@ -533,9 +530,6 @@ export function EntityView<M extends Record<string, any>, UserType extends User>
|
|
|
533
530
|
|
|
534
531
|
<Tab
|
|
535
532
|
disabled={!hasAdditionalViews}
|
|
536
|
-
// onClick={() => {
|
|
537
|
-
// onSideTabClick(-1);
|
|
538
|
-
// }}
|
|
539
533
|
value={MAIN_TAB_VALUE}
|
|
540
534
|
className={`${
|
|
541
535
|
!hasAdditionalViews ? "hidden" : ""
|
|
@@ -62,8 +62,6 @@ export function useBuildDataSource({
|
|
|
62
62
|
order
|
|
63
63
|
}: FetchCollectionProps<M>
|
|
64
64
|
): Promise<Entity<M>[]> => {
|
|
65
|
-
|
|
66
|
-
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
67
65
|
return delegate.fetchCollection<M>({
|
|
68
66
|
path,
|
|
69
67
|
filter,
|
|
@@ -125,7 +123,7 @@ export function useBuildDataSource({
|
|
|
125
123
|
onError,
|
|
126
124
|
isCollectionGroup
|
|
127
125
|
});
|
|
128
|
-
}, [delegate])
|
|
126
|
+
}, [delegate, navigationController.getCollection])
|
|
129
127
|
: undefined,
|
|
130
128
|
|
|
131
129
|
/**
|
|
@@ -240,7 +238,7 @@ export function useBuildDataSource({
|
|
|
240
238
|
values: delegate.delegateToCMSModel(updatedFirestoreValues)
|
|
241
239
|
} as Entity<M>;
|
|
242
240
|
});
|
|
243
|
-
}, [delegate.saveEntity]),
|
|
241
|
+
}, [delegate.saveEntity, navigationController.getCollection]),
|
|
244
242
|
|
|
245
243
|
/**
|
|
246
244
|
* Delete an entity
|