@firecms/core 3.0.0-canary.112 → 3.0.0-canary.114
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/ArrayContainer.d.ts +2 -1
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityPreview.d.ts +1 -1
- package/dist/form/components/FormikArrayContainer.d.ts +2 -1
- package/dist/index.es.js +167 -117
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +166 -116
- package/dist/index.umd.js.map +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/types/datasource.d.ts +8 -6
- package/dist/types/entity_overrides.d.ts +2 -2
- package/dist/types/side_dialogs_controller.d.ts +10 -0
- package/dist/util/icons.d.ts +1 -0
- package/package.json +5 -5
- package/src/components/ArrayContainer.tsx +7 -4
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +13 -8
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +1 -1
- package/src/components/EntityPreview.tsx +20 -22
- package/src/components/HomePage/DefaultHomePage.tsx +7 -9
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +7 -2
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -3
- package/src/components/VirtualTable/fields/VirtualTableInput.tsx +2 -1
- package/src/components/VirtualTable/fields/VirtualTableNumberInput.tsx +2 -1
- package/src/core/EntityEditView.tsx +20 -18
- package/src/core/SideDialogs.tsx +0 -2
- package/src/form/components/FormikArrayContainer.tsx +4 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +4 -4
- package/src/form/field_bindings/BlockFieldBinding.tsx +2 -1
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +5 -4
- package/src/hooks/data/delete.ts +2 -1
- package/src/hooks/data/useDataSource.tsx +10 -2
- package/src/hooks/useBuildNavigationController.tsx +2 -4
- package/src/internal/useBuildDataSource.ts +41 -67
- package/src/internal/useBuildSideDialogsController.tsx +1 -0
- package/src/internal/useBuildSideEntityController.tsx +13 -2
- package/src/preview/components/ReferencePreview.tsx +2 -13
- package/src/types/datasource.ts +9 -6
- package/src/types/entity_overrides.tsx +2 -2
- package/src/types/side_dialogs_controller.tsx +13 -0
- package/src/util/icons.tsx +8 -2
|
@@ -6,7 +6,7 @@ import { ReadOnlyFieldBinding } from "./ReadOnlyFieldBinding";
|
|
|
6
6
|
import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
|
|
7
7
|
import { ErrorView } from "../../components";
|
|
8
8
|
import { EmptyValue, ReferencePreview } from "../../preview";
|
|
9
|
-
import { getIconForProperty, getReferenceFrom } from "../../util";
|
|
9
|
+
import { getIconForProperty, getReferenceFrom, IconForView } from "../../util";
|
|
10
10
|
import { useClearRestoreValue } from "../useClearRestoreValue";
|
|
11
11
|
import { EntityPreviewContainer } from "../../components/EntityPreview";
|
|
12
12
|
import { cls } from "@firecms/ui";
|
|
@@ -78,10 +78,10 @@ function ReferenceFieldBindingInternal({
|
|
|
78
78
|
}
|
|
79
79
|
);
|
|
80
80
|
|
|
81
|
-
const onEntryClick =
|
|
81
|
+
const onEntryClick = (e: React.SyntheticEvent) => {
|
|
82
82
|
e.preventDefault();
|
|
83
83
|
referenceDialogController.open();
|
|
84
|
-
}
|
|
84
|
+
};
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
87
|
<>
|
|
@@ -115,7 +115,8 @@ function ReferenceFieldBindingInternal({
|
|
|
115
115
|
: "cursor-pointer text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-gray-800 group-hover:bg-slate-50 dark:group-hover:bg-gray-800")}
|
|
116
116
|
onClick={onEntryClick}
|
|
117
117
|
size={"medium"}>
|
|
118
|
-
<
|
|
118
|
+
<IconForView collectionOrView={collection}
|
|
119
|
+
className={"text-gray-300 dark:text-gray-600"}/>
|
|
119
120
|
{`Edit ${property.name}`.toUpperCase()}
|
|
120
121
|
</EntityPreviewContainer>
|
|
121
122
|
</div>}
|
package/src/hooks/data/delete.ts
CHANGED
|
@@ -7,8 +7,16 @@ import { DataSourceContext } from "../../contexts/DataSourceContext";
|
|
|
7
7
|
* @group Hooks and utilities
|
|
8
8
|
*/
|
|
9
9
|
export const useDataSource = (collection?: EntityCollection<any, any>): DataSource => {
|
|
10
|
+
// const customizationController = useCustomizationController();
|
|
11
|
+
// const navigationController = useNavigationController();
|
|
10
12
|
const defaultDataSource = useContext(DataSourceContext);
|
|
11
|
-
if (collection?.overrides?.
|
|
12
|
-
|
|
13
|
+
// if (collection?.overrides?.dataSourceDelegate) {
|
|
14
|
+
// console.trace("Using custom data source for collection " + collection.id);
|
|
15
|
+
// return useBuildDataSource({
|
|
16
|
+
// delegate: collection.overrides.dataSourceDelegate,
|
|
17
|
+
// propertyConfigs: customizationController?.propertyConfigs,
|
|
18
|
+
// navigationController: navigationController
|
|
19
|
+
// });
|
|
20
|
+
// }
|
|
13
21
|
return defaultDataSource;
|
|
14
22
|
};
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
applyPermissionsFunctionIfEmpty,
|
|
21
21
|
getCollectionByPathOrId,
|
|
22
|
-
mergeDeep,
|
|
22
|
+
mergeDeep,
|
|
23
|
+
removeFunctions,
|
|
23
24
|
removeInitialAndTrailingSlashes,
|
|
24
25
|
resolveCollectionPathIds,
|
|
25
26
|
resolvePermissions
|
|
@@ -200,7 +201,6 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
200
201
|
|
|
201
202
|
let shouldUpdateTopLevelNav = false;
|
|
202
203
|
if (!areCollectionListsEqual(collectionsRef.current ?? [], resolvedCollections)) {
|
|
203
|
-
console.log("Collections need to be updated");
|
|
204
204
|
collectionsRef.current = resolvedCollections;
|
|
205
205
|
shouldUpdateTopLevelNav = true;
|
|
206
206
|
}
|
|
@@ -209,12 +209,10 @@ export function useBuildNavigationController<EC extends EntityCollection, UserTy
|
|
|
209
209
|
shouldUpdateTopLevelNav = true;
|
|
210
210
|
}
|
|
211
211
|
if (!equal(viewsRef.current, resolvedViews)) {
|
|
212
|
-
console.log("Views need to be updated");
|
|
213
212
|
viewsRef.current = resolvedViews;
|
|
214
213
|
shouldUpdateTopLevelNav = true;
|
|
215
214
|
}
|
|
216
215
|
if (!equal(adminViewsRef.current, resolvedAdminViews)) {
|
|
217
|
-
console.log("Admin views need to be updated");
|
|
218
216
|
adminViewsRef.current = resolvedAdminViews;
|
|
219
217
|
shouldUpdateTopLevelNav = true;
|
|
220
218
|
}
|
|
@@ -61,7 +61,8 @@ export function useBuildDataSource({
|
|
|
61
61
|
order,
|
|
62
62
|
}: FetchCollectionProps<M>
|
|
63
63
|
): Promise<Entity<M>[]> => {
|
|
64
|
-
|
|
64
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
65
|
+
return usedDelegate.fetchCollection<M>({
|
|
65
66
|
path,
|
|
66
67
|
filter,
|
|
67
68
|
limit,
|
|
@@ -106,11 +107,12 @@ export function useBuildDataSource({
|
|
|
106
107
|
): () => void => {
|
|
107
108
|
|
|
108
109
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
109
|
-
const
|
|
110
|
-
|
|
110
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
111
|
+
|
|
112
|
+
if (!usedDelegate.listenCollection)
|
|
111
113
|
throw Error("useBuildDataSource delegate not initialised");
|
|
112
114
|
|
|
113
|
-
return
|
|
115
|
+
return usedDelegate.listenCollection<M>({
|
|
114
116
|
path,
|
|
115
117
|
filter,
|
|
116
118
|
limit,
|
|
@@ -137,11 +139,14 @@ export function useBuildDataSource({
|
|
|
137
139
|
entityId,
|
|
138
140
|
collection
|
|
139
141
|
}: FetchEntityProps<M>
|
|
140
|
-
): Promise<Entity<M> | undefined> =>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
): Promise<Entity<M> | undefined> => {
|
|
143
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
144
|
+
return usedDelegate.fetchEntity({
|
|
145
|
+
path,
|
|
146
|
+
entityId,
|
|
147
|
+
collection
|
|
148
|
+
});
|
|
149
|
+
}, [delegate.fetchEntity]),
|
|
145
150
|
|
|
146
151
|
/**
|
|
147
152
|
*
|
|
@@ -162,10 +167,12 @@ export function useBuildDataSource({
|
|
|
162
167
|
onUpdate,
|
|
163
168
|
onError
|
|
164
169
|
}: ListenEntityProps<M>): () => void => {
|
|
165
|
-
|
|
170
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
171
|
+
|
|
172
|
+
if (!usedDelegate.listenEntity)
|
|
166
173
|
throw Error("useBuildDataSource delegate not initialised");
|
|
167
174
|
|
|
168
|
-
return
|
|
175
|
+
return usedDelegate.listenEntity<M>({
|
|
169
176
|
path,
|
|
170
177
|
entityId,
|
|
171
178
|
onUpdate,
|
|
@@ -195,6 +202,7 @@ export function useBuildDataSource({
|
|
|
195
202
|
}: SaveEntityProps<M>): Promise<Entity<M>> => {
|
|
196
203
|
|
|
197
204
|
const collection = collectionProp ?? navigationController.getCollection(path);
|
|
205
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
198
206
|
|
|
199
207
|
console.log("useBuildDatasource save", {
|
|
200
208
|
path,
|
|
@@ -216,32 +224,32 @@ export function useBuildDataSource({
|
|
|
216
224
|
|
|
217
225
|
const properties: ResolvedProperties<M> | undefined = resolvedCollection?.properties;
|
|
218
226
|
|
|
219
|
-
const firestoreValues =
|
|
227
|
+
const firestoreValues = usedDelegate.cmsToDelegateModel(
|
|
220
228
|
values,
|
|
221
229
|
);
|
|
222
230
|
|
|
223
|
-
const
|
|
231
|
+
const updatedValues: EntityValues<M> = properties
|
|
224
232
|
? updateDateAutoValues(
|
|
225
233
|
{
|
|
226
234
|
inputValues: firestoreValues,
|
|
227
235
|
properties,
|
|
228
236
|
status,
|
|
229
|
-
timestampNowValue:
|
|
230
|
-
setDateToMidnight:
|
|
237
|
+
timestampNowValue: usedDelegate.currentTime?.() ?? new Date(),
|
|
238
|
+
setDateToMidnight: usedDelegate.setDateToMidnight
|
|
231
239
|
})
|
|
232
240
|
: firestoreValues;
|
|
233
241
|
|
|
234
|
-
return
|
|
242
|
+
return usedDelegate.saveEntity({
|
|
235
243
|
path,
|
|
236
244
|
collection,
|
|
237
245
|
entityId,
|
|
238
|
-
values:
|
|
246
|
+
values: updatedValues,
|
|
239
247
|
status
|
|
240
248
|
}).then((res) => {
|
|
241
249
|
return {
|
|
242
250
|
id: res.id,
|
|
243
251
|
path: res.path,
|
|
244
|
-
values:
|
|
252
|
+
values: usedDelegate.delegateToCMSModel(updatedValues)
|
|
245
253
|
} as Entity<M>;
|
|
246
254
|
});
|
|
247
255
|
}, [delegate.saveEntity, navigationController.getCollection]),
|
|
@@ -254,10 +262,12 @@ export function useBuildDataSource({
|
|
|
254
262
|
*/
|
|
255
263
|
deleteEntity: useCallback(<M extends Record<string, any>>(
|
|
256
264
|
{
|
|
257
|
-
entity
|
|
265
|
+
entity,
|
|
266
|
+
collection
|
|
258
267
|
}: DeleteEntityProps<M>
|
|
259
268
|
): Promise<void> => {
|
|
260
|
-
|
|
269
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
270
|
+
return usedDelegate.deleteEntity({ entity, collection });
|
|
261
271
|
}, [delegate.deleteEntity]),
|
|
262
272
|
|
|
263
273
|
/**
|
|
@@ -275,13 +285,15 @@ export function useBuildDataSource({
|
|
|
275
285
|
name: string,
|
|
276
286
|
value: any,
|
|
277
287
|
entityId?: string,
|
|
278
|
-
|
|
288
|
+
collection?: EntityCollection
|
|
279
289
|
): Promise<boolean> => {
|
|
280
|
-
|
|
290
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
291
|
+
return usedDelegate.checkUniqueField(path, name, value, entityId, collection);
|
|
281
292
|
}, [delegate.checkUniqueField]),
|
|
282
293
|
|
|
283
|
-
generateEntityId: useCallback((path: string): string => {
|
|
284
|
-
|
|
294
|
+
generateEntityId: useCallback((path: string, collection: EntityCollection): string => {
|
|
295
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
296
|
+
return usedDelegate.generateEntityId(path, collection);
|
|
285
297
|
}, [delegate.generateEntityId]),
|
|
286
298
|
|
|
287
299
|
countEntities: delegate.countEntities ? async ({
|
|
@@ -297,7 +309,8 @@ export function useBuildDataSource({
|
|
|
297
309
|
orderBy?: string,
|
|
298
310
|
order?: "desc" | "asc",
|
|
299
311
|
}): Promise<number> => {
|
|
300
|
-
|
|
312
|
+
const usedDelegate = collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
313
|
+
return usedDelegate.countEntities!({
|
|
301
314
|
path,
|
|
302
315
|
filter,
|
|
303
316
|
orderBy,
|
|
@@ -335,51 +348,12 @@ export function useBuildDataSource({
|
|
|
335
348
|
collection: EntityCollection,
|
|
336
349
|
parentCollectionIds?: string[]
|
|
337
350
|
}): Promise<boolean> => {
|
|
338
|
-
|
|
351
|
+
const usedDelegate = props.collection?.overrides?.dataSourceDelegate ?? delegate;
|
|
352
|
+
if (!usedDelegate.initTextSearch)
|
|
339
353
|
return false;
|
|
340
|
-
return
|
|
354
|
+
return usedDelegate.initTextSearch(props)
|
|
341
355
|
}, [delegate.initTextSearch]),
|
|
342
356
|
|
|
343
357
|
};
|
|
344
358
|
|
|
345
359
|
}
|
|
346
|
-
|
|
347
|
-
// /**
|
|
348
|
-
// * Recursive function that converts Firestore data types into CMS or plain
|
|
349
|
-
// * JS types.
|
|
350
|
-
// * FireCMS uses Javascript dates internally instead of Firestore timestamps.
|
|
351
|
-
// * This makes it easier to interact with the rest of the libraries and
|
|
352
|
-
// * bindings.
|
|
353
|
-
// * Also, Firestore references are replaced with {@link EntityReference}
|
|
354
|
-
// * @param data
|
|
355
|
-
// * @param buildReference
|
|
356
|
-
// * @param buildGeoPoint
|
|
357
|
-
// * @param buildDate
|
|
358
|
-
// * @param buildDelete
|
|
359
|
-
// * @group Firestore
|
|
360
|
-
// */
|
|
361
|
-
// export function cmsToDelegateModel(data: any,
|
|
362
|
-
// buildReference: (reference: EntityReference) => any,
|
|
363
|
-
// buildGeoPoint: (geoPoint: GeoPoint) => any,
|
|
364
|
-
// buildDate: (date: Date) => any,
|
|
365
|
-
// buildDelete: () => any
|
|
366
|
-
// ): any {
|
|
367
|
-
// if (data === undefined) {
|
|
368
|
-
// return buildDelete();
|
|
369
|
-
// } else if (data === null) {
|
|
370
|
-
// return null;
|
|
371
|
-
// } else if (Array.isArray(data)) {
|
|
372
|
-
// return data.map(v => cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete));
|
|
373
|
-
// } else if (data.isEntityReference && data.isEntityReference()) {
|
|
374
|
-
// return buildReference(data);
|
|
375
|
-
// } else if (data instanceof GeoPoint) {
|
|
376
|
-
// return buildGeoPoint(data);
|
|
377
|
-
// } else if (data instanceof Date) {
|
|
378
|
-
// return buildDate(data);
|
|
379
|
-
// } else if (data && typeof data === "object") {
|
|
380
|
-
// return Object.entries(data)
|
|
381
|
-
// .map(([key, v]) => ({ [key]: cmsToDelegateModel(v, buildReference, buildGeoPoint, buildDate, buildDelete) }))
|
|
382
|
-
// .reduce((a, b) => ({ ...a, ...b }), {});
|
|
383
|
-
// }
|
|
384
|
-
// return data;
|
|
385
|
-
// }
|
|
@@ -115,6 +115,16 @@ export const useBuildSideEntityController = (navigation: NavigationController,
|
|
|
115
115
|
}
|
|
116
116
|
}, [location, navigation.loading, navigation.isUrlCollectionPath, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, sideDialogsController, smallLayout, navigation]);
|
|
117
117
|
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
const updatedSidePanels = sideDialogsController.sidePanels.map(sidePanelProps => {
|
|
120
|
+
if (sidePanelProps.additional) {
|
|
121
|
+
return propsToSidePanel(sidePanelProps.additional, navigation.buildUrlCollectionPath, navigation.resolveAliasesFrom, smallLayout);
|
|
122
|
+
}
|
|
123
|
+
return sidePanelProps;
|
|
124
|
+
});
|
|
125
|
+
sideDialogsController.setSidePanels(updatedSidePanels);
|
|
126
|
+
}, [smallLayout]);
|
|
127
|
+
|
|
118
128
|
const close = useCallback(() => {
|
|
119
129
|
sideDialogsController.close();
|
|
120
130
|
}, [sideDialogsController]);
|
|
@@ -210,7 +220,7 @@ export function buildSidePanelsFromUrl(path: string, collections: EntityCollecti
|
|
|
210
220
|
return sidePanels;
|
|
211
221
|
}
|
|
212
222
|
|
|
213
|
-
const propsToSidePanel = (props: EntitySidePanelProps
|
|
223
|
+
const propsToSidePanel = (props: EntitySidePanelProps,
|
|
214
224
|
buildUrlCollectionPath: (path: string) => string,
|
|
215
225
|
resolveAliasesFrom: (pathWithAliases: string) => string,
|
|
216
226
|
smallLayout: boolean): SideDialogPanelProps => {
|
|
@@ -235,7 +245,8 @@ const propsToSidePanel = (props: EntitySidePanelProps<any>,
|
|
|
235
245
|
urlPath: newPath,
|
|
236
246
|
parentUrlPath: buildUrlCollectionPath(collectionPath),
|
|
237
247
|
width: entityViewWidth,
|
|
238
|
-
onClose: props.onClose
|
|
248
|
+
onClose: props.onClose,
|
|
249
|
+
additional: props
|
|
239
250
|
};
|
|
240
251
|
}
|
|
241
252
|
;
|
|
@@ -21,7 +21,7 @@ export type ReferencePreviewProps = {
|
|
|
21
21
|
/**
|
|
22
22
|
* @group Preview components
|
|
23
23
|
*/
|
|
24
|
-
export const ReferencePreview =
|
|
24
|
+
export const ReferencePreview = function ReferencePreview(props: ReferencePreviewProps) {
|
|
25
25
|
const reference = props.reference;
|
|
26
26
|
if (!(typeof reference === "object" && "isEntityReference" in reference && reference.isEntityReference())) {
|
|
27
27
|
console.warn("Reference preview received value of type", typeof reference);
|
|
@@ -33,18 +33,7 @@ export const ReferencePreview = React.memo<ReferencePreviewProps>(function Refer
|
|
|
33
33
|
</EntityPreviewContainer>;
|
|
34
34
|
}
|
|
35
35
|
return <ReferencePreviewInternal {...props} />;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function areEqual(prevProps: ReferencePreviewProps, nextProps: ReferencePreviewProps) {
|
|
39
|
-
return prevProps.disabled === nextProps.disabled &&
|
|
40
|
-
prevProps.size === nextProps.size &&
|
|
41
|
-
prevProps.hover === nextProps.hover &&
|
|
42
|
-
prevProps.reference?.id === nextProps.reference?.id &&
|
|
43
|
-
prevProps.reference?.path === nextProps.reference?.path &&
|
|
44
|
-
prevProps.includeEntityLink === nextProps.includeEntityLink &&
|
|
45
|
-
prevProps.onClick === nextProps.onClick
|
|
46
|
-
;
|
|
47
|
-
}
|
|
36
|
+
};
|
|
48
37
|
|
|
49
38
|
function ReferencePreviewInternal({
|
|
50
39
|
disabled,
|
package/src/types/datasource.ts
CHANGED
|
@@ -64,6 +64,7 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
|
|
|
64
64
|
*/
|
|
65
65
|
export interface DeleteEntityProps<M extends Record<string, any> = any> {
|
|
66
66
|
entity: Entity<M>;
|
|
67
|
+
collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
/**
|
|
@@ -182,7 +183,8 @@ export interface DataSource {
|
|
|
182
183
|
*/
|
|
183
184
|
deleteEntity<M extends Record<string, any> = any>(
|
|
184
185
|
{
|
|
185
|
-
entity
|
|
186
|
+
entity,
|
|
187
|
+
collection
|
|
186
188
|
}: DeleteEntityProps<M>
|
|
187
189
|
): Promise<void>;
|
|
188
190
|
|
|
@@ -191,7 +193,7 @@ export interface DataSource {
|
|
|
191
193
|
* @param path Collection path
|
|
192
194
|
* @param name of the property
|
|
193
195
|
* @param value
|
|
194
|
-
* @param
|
|
196
|
+
* @param collection
|
|
195
197
|
* @param entityId
|
|
196
198
|
* @return `true` if there are no other fields besides the given entity
|
|
197
199
|
*/
|
|
@@ -200,13 +202,13 @@ export interface DataSource {
|
|
|
200
202
|
name: string,
|
|
201
203
|
value: any,
|
|
202
204
|
entityId?: string,
|
|
203
|
-
|
|
205
|
+
collection?: EntityCollection
|
|
204
206
|
): Promise<boolean>;
|
|
205
207
|
|
|
206
208
|
/**
|
|
207
209
|
* Generate an id for a new entity
|
|
208
210
|
*/
|
|
209
|
-
generateEntityId(path: string): string;
|
|
211
|
+
generateEntityId(path: string, collection: EntityCollection): string;
|
|
210
212
|
|
|
211
213
|
/**
|
|
212
214
|
* Count the number of entities in a collection
|
|
@@ -360,14 +362,15 @@ export interface DataSourceDelegate {
|
|
|
360
362
|
* @param name of the property
|
|
361
363
|
* @param value
|
|
362
364
|
* @param entityId
|
|
365
|
+
* @param collection
|
|
363
366
|
* @return `true` if there are no other fields besides the given entity
|
|
364
367
|
*/
|
|
365
|
-
checkUniqueField(path: string, name: string, value: any, entityId?: string,
|
|
368
|
+
checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection): Promise<boolean>;
|
|
366
369
|
|
|
367
370
|
/**
|
|
368
371
|
* Generate an id for a new entity
|
|
369
372
|
*/
|
|
370
|
-
generateEntityId(path: string): string;
|
|
373
|
+
generateEntityId(path: string, collection?: EntityCollection): string;
|
|
371
374
|
|
|
372
375
|
/**
|
|
373
376
|
* Count the number of entities in a collection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataSource } from "./datasource";
|
|
1
|
+
import { DataSource, DataSourceDelegate } from "./datasource";
|
|
2
2
|
import { StorageSource } from "./storage";
|
|
3
3
|
|
|
4
4
|
export type EntityOverrides = {
|
|
5
|
-
|
|
5
|
+
dataSourceDelegate?: DataSourceDelegate;
|
|
6
6
|
storageSource?: StorageSource;
|
|
7
7
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Controller to open the side dialog
|
|
3
5
|
* @group Hooks and utilities
|
|
@@ -14,6 +16,12 @@ export interface SideDialogsController {
|
|
|
14
16
|
*/
|
|
15
17
|
sidePanels: SideDialogPanelProps[];
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Override the current side panels
|
|
21
|
+
* @param panels
|
|
22
|
+
*/
|
|
23
|
+
setSidePanels: (panels: SideDialogPanelProps[]) => void;
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
26
|
* Open one or multiple side panels
|
|
19
27
|
* @param props
|
|
@@ -65,4 +73,9 @@ export interface SideDialogPanelProps {
|
|
|
65
73
|
* Callback when the panel is closed
|
|
66
74
|
*/
|
|
67
75
|
onClose?: () => void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Use this prop to store additional data in the panel
|
|
79
|
+
*/
|
|
80
|
+
additional?: any;
|
|
68
81
|
}
|
package/src/util/icons.tsx
CHANGED
|
@@ -22,7 +22,13 @@ export type IconViewProps = {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const IconForView = React.memo(
|
|
25
|
-
function IconForView({
|
|
25
|
+
function IconForView({
|
|
26
|
+
collectionOrView,
|
|
27
|
+
className,
|
|
28
|
+
size = "medium"
|
|
29
|
+
}: {
|
|
30
|
+
collectionOrView?: IconViewProps, className?: string, size?: "smallest" | "small" | "medium" | "large" | number,
|
|
31
|
+
}): React.ReactElement {
|
|
26
32
|
if (!collectionOrView) return <></>;
|
|
27
33
|
const icon = getIcon(collectionOrView.icon, className);
|
|
28
34
|
if (collectionOrView?.icon && icon)
|
|
@@ -45,7 +51,7 @@ export const IconForView = React.memo(
|
|
|
45
51
|
if (!key)
|
|
46
52
|
key = coolIconKeys[hashString(collectionOrView.path) % iconsCount];
|
|
47
53
|
|
|
48
|
-
return <Icon iconKey={key} size={
|
|
54
|
+
return <Icon iconKey={key} size={size} className={className}/>;
|
|
49
55
|
}, (prevProps, nextProps) => {
|
|
50
56
|
return equal(prevProps.collectionOrView?.icon, nextProps.collectionOrView?.icon);
|
|
51
57
|
});
|