@firecms/core 3.0.0-beta.2-pre.2 → 3.0.0-beta.2-pre.4
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/README.md +2 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +0 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -8
- package/dist/components/EntityCollectionTable/index.d.ts +2 -4
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/{ReferenceSelectionInner.d.ts → ReferenceTable/ReferenceSelectionTable.d.ts} +2 -2
- package/dist/components/{EntityCollectionTable/SimpleTable.d.ts → SelectableTable/SelectableTable.d.ts} +3 -4
- package/dist/components/SelectableTable/SelectableTableContext.d.ts +4 -0
- package/dist/components/common/index.d.ts +5 -0
- package/dist/components/{EntityCollectionTable → common}/types.d.ts +7 -0
- package/dist/components/common/useTableSearchHelper.d.ts +12 -0
- package/dist/components/index.d.ts +5 -2
- package/dist/form/EntityForm.d.ts +2 -0
- package/dist/form/components/index.d.ts +0 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/{internal → hooks}/useBuildNavigationController.d.ts +11 -4
- package/dist/hooks/useSnackbarController.d.ts +1 -0
- package/dist/index.es.js +4081 -4049
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/types/fields.d.ts +0 -1
- package/dist/types/firecms.d.ts +6 -25
- package/dist/types/navigation.d.ts +2 -2
- package/dist/types/plugins.d.ts +0 -8
- package/package.json +4 -4
- package/src/components/ArrayContainer.tsx +11 -4
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +16 -22
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +2 -2
- package/src/components/EntityCollectionTable/column_utils.tsx +1 -1
- package/src/components/EntityCollectionTable/index.tsx +1 -9
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +133 -136
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +20 -41
- package/src/components/{ReferenceSelectionInner.tsx → ReferenceTable/ReferenceSelectionTable.tsx} +31 -15
- package/src/components/{EntityCollectionTable/SimpleTable.tsx → SelectableTable/SelectableTable.tsx} +8 -9
- package/src/components/SelectableTable/SelectableTableContext.tsx +6 -0
- package/src/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.tsx +0 -1
- package/src/components/VirtualTable/VirtualTableHeader.tsx +10 -4
- package/src/components/common/index.ts +5 -0
- package/src/components/{EntityCollectionTable → common}/types.tsx +5 -0
- package/src/components/common/useTableSearchHelper.ts +47 -0
- package/src/components/index.tsx +6 -2
- package/src/core/EntitySidePanel.tsx +7 -5
- package/src/core/FireCMS.tsx +1 -16
- package/src/form/EntityForm.tsx +237 -196
- package/src/form/PropertyFieldBinding.tsx +7 -7
- package/src/form/components/CustomIdField.tsx +35 -34
- package/src/form/components/ErrorFocus.tsx +3 -3
- package/src/form/components/index.tsx +0 -1
- package/src/form/field_bindings/BlockFieldBinding.tsx +13 -12
- package/src/hooks/index.tsx +1 -0
- package/src/{internal → hooks}/useBuildNavigationController.tsx +23 -17
- package/src/hooks/useFireCMSContext.tsx +51 -3
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useSnackbarController.tsx +1 -2
- package/src/internal/useBuildSideEntityController.tsx +1 -1
- package/src/types/fields.tsx +1 -1
- package/src/types/firecms.tsx +7 -28
- package/src/types/navigation.ts +2 -2
- package/src/types/plugins.tsx +0 -9
- package/src/util/resolutions.ts +1 -1
- package/dist/form/components/SubmitListener.d.ts +0 -1
- package/dist/form/components/SwitchControl.d.ts +0 -8
- package/src/form/components/SubmitListener.tsx +0 -32
- package/src/form/components/SwitchControl.tsx +0 -39
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.d.ts +0 -0
- /package/dist/components/{EntityCollectionView → common}/useColumnsIds.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.d.ts +0 -0
- /package/dist/components/{EntityCollectionTable → common}/useDebouncedData.d.ts +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/BooleanFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/DateTimeFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionTable → SelectableTable}/filters/ReferenceFilterField.tsx +0 -0
- /package/src/components/{EntityCollectionView → common}/useColumnsIds.tsx +0 -0
- /package/src/components/{EntityCollectionTable → common}/useDataSourceEntityCollectionTableController.tsx +0 -0
- /package/src/components/{EntityCollectionTable → common}/useDebouncedData.ts +0 -0
|
@@ -16,14 +16,11 @@ import {
|
|
|
16
16
|
SelectionController
|
|
17
17
|
} from "../../types";
|
|
18
18
|
import {
|
|
19
|
+
EntityCollectionRowActions,
|
|
19
20
|
EntityCollectionTable,
|
|
20
|
-
|
|
21
|
-
OnColumnResizeParams,
|
|
22
|
-
UniqueFieldValidator
|
|
21
|
+
useDataSourceEntityCollectionTableController
|
|
23
22
|
} from "../EntityCollectionTable";
|
|
24
23
|
|
|
25
|
-
import { EntityCollectionRowActions } from "../EntityCollectionTable/EntityCollectionRowActions";
|
|
26
|
-
|
|
27
24
|
import {
|
|
28
25
|
canCreateEntity,
|
|
29
26
|
canDeleteEntity,
|
|
@@ -40,16 +37,12 @@ import {
|
|
|
40
37
|
useAuthController,
|
|
41
38
|
useCustomizationController,
|
|
42
39
|
useDataSource,
|
|
43
|
-
useFireCMSContext,
|
|
44
40
|
useLargeLayout,
|
|
45
41
|
useNavigationController,
|
|
46
42
|
useSideEntityController
|
|
47
43
|
} from "../../hooks";
|
|
48
44
|
import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
|
|
49
45
|
import { EntityCollectionViewActions } from "./EntityCollectionViewActions";
|
|
50
|
-
import {
|
|
51
|
-
useDataSourceEntityCollectionTableController
|
|
52
|
-
} from "../EntityCollectionTable/useDataSourceEntityCollectionTableController";
|
|
53
46
|
import {
|
|
54
47
|
AddIcon,
|
|
55
48
|
Button,
|
|
@@ -64,9 +57,15 @@ import {
|
|
|
64
57
|
Tooltip,
|
|
65
58
|
Typography
|
|
66
59
|
} from "@firecms/ui";
|
|
67
|
-
import { setIn } from "
|
|
60
|
+
import { setIn } from "@firecms/formex";
|
|
68
61
|
import { getSubcollectionColumnId } from "../EntityCollectionTable/internal/common";
|
|
69
|
-
import {
|
|
62
|
+
import {
|
|
63
|
+
OnCellValueChange,
|
|
64
|
+
OnColumnResizeParams,
|
|
65
|
+
UniqueFieldValidator,
|
|
66
|
+
useColumnIds,
|
|
67
|
+
useTableSearchHelper
|
|
68
|
+
} from "../common";
|
|
70
69
|
import { PopupFormField } from "../EntityCollectionTable/internal/popup_field/PopupFormField";
|
|
71
70
|
import { GetPropertyForProps } from "../EntityCollectionTable/EntityCollectionTableProps";
|
|
72
71
|
import {
|
|
@@ -130,7 +129,6 @@ export const EntityCollectionView = React.memo(
|
|
|
130
129
|
const userConfigPersistence = useUserConfigurationPersistence();
|
|
131
130
|
const analyticsController = useAnalyticsController();
|
|
132
131
|
const customizationController = useCustomizationController();
|
|
133
|
-
const context = useFireCMSContext();
|
|
134
132
|
|
|
135
133
|
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
136
134
|
|
|
@@ -148,7 +146,6 @@ export const EntityCollectionView = React.memo(
|
|
|
148
146
|
const [selectedNavigationEntity, setSelectedNavigationEntity] = useState<Entity<M> | undefined>(undefined);
|
|
149
147
|
const [deleteEntityClicked, setDeleteEntityClicked] = React.useState<Entity<M> | Entity<M>[] | undefined>(undefined);
|
|
150
148
|
|
|
151
|
-
const [textSearchLoading, setTextSearchLoading] = useState<boolean>(false);
|
|
152
149
|
const [lastDeleteTimestamp, setLastDeleteTimestamp] = React.useState<number>(0);
|
|
153
150
|
|
|
154
151
|
// number of entities in the collection
|
|
@@ -569,34 +566,16 @@ export const EntityCollectionView = React.memo(
|
|
|
569
566
|
}
|
|
570
567
|
: undefined;
|
|
571
568
|
|
|
572
|
-
const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (p.collectionView?.onTextSearchClick)
|
|
583
|
-
return p.collectionView.onTextSearchClick({ context, path: resolvedFullPath, collection, parentCollectionIds });
|
|
584
|
-
return Promise.resolve(true);
|
|
585
|
-
}) as Promise<boolean>[])
|
|
586
|
-
.then((res) => {
|
|
587
|
-
if (res.every(Boolean)) setTextSearchInitialised(true);
|
|
588
|
-
})
|
|
589
|
-
.finally(() => setTextSearchLoading(false));
|
|
590
|
-
}
|
|
591
|
-
: undefined;
|
|
592
|
-
|
|
593
|
-
customizationController.plugins?.forEach(p => {
|
|
594
|
-
if (!textSearchEnabled)
|
|
595
|
-
if (p.collectionView?.showTextSearchBar) {
|
|
596
|
-
textSearchEnabled = p.collectionView.showTextSearchBar({ context, path: resolvedFullPath, collection, parentCollectionIds });
|
|
597
|
-
}
|
|
598
|
-
})
|
|
599
|
-
}
|
|
569
|
+
const {
|
|
570
|
+
textSearchLoading,
|
|
571
|
+
textSearchInitialised,
|
|
572
|
+
onTextSearchClick,
|
|
573
|
+
textSearchEnabled
|
|
574
|
+
} = useTableSearchHelper({
|
|
575
|
+
collection,
|
|
576
|
+
fullPath: resolvedFullPath,
|
|
577
|
+
parentCollectionIds
|
|
578
|
+
});
|
|
600
579
|
|
|
601
580
|
return (
|
|
602
581
|
<div className={cn("overflow-hidden h-full w-full", className)}
|
package/src/components/{ReferenceSelectionInner.tsx → ReferenceTable/ReferenceSelectionTable.tsx}
RENAMED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React, { MouseEventHandler, useCallback, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { CollectionSize, Entity, EntityCollection, FilterValues } from "
|
|
2
|
+
import { CollectionSize, Entity, EntityCollection, FilterValues } from "../../types";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import {
|
|
5
|
+
EntityCollectionRowActions,
|
|
6
|
+
EntityCollectionTable,
|
|
7
|
+
useDataSourceEntityCollectionTableController
|
|
8
|
+
} from "../EntityCollectionTable";
|
|
6
9
|
import {
|
|
7
10
|
useAuthController,
|
|
8
11
|
useCustomizationController,
|
|
@@ -10,17 +13,14 @@ import {
|
|
|
10
13
|
useLargeLayout,
|
|
11
14
|
useNavigationController,
|
|
12
15
|
useSideEntityController
|
|
13
|
-
} from "
|
|
14
|
-
import { ErrorView } from "
|
|
16
|
+
} from "../../hooks";
|
|
17
|
+
import { ErrorView } from "../ErrorView";
|
|
15
18
|
import { AddIcon, Button, DialogActions, Typography } from "@firecms/ui";
|
|
16
|
-
import { canCreateEntity, fullPathToCollectionSegments, resolveCollection } from "
|
|
17
|
-
import { useSelectionController } from "
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
} from "
|
|
21
|
-
import { useColumnIds } from "./EntityCollectionView/useColumnsIds";
|
|
22
|
-
import { useSideDialogContext } from "../core";
|
|
23
|
-
import { useAnalyticsController } from "../hooks/useAnalyticsController";
|
|
19
|
+
import { canCreateEntity, fullPathToCollectionSegments, resolveCollection } from "../../util";
|
|
20
|
+
import { useSelectionController } from "../EntityCollectionView/EntityCollectionView";
|
|
21
|
+
import { useColumnIds, useTableSearchHelper } from "../common";
|
|
22
|
+
import { useSideDialogContext } from "../../core";
|
|
23
|
+
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @group Components
|
|
@@ -88,7 +88,7 @@ export interface ReferenceSelectionInnerProps<M extends Record<string, any>> {
|
|
|
88
88
|
* You probably want to open this dialog as a side view using {@link useReferenceDialog}
|
|
89
89
|
* @group Components
|
|
90
90
|
*/
|
|
91
|
-
export function
|
|
91
|
+
export function ReferenceSelectionTable<M extends Record<string, any>>(
|
|
92
92
|
{
|
|
93
93
|
onSingleEntitySelected,
|
|
94
94
|
onMultipleEntitiesSelected,
|
|
@@ -98,7 +98,7 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
98
98
|
selectedEntityIds: selectedEntityIdsProp,
|
|
99
99
|
description,
|
|
100
100
|
forceFilter,
|
|
101
|
-
maxSelection
|
|
101
|
+
maxSelection,
|
|
102
102
|
}: ReferenceSelectionInnerProps<M>) {
|
|
103
103
|
|
|
104
104
|
const sideDialogContext = useSideDialogContext();
|
|
@@ -266,6 +266,19 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
266
266
|
forceFilter
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
+
|
|
270
|
+
const {
|
|
271
|
+
textSearchLoading,
|
|
272
|
+
textSearchInitialised,
|
|
273
|
+
onTextSearchClick,
|
|
274
|
+
textSearchEnabled
|
|
275
|
+
} =
|
|
276
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
277
|
+
useTableSearchHelper({
|
|
278
|
+
collection,
|
|
279
|
+
fullPath,
|
|
280
|
+
});
|
|
281
|
+
|
|
269
282
|
return (
|
|
270
283
|
|
|
271
284
|
<div className="flex flex-col h-full">
|
|
@@ -273,6 +286,9 @@ export function ReferenceSelectionInner<M extends Record<string, any>>(
|
|
|
273
286
|
<div className="flex-grow">
|
|
274
287
|
{entitiesDisplayedFirst &&
|
|
275
288
|
<EntityCollectionTable
|
|
289
|
+
textSearchLoading={textSearchLoading}
|
|
290
|
+
onTextSearchClick={textSearchInitialised ? undefined : onTextSearchClick}
|
|
291
|
+
textSearchEnabled={textSearchEnabled}
|
|
276
292
|
displayedColumnIds={displayedColumnIds}
|
|
277
293
|
onEntityClick={onEntityClick}
|
|
278
294
|
tableController={tableController}
|
package/src/components/{EntityCollectionTable/SimpleTable.tsx → SelectableTable/SelectableTable.tsx}
RENAMED
|
@@ -10,17 +10,16 @@ import {
|
|
|
10
10
|
} from "../../types";
|
|
11
11
|
import { CellRendererParams, VirtualTable, VirtualTableColumn } from "../VirtualTable";
|
|
12
12
|
import { enumToObjectEntries } from "../../util";
|
|
13
|
-
import { OnCellValueChange } from "
|
|
14
|
-
import { OnColumnResizeParams } from "./EntityCollectionTableProps";
|
|
13
|
+
import { OnCellValueChange, OnColumnResizeParams } from "../common/types";
|
|
15
14
|
import { FilterFormFieldProps } from "../VirtualTable/VirtualTableHeader";
|
|
16
15
|
import { ReferenceFilterField } from "./filters/ReferenceFilterField";
|
|
17
16
|
import { StringNumberFilterField } from "./filters/StringNumberFilterField";
|
|
18
17
|
import { BooleanFilterField } from "./filters/BooleanFilterField";
|
|
19
18
|
import { DateTimeFilterField } from "./filters/DateTimeFilterField";
|
|
20
|
-
import { EntityCollectionTableContext } from "./EntityCollectionTable";
|
|
21
19
|
import { useOutsideAlerter } from "@firecms/ui";
|
|
20
|
+
import { SelectableTableContext } from "./SelectableTableContext";
|
|
22
21
|
|
|
23
|
-
export type
|
|
22
|
+
export type SelectableTableProps<M extends Record<string, any>> = {
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Callback when a cell value changes.
|
|
@@ -108,8 +107,8 @@ export type SimpleTableProps<M extends Record<string, any>> = {
|
|
|
108
107
|
* @see VirtualTable
|
|
109
108
|
* @group Components
|
|
110
109
|
*/
|
|
111
|
-
export const
|
|
112
|
-
function
|
|
110
|
+
export const SelectableTable = React.memo<SelectableTableProps<any>>(
|
|
111
|
+
function SelectableTable<M extends Record<string, any>>
|
|
113
112
|
({
|
|
114
113
|
onValueChange,
|
|
115
114
|
cellRenderer,
|
|
@@ -143,7 +142,7 @@ export const SimpleTable = React.memo<SimpleTableProps<any>>(
|
|
|
143
142
|
highlightedRow,
|
|
144
143
|
endAdornment,
|
|
145
144
|
AddColumnComponent
|
|
146
|
-
}:
|
|
145
|
+
}: SelectableTableProps<M>) {
|
|
147
146
|
|
|
148
147
|
const ref = useRef<HTMLDivElement>(null);
|
|
149
148
|
const [size, setSize] = React.useState<CollectionSize>("m");
|
|
@@ -203,7 +202,7 @@ export const SimpleTable = React.memo<SimpleTableProps<any>>(
|
|
|
203
202
|
}, [forceFilter]);
|
|
204
203
|
|
|
205
204
|
return (
|
|
206
|
-
<
|
|
205
|
+
<SelectableTableContext.Provider
|
|
207
206
|
value={{
|
|
208
207
|
setPopupCell: setPopupCell as ((cell?: SelectedCellProps<M>) => void),
|
|
209
208
|
select,
|
|
@@ -244,7 +243,7 @@ export const SimpleTable = React.memo<SimpleTableProps<any>>(
|
|
|
244
243
|
/>
|
|
245
244
|
|
|
246
245
|
</div>
|
|
247
|
-
</
|
|
246
|
+
</SelectableTableContext.Provider>
|
|
248
247
|
);
|
|
249
248
|
|
|
250
249
|
},
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import { EntityCollectionTableController } from "../common/types";
|
|
3
|
+
|
|
4
|
+
export const SelectableTableContext = React.createContext<EntityCollectionTableController<any>>({} as any);
|
|
5
|
+
|
|
6
|
+
export const useSelectableTableController = () => useContext<EntityCollectionTableController<any>>(SelectableTableContext);
|
package/src/components/{EntityCollectionTable → SelectableTable}/filters/StringNumberFilterField.tsx
RENAMED
|
@@ -112,7 +112,6 @@ export function StringNumberFilterField({
|
|
|
112
112
|
updateFilter(operation, val);
|
|
113
113
|
}}
|
|
114
114
|
endAdornment={internalValue && <IconButton
|
|
115
|
-
className="absolute right-3 top-2"
|
|
116
115
|
onClick={(e) => updateFilter(operation, undefined)}>
|
|
117
116
|
<ClearIcon/>
|
|
118
117
|
</IconButton>}
|
|
@@ -198,7 +198,7 @@ function FilterForm<M>({
|
|
|
198
198
|
onHover,
|
|
199
199
|
createFilterField,
|
|
200
200
|
hidden,
|
|
201
|
-
setHidden
|
|
201
|
+
setHidden
|
|
202
202
|
}: FilterFormProps<M>) {
|
|
203
203
|
|
|
204
204
|
const id = column.key;
|
|
@@ -232,7 +232,13 @@ function FilterForm<M>({
|
|
|
232
232
|
|
|
233
233
|
if (!filterField) return null;
|
|
234
234
|
return (
|
|
235
|
-
<
|
|
235
|
+
<form noValidate={true}
|
|
236
|
+
onSubmit={(e) => {
|
|
237
|
+
e.stopPropagation();
|
|
238
|
+
e.preventDefault();
|
|
239
|
+
submit();
|
|
240
|
+
}}
|
|
241
|
+
className={"text-gray-900 dark:text-white"}>
|
|
236
242
|
<div
|
|
237
243
|
className={cn(defaultBorderMixin, "py-4 px-6 text-xs font-semibold uppercase border-b")}>
|
|
238
244
|
{column.title ?? id}
|
|
@@ -252,9 +258,9 @@ function FilterForm<M>({
|
|
|
252
258
|
<Button
|
|
253
259
|
variant="outlined"
|
|
254
260
|
color="primary"
|
|
255
|
-
|
|
261
|
+
type="submit">Filter</Button>
|
|
256
262
|
</div>
|
|
257
|
-
</
|
|
263
|
+
</form>
|
|
258
264
|
);
|
|
259
265
|
|
|
260
266
|
}
|
|
@@ -56,3 +56,8 @@ export type UniqueFieldValidator = (props: {
|
|
|
56
56
|
* @group Collection components
|
|
57
57
|
*/
|
|
58
58
|
export type OnCellValueChange<T, M extends Record<string, any>> = (params: OnCellValueChangeParams<T, M>) => Promise<void> | void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @group Collection components
|
|
62
|
+
*/
|
|
63
|
+
export type OnColumnResizeParams = { width: number, key: string };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { EntityCollection } from "../../types";
|
|
4
|
+
import { useCustomizationController, useFireCMSContext } from "../../hooks";
|
|
5
|
+
|
|
6
|
+
export interface UseTableSearchHelperParams<M extends Record<string, any>> {
|
|
7
|
+
collection: EntityCollection<M>;
|
|
8
|
+
fullPath: string;
|
|
9
|
+
parentCollectionIds?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useTableSearchHelper<M extends Record<string, any>>({ collection, fullPath, parentCollectionIds }: UseTableSearchHelperParams<M>) {
|
|
13
|
+
|
|
14
|
+
const context = useFireCMSContext();
|
|
15
|
+
const customizationController = useCustomizationController();
|
|
16
|
+
|
|
17
|
+
const [textSearchLoading, setTextSearchLoading] = useState<boolean>(false);
|
|
18
|
+
const [textSearchInitialised, setTextSearchInitialised] = useState<boolean>(false);
|
|
19
|
+
let onTextSearchClick: (() => void) | undefined;
|
|
20
|
+
let textSearchEnabled = Boolean(collection.textSearchEnabled);
|
|
21
|
+
if (customizationController?.plugins) {
|
|
22
|
+
const addTextSearchClickListener = customizationController.plugins?.find(p => Boolean(p.collectionView?.onTextSearchClick));
|
|
23
|
+
|
|
24
|
+
onTextSearchClick = addTextSearchClickListener
|
|
25
|
+
? () => {
|
|
26
|
+
setTextSearchLoading(true);
|
|
27
|
+
Promise.all(customizationController.plugins?.map(p => {
|
|
28
|
+
if (p.collectionView?.onTextSearchClick)
|
|
29
|
+
return p.collectionView.onTextSearchClick({ context, path: fullPath, collection, parentCollectionIds });
|
|
30
|
+
return Promise.resolve(true);
|
|
31
|
+
}) as Promise<boolean>[])
|
|
32
|
+
.then((res) => {
|
|
33
|
+
if (res.every(Boolean)) setTextSearchInitialised(true);
|
|
34
|
+
})
|
|
35
|
+
.finally(() => setTextSearchLoading(false));
|
|
36
|
+
}
|
|
37
|
+
: undefined;
|
|
38
|
+
|
|
39
|
+
customizationController.plugins?.forEach(p => {
|
|
40
|
+
if (!textSearchEnabled)
|
|
41
|
+
if (p.collectionView?.showTextSearchBar) {
|
|
42
|
+
textSearchEnabled = p.collectionView.showTextSearchBar({ context, path: fullPath, collection, parentCollectionIds });
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
return { textSearchLoading, textSearchInitialised, onTextSearchClick, textSearchEnabled };
|
|
47
|
+
}
|
package/src/components/index.tsx
CHANGED
|
@@ -4,13 +4,17 @@ export { ErrorView } from "./ErrorView";
|
|
|
4
4
|
export type { EntityPreviewProps } from "./EntityPreview";
|
|
5
5
|
export { EntityPreview } from "./EntityPreview";
|
|
6
6
|
|
|
7
|
-
export type { ReferenceSelectionInnerProps } from "./
|
|
8
|
-
export {
|
|
7
|
+
export type { ReferenceSelectionInnerProps } from "./ReferenceTable/ReferenceSelectionTable";
|
|
8
|
+
export { ReferenceSelectionTable } from "./ReferenceTable/ReferenceSelectionTable";
|
|
9
9
|
|
|
10
10
|
export { CircularProgressCenter } from "./CircularProgressCenter";
|
|
11
11
|
|
|
12
|
+
export * from "./common";
|
|
13
|
+
|
|
12
14
|
export * from "./HomePage";
|
|
15
|
+
export * from "./SelectableTable/SelectableTable";
|
|
13
16
|
export * from "./EntityCollectionView/EntityCollectionView";
|
|
17
|
+
export * from "./EntityCollectionView/EntityCollectionViewActions";
|
|
14
18
|
|
|
15
19
|
export * from "./PropertyConfigBadge";
|
|
16
20
|
|
|
@@ -33,13 +33,15 @@ export function EntitySidePanel(props: EntitySidePanelProps) {
|
|
|
33
33
|
if (!props) return undefined;
|
|
34
34
|
let usedCollection = props.collection;
|
|
35
35
|
|
|
36
|
+
const registryCollection = navigationController.getCollection(props.path, props.entityId);
|
|
37
|
+
if (registryCollection) {
|
|
38
|
+
usedCollection = registryCollection;
|
|
39
|
+
}
|
|
36
40
|
if (!usedCollection) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
|
|
40
|
-
throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
|
|
41
|
-
}
|
|
41
|
+
console.error("ERROR: No collection found in path `", props.path, "`. Entity id: ", props.entityId);
|
|
42
|
+
throw Error("ERROR: No collection found in path `" + props.path + "`. Make sure you have defined a collection for this path in the root navigation.");
|
|
42
43
|
}
|
|
44
|
+
|
|
43
45
|
return usedCollection;
|
|
44
46
|
}, [navigationController, props]);
|
|
45
47
|
|
package/src/core/FireCMS.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import { SideDialogsControllerContext } from "../contexts/SideDialogsControllerC
|
|
|
15
15
|
import { useLocaleConfig } from "../internal/useLocaleConfig";
|
|
16
16
|
import { CenteredView } from "@firecms/ui";
|
|
17
17
|
import { DialogsProvider } from "../contexts/DialogsProvider";
|
|
18
|
-
import { useBuildNavigationController } from "../internal/useBuildNavigationController";
|
|
19
18
|
import { useBuildDataSource } from "../internal/useBuildDataSource";
|
|
20
19
|
import { useBuildCustomizationController } from "../internal/useBuildCustomizationController";
|
|
21
20
|
import { CustomizationControllerContext } from "../contexts/CustomizationControllerContext";
|
|
@@ -50,25 +49,11 @@ export function FireCMS<UserType extends User, EC extends EntityCollection>(prop
|
|
|
50
49
|
propertyConfigs,
|
|
51
50
|
entityViews,
|
|
52
51
|
components,
|
|
53
|
-
|
|
54
|
-
basePath,
|
|
55
|
-
collections,
|
|
56
|
-
views
|
|
52
|
+
navigationController,
|
|
57
53
|
} = props;
|
|
58
54
|
|
|
59
55
|
useLocaleConfig(locale);
|
|
60
56
|
|
|
61
|
-
const navigationController = useBuildNavigationController({
|
|
62
|
-
basePath,
|
|
63
|
-
baseCollectionPath,
|
|
64
|
-
authController,
|
|
65
|
-
collections,
|
|
66
|
-
views,
|
|
67
|
-
userConfigPersistence,
|
|
68
|
-
dataSource: dataSourceDelegate,
|
|
69
|
-
plugins
|
|
70
|
-
});
|
|
71
|
-
|
|
72
57
|
/**
|
|
73
58
|
* Controller in charge of fetching and persisting data
|
|
74
59
|
*/
|