@firecms/core 3.0.0-alpha.46 → 3.0.0-alpha.48
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/index.es.js +2128 -2082
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +12 -12
- 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/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/EntityCollectionTable.tsx +1 -0
- 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 +3 -3
- package/src/components/ReferenceSelectionInner.tsx +34 -30
- package/src/components/VirtualTable/VirtualTableRow.tsx +10 -8
- package/src/core/EntitySidePanel.tsx +5 -0
- package/src/core/NavigationRoutes.tsx +5 -5
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -0
- package/src/internal/EntityView.tsx +6 -12
- package/src/internal/useBuildNavigationController.tsx +33 -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 +1 -1
- 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 +76 -24
- 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
|
@@ -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/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 | void): 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 | void): 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.48",
|
|
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": "04d4690b0b71a4dd56a01a77e4c639d6af79be86",
|
|
137
137
|
"publishConfig": {
|
|
138
138
|
"access": "public"
|
|
139
139
|
}
|
|
@@ -142,6 +142,7 @@ export const EntityCollectionTable = React.memo<EntityCollectionTableProps<any>>
|
|
|
142
142
|
const onRowClick = useCallback(({ rowData }: {
|
|
143
143
|
rowData: Entity<M>
|
|
144
144
|
}) => {
|
|
145
|
+
console.debug("EntityCollectionTable click");
|
|
145
146
|
if (inlineEditing)
|
|
146
147
|
return;
|
|
147
148
|
return onEntityClick && onEntityClick(rowData);
|
|
@@ -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,
|
|
@@ -19,6 +19,7 @@ import { useEntityCollectionTableController } from "./EntityCollectionTable/useE
|
|
|
19
19
|
import { AddIcon } from "../icons";
|
|
20
20
|
import { useColumnIds } from "./EntityCollectionView/useColumnsIds";
|
|
21
21
|
import { useSideDialogContext } from "../core";
|
|
22
|
+
import { useTraceUpdate } from "../util/useTraceUpdate";
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* @group Components
|
|
@@ -99,6 +100,8 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
99
100
|
maxSelection
|
|
100
101
|
}: ReferenceSelectionInnerProps<M>) {
|
|
101
102
|
|
|
103
|
+
console.log("ReferenceSelectionInner");
|
|
104
|
+
|
|
102
105
|
const sideDialogContext = useSideDialogContext();
|
|
103
106
|
const sideEntityController = useSideEntityController();
|
|
104
107
|
const navigation = useNavigationController();
|
|
@@ -142,7 +145,7 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
142
145
|
};
|
|
143
146
|
}, [dataSource, fullPath, selectedEntityIdsProp, collection, selectionController.setSelectedEntities]);
|
|
144
147
|
|
|
145
|
-
const onClear =
|
|
148
|
+
const onClear = () => {
|
|
146
149
|
context.onAnalyticsEvent?.("reference_selection_clear", {
|
|
147
150
|
path: fullPath
|
|
148
151
|
});
|
|
@@ -152,9 +155,10 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
152
155
|
} else if (onMultipleEntitiesSelected) {
|
|
153
156
|
onMultipleEntitiesSelected([]);
|
|
154
157
|
}
|
|
155
|
-
}
|
|
158
|
+
};
|
|
156
159
|
|
|
157
|
-
const toggleEntitySelection =
|
|
160
|
+
const toggleEntitySelection = (entity: Entity<any>) => {
|
|
161
|
+
console.debug("ReferenceSelectionInner toggleEntitySelection", entity);
|
|
158
162
|
let newValue;
|
|
159
163
|
const selectedEntities = selectionController.selectedEntities;
|
|
160
164
|
|
|
@@ -176,9 +180,10 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
176
180
|
if (onMultipleEntitiesSelected)
|
|
177
181
|
onMultipleEntitiesSelected(newValue);
|
|
178
182
|
}
|
|
179
|
-
}
|
|
183
|
+
};
|
|
180
184
|
|
|
181
|
-
const onEntityClick =
|
|
185
|
+
const onEntityClick = (entity: Entity<any>) => {
|
|
186
|
+
console.debug("ReferenceSelectionInner onEntityClick", entity);
|
|
182
187
|
|
|
183
188
|
if (!multiselect && onSingleEntitySelected) {
|
|
184
189
|
context.onAnalyticsEvent?.("reference_selected_single", {
|
|
@@ -190,32 +195,31 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
190
195
|
} else {
|
|
191
196
|
toggleEntitySelection(entity);
|
|
192
197
|
}
|
|
193
|
-
}
|
|
198
|
+
};
|
|
194
199
|
|
|
195
200
|
// create a new entity from within the reference dialog
|
|
196
|
-
const onNewClick =
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}: {
|
|
201
|
+
const onNewClick = () => {
|
|
202
|
+
context.onAnalyticsEvent?.("reference_selection_new_entity", {
|
|
203
|
+
path: fullPath
|
|
204
|
+
});
|
|
205
|
+
sideEntityController.open({
|
|
206
|
+
path: fullPath,
|
|
207
|
+
collection,
|
|
208
|
+
updateUrl: true,
|
|
209
|
+
onUpdate: ({ entity }) => {
|
|
210
|
+
setEntitiesDisplayedFirst([entity, ...entitiesDisplayedFirst]);
|
|
211
|
+
onEntityClick(entity);
|
|
212
|
+
},
|
|
213
|
+
closeOnSave: true
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
const tableRowActionsBuilder = ({
|
|
218
|
+
entity,
|
|
219
|
+
size,
|
|
220
|
+
width,
|
|
221
|
+
frozen
|
|
222
|
+
}: {
|
|
219
223
|
entity: Entity<any>,
|
|
220
224
|
size: CollectionSize,
|
|
221
225
|
width: number,
|
|
@@ -234,7 +238,7 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
234
238
|
fullPath={fullPath}
|
|
235
239
|
selectionController={selectionController}/>;
|
|
236
240
|
|
|
237
|
-
}
|
|
241
|
+
};
|
|
238
242
|
|
|
239
243
|
const onDone = useCallback((event: React.SyntheticEvent) => {
|
|
240
244
|
event.stopPropagation();
|
|
@@ -15,16 +15,18 @@ export const VirtualTableRow = React.memo<VirtualTableRowProps<any>>(
|
|
|
15
15
|
size,
|
|
16
16
|
style,
|
|
17
17
|
hoverRow,
|
|
18
|
-
rowClassName
|
|
18
|
+
rowClassName
|
|
19
19
|
}: VirtualTableRowProps<T>) {
|
|
20
20
|
|
|
21
|
-
const onClick = useCallback((event: React.SyntheticEvent) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const onClick = useCallback((event: React.SyntheticEvent) => {
|
|
22
|
+
console.debug("VirtualTableRow click");
|
|
23
|
+
if (onRowClick)
|
|
24
|
+
onRowClick({
|
|
25
|
+
rowData,
|
|
26
|
+
rowIndex,
|
|
27
|
+
event
|
|
28
|
+
})
|
|
29
|
+
}, [onRowClick, rowData, rowIndex]);
|
|
28
30
|
|
|
29
31
|
return (
|
|
30
32
|
<div
|
|
@@ -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>
|
|
@@ -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
|
|
|
@@ -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" : ""
|