@firecms/core 3.0.0-canary.1 → 3.0.0-canary.100
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 -2
- package/dist/app/AppBar.d.ts +12 -0
- package/dist/app/Drawer.d.ts +17 -0
- package/dist/app/Scaffold.d.ts +30 -0
- package/dist/app/index.d.ts +4 -0
- package/dist/app/useApp.d.ts +16 -0
- package/dist/components/CircularProgressCenter.d.ts +1 -1
- package/dist/components/ClearFilterSortButton.d.ts +5 -0
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +11 -12
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -2
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +5 -3
- package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +3 -2
- package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -4
- package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +13 -4
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +11 -0
- package/dist/components/EntityCollectionView/useSelectionController.d.ts +2 -0
- package/dist/components/EntityPreview.d.ts +26 -7
- package/dist/components/EntityView.d.ts +11 -0
- package/dist/components/ErrorView.d.ts +1 -1
- package/dist/components/FieldCaption.d.ts +5 -0
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/NavigationCard.d.ts +8 -0
- package/dist/components/HomePage/{NavigationCollectionCard.d.ts → NavigationCardBinding.d.ts} +3 -3
- package/dist/components/HomePage/SmallNavigationCard.d.ts +6 -0
- package/dist/components/HomePage/index.d.ts +3 -1
- package/dist/components/ReferenceWidget.d.ts +6 -4
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/VirtualTable/VirtualTableProps.d.ts +16 -13
- package/dist/components/VirtualTable/types.d.ts +3 -3
- package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/common/table_height.d.ts +5 -0
- package/dist/components/common/types.d.ts +4 -6
- package/dist/components/common/useColumnsIds.d.ts +2 -1
- package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
- package/dist/components/index.d.ts +6 -4
- package/dist/contexts/AuthControllerContext.d.ts +1 -1
- package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +6 -9
- package/dist/core/DefaultDrawer.d.ts +19 -0
- package/dist/core/DrawerNavigationItem.d.ts +9 -0
- package/dist/core/EntityEditView.d.ts +36 -0
- package/dist/core/FireCMS.d.ts +1 -1
- package/dist/core/NavigationRoutes.d.ts +3 -3
- package/dist/core/index.d.ts +3 -6
- package/dist/form/PropertiesForm.d.ts +8 -0
- package/dist/form/PropertyFieldBinding.d.ts +1 -1
- package/dist/form/components/ErrorFocus.d.ts +1 -1
- package/dist/form/components/FieldHelperText.d.ts +3 -3
- package/dist/form/components/StorageItemPreview.d.ts +4 -3
- package/dist/form/components/StorageUploadProgress.d.ts +1 -1
- package/dist/form/components/index.d.ts +1 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -4
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -2
- package/dist/form/index.d.ts +1 -2
- package/dist/form/validation.d.ts +1 -1
- package/dist/hooks/data/delete.d.ts +2 -2
- package/dist/hooks/data/save.d.ts +2 -3
- package/dist/hooks/data/useDataSource.d.ts +2 -2
- package/dist/hooks/data/useEntityFetch.d.ts +3 -3
- package/dist/hooks/index.d.ts +4 -1
- package/dist/{core → hooks}/useBuildModeController.d.ts +1 -1
- package/dist/hooks/useBuildNavigationController.d.ts +6 -4
- package/dist/hooks/useProjectLog.d.ts +6 -2
- package/dist/hooks/useStorageSource.d.ts +2 -2
- package/dist/hooks/useValidateAuthenticator.d.ts +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +16400 -12423
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +19713 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/internal/useBuildDataSource.d.ts +1 -12
- package/dist/preview/PropertyPreview.d.ts +1 -1
- package/dist/preview/PropertyPreviewProps.d.ts +6 -4
- package/dist/preview/components/BooleanPreview.d.ts +5 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ReferencePreview.d.ts +3 -8
- package/dist/preview/components/StorageThumbnail.d.ts +2 -1
- package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/auth.d.ts +38 -2
- package/dist/types/collections.d.ts +45 -8
- package/dist/types/datasource.d.ts +34 -20
- package/dist/types/entities.d.ts +6 -1
- package/dist/types/entity_actions.d.ts +14 -0
- package/dist/types/entity_callbacks.d.ts +2 -2
- package/dist/types/entity_overrides.d.ts +6 -0
- package/dist/types/fields.d.ts +36 -30
- package/dist/types/index.d.ts +2 -1
- package/dist/types/navigation.d.ts +15 -14
- package/dist/types/permissions.d.ts +5 -1
- package/dist/types/plugins.d.ts +31 -23
- package/dist/types/properties.d.ts +34 -21
- package/dist/types/property_config.d.ts +2 -2
- package/dist/types/roles.d.ts +31 -0
- package/dist/types/storage.d.ts +11 -3
- package/dist/types/user.d.ts +5 -0
- package/dist/util/collections.d.ts +9 -1
- package/dist/util/entities.d.ts +1 -1
- package/dist/util/icon_list.d.ts +5 -1
- package/dist/util/icon_synonyms.d.ts +1 -97
- package/dist/util/icons.d.ts +9 -3
- package/dist/util/index.d.ts +1 -0
- package/dist/util/navigation_utils.d.ts +2 -2
- package/dist/util/objects.d.ts +1 -1
- package/dist/util/permissions.d.ts +4 -4
- package/dist/util/plurals.d.ts +0 -2
- package/dist/util/references.d.ts +4 -2
- package/dist/util/resolutions.d.ts +15 -14
- package/dist/util/storage.d.ts +23 -2
- package/dist/util/useStorageUploadController.d.ts +1 -1
- package/dist/util/useTraceUpdate.d.ts +1 -0
- package/package.json +128 -119
- package/src/app/AppBar.tsx +18 -0
- package/src/app/Drawer.tsx +25 -0
- package/src/app/Scaffold.tsx +251 -0
- package/src/app/index.ts +4 -0
- package/src/app/useApp.tsx +32 -0
- package/src/components/ArrayContainer.tsx +1 -1
- package/src/components/CircularProgressCenter.tsx +1 -1
- package/src/components/ClearFilterSortButton.tsx +41 -0
- package/src/components/DeleteEntityDialog.tsx +4 -4
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +11 -21
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +276 -279
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
- package/src/components/EntityCollectionTable/PropertyTableCell.tsx +49 -45
- package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +20 -18
- package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +17 -9
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +29 -34
- package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +16 -12
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -5
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +95 -92
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +5 -6
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +68 -0
- package/src/components/EntityCollectionView/useSelectionController.tsx +42 -0
- package/src/components/EntityPreview.tsx +210 -70
- package/src/components/EntityView.tsx +84 -0
- package/src/components/ErrorView.tsx +1 -1
- package/src/components/FieldCaption.tsx +14 -0
- package/src/components/HomePage/DefaultHomePage.tsx +37 -24
- package/src/components/HomePage/NavigationCard.tsx +69 -0
- package/src/components/HomePage/NavigationCardBinding.tsx +116 -0
- package/src/components/HomePage/SmallNavigationCard.tsx +45 -0
- package/src/components/HomePage/index.tsx +3 -1
- package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +4 -4
- package/src/components/ReferenceWidget.tsx +26 -16
- package/src/components/SearchIconsView.tsx +9 -6
- package/src/components/SelectableTable/SelectableTable.tsx +7 -7
- package/src/components/SelectableTable/filters/BooleanFilterField.tsx +2 -3
- package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +22 -7
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -24
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +35 -15
- package/src/components/VirtualTable/VirtualTable.tsx +70 -37
- package/src/components/VirtualTable/VirtualTableCell.tsx +1 -1
- package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
- package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
- package/src/components/VirtualTable/VirtualTableProps.tsx +19 -15
- package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
- package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +1 -1
- package/src/components/VirtualTable/types.tsx +2 -3
- package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +11 -7
- package/src/components/common/index.ts +1 -0
- package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
- package/src/components/common/types.tsx +4 -6
- package/src/components/common/useColumnsIds.tsx +23 -2
- package/src/components/common/useDataSourceEntityCollectionTableController.tsx +12 -1
- package/src/components/common/useTableSearchHelper.ts +52 -12
- package/src/components/index.tsx +6 -4
- package/src/contexts/AuthControllerContext.tsx +1 -1
- package/src/contexts/DialogsProvider.tsx +2 -2
- package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +60 -37
- package/src/core/DefaultDrawer.tsx +177 -0
- package/src/core/DrawerNavigationItem.tsx +62 -0
- package/src/core/EntityEditView.tsx +1130 -0
- package/src/core/EntitySidePanel.tsx +3 -4
- package/src/core/FireCMS.tsx +55 -44
- package/src/core/NavigationRoutes.tsx +15 -8
- package/src/core/SideDialogs.tsx +1 -0
- package/src/core/field_configs.tsx +2 -3
- package/src/core/index.tsx +3 -6
- package/src/form/PropertiesForm.tsx +81 -0
- package/src/form/PropertyFieldBinding.tsx +38 -9
- package/src/form/components/FieldHelperText.tsx +3 -3
- package/src/form/components/StorageItemPreview.tsx +21 -10
- package/src/form/components/StorageUploadProgress.tsx +9 -8
- package/src/form/components/index.tsx +1 -0
- package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +10 -8
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +18 -18
- package/src/form/field_bindings/BlockFieldBinding.tsx +4 -5
- package/src/form/field_bindings/DateTimeFieldBinding.tsx +3 -3
- package/src/form/field_bindings/KeyValueFieldBinding.tsx +62 -57
- package/src/form/field_bindings/MapFieldBinding.tsx +28 -20
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +3 -4
- package/src/form/field_bindings/MultiSelectBinding.tsx +2 -3
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +4 -11
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +21 -17
- package/src/form/field_bindings/RepeatFieldBinding.tsx +14 -11
- package/src/form/field_bindings/SelectFieldBinding.tsx +5 -6
- package/src/form/field_bindings/StorageUploadFieldBinding.tsx +28 -40
- package/src/form/field_bindings/SwitchFieldBinding.tsx +3 -4
- package/src/form/field_bindings/TextFieldBinding.tsx +10 -9
- package/src/form/index.tsx +5 -4
- package/src/form/validation.ts +4 -21
- package/src/hooks/data/delete.ts +3 -3
- package/src/hooks/data/save.ts +4 -2
- package/src/hooks/data/useCollectionFetch.tsx +1 -1
- package/src/hooks/data/useDataSource.tsx +7 -2
- package/src/hooks/data/useEntityFetch.tsx +4 -4
- package/src/hooks/index.tsx +6 -1
- package/src/{core → hooks}/useBuildLocalConfigurationPersistence.tsx +8 -10
- package/src/{core → hooks}/useBuildModeController.tsx +12 -6
- package/src/hooks/useBuildNavigationController.tsx +208 -92
- package/src/hooks/useProjectLog.tsx +30 -9
- package/src/hooks/useReferenceDialog.tsx +2 -2
- package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
- package/src/hooks/useStorageSource.tsx +7 -2
- package/src/hooks/useValidateAuthenticator.tsx +115 -0
- package/src/index.ts +1 -0
- package/src/internal/useBuildDataSource.ts +56 -44
- package/src/internal/useBuildSideEntityController.tsx +88 -21
- package/src/preview/PropertyPreview.tsx +11 -18
- package/src/preview/PropertyPreviewProps.tsx +4 -8
- package/src/preview/components/BooleanPreview.tsx +19 -4
- package/src/preview/components/EnumValuesChip.tsx +2 -2
- package/src/preview/components/ImagePreview.tsx +21 -33
- package/src/preview/components/ReferencePreview.tsx +74 -166
- package/src/preview/components/StorageThumbnail.tsx +5 -1
- package/src/preview/components/UrlComponentPreview.tsx +44 -11
- package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
- package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
- package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
- package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
- package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
- package/src/preview/property_previews/StringPropertyPreview.tsx +8 -7
- package/src/types/analytics.ts +1 -0
- package/src/types/auth.tsx +51 -2
- package/src/types/collections.ts +52 -8
- package/src/types/customization_controller.tsx +0 -1
- package/src/types/datasource.ts +41 -24
- package/src/types/entities.ts +13 -1
- package/src/types/entity_actions.tsx +17 -0
- package/src/types/entity_callbacks.ts +2 -2
- package/src/types/entity_overrides.tsx +7 -0
- package/src/types/fields.tsx +39 -33
- package/src/types/firecms.tsx +0 -1
- package/src/types/index.ts +2 -1
- package/src/types/navigation.ts +17 -17
- package/src/types/permissions.ts +6 -1
- package/src/types/plugins.tsx +38 -31
- package/src/types/properties.ts +40 -22
- package/src/types/property_config.tsx +2 -2
- package/src/types/roles.ts +41 -0
- package/src/types/side_entity_controller.tsx +1 -0
- package/src/types/storage.ts +12 -3
- package/src/types/user.ts +7 -0
- package/src/util/collections.ts +22 -0
- package/src/util/entities.ts +5 -4
- package/src/util/enums.ts +1 -1
- package/src/util/icon_list.ts +15 -10
- package/src/util/icon_synonyms.ts +3 -99
- package/src/util/icons.tsx +11 -3
- package/src/util/index.ts +1 -0
- package/src/util/navigation_utils.ts +6 -6
- package/src/util/objects.ts +25 -28
- package/src/util/permissions.ts +12 -8
- package/src/util/plurals.ts +0 -2
- package/src/util/references.ts +36 -5
- package/src/util/resolutions.ts +44 -39
- package/src/util/storage.ts +75 -21
- package/src/util/strings.ts +2 -2
- package/src/util/useStorageUploadController.tsx +21 -3
- package/src/util/useTraceUpdate.tsx +2 -1
- package/dist/components/VirtualTable/common.d.ts +0 -2
- package/dist/core/Drawer.d.ts +0 -23
- package/dist/core/Scaffold.d.ts +0 -55
- package/dist/form/EntityForm.d.ts +0 -77
- package/dist/internal/EntityView.d.ts +0 -22
- package/dist/internal/useBuildCustomizationController.d.ts +0 -2
- package/dist/internal/useLocaleConfig.d.ts +0 -1
- package/dist/types/appcheck.d.ts +0 -26
- package/src/components/HomePage/NavigationCollectionCard.tsx +0 -146
- package/src/core/Drawer.tsx +0 -164
- package/src/core/Scaffold.tsx +0 -281
- package/src/form/EntityForm.tsx +0 -720
- package/src/internal/EntityView.tsx +0 -578
- package/src/internal/useBuildCustomizationController.tsx +0 -5
- package/src/internal/useLocaleConfig.tsx +0 -18
- package/src/types/appcheck.ts +0 -29
- /package/dist/{components → form/components}/LabelWithIcon.d.ts +0 -0
- /package/dist/{core → hooks}/useBuildLocalConfigurationPersistence.d.ts +0 -0
- /package/src/{components → form/components}/LabelWithIcon.tsx +0 -0
|
@@ -2,10 +2,9 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
|
2
2
|
|
|
3
3
|
import useMeasure from "react-use-measure";
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { getRowHeight } from "../../VirtualTable/common";
|
|
7
|
-
import { cn, RemoveCircleIcon, Tooltip } from "@firecms/ui";
|
|
5
|
+
import { cls, RemoveCircleIcon, Tooltip } from "@firecms/ui";
|
|
8
6
|
import { ErrorBoundary } from "../../../components";
|
|
7
|
+
import { getRowHeight, TableSize } from "../../common/table_height";
|
|
9
8
|
|
|
10
9
|
interface EntityTableCellProps {
|
|
11
10
|
children: React.ReactNode;
|
|
@@ -19,7 +18,7 @@ interface EntityTableCellProps {
|
|
|
19
18
|
error?: Error;
|
|
20
19
|
allowScroll?: boolean;
|
|
21
20
|
align: "right" | "left" | "center";
|
|
22
|
-
size:
|
|
21
|
+
size: TableSize;
|
|
23
22
|
disabledTooltip?: string;
|
|
24
23
|
width: number;
|
|
25
24
|
showExpandIcon?: boolean;
|
|
@@ -47,7 +46,7 @@ const TableCellInner = ({
|
|
|
47
46
|
}: TableCellInnerProps) => {
|
|
48
47
|
return (
|
|
49
48
|
<div
|
|
50
|
-
className={
|
|
49
|
+
className={cls("flex flex-col max-h-full w-full",
|
|
51
50
|
{
|
|
52
51
|
"items-start": faded || scrollable
|
|
53
52
|
})}
|
|
@@ -96,7 +95,7 @@ export const EntityTableCell = React.memo<EntityTableCellProps>(
|
|
|
96
95
|
const [onHover, setOnHover] = useState(false);
|
|
97
96
|
const [internalSaved, setInternalSaved] = useState(saved);
|
|
98
97
|
|
|
99
|
-
const showError = !disabled && error;
|
|
98
|
+
const showError = !disabled && Boolean(error);
|
|
100
99
|
|
|
101
100
|
useEffect(() => {
|
|
102
101
|
if (saved) {
|
|
@@ -176,21 +175,26 @@ export const EntityTableCell = React.memo<EntityTableCellProps>(
|
|
|
176
175
|
const setOnHoverTrue = useCallback(() => setOnHover(true), []);
|
|
177
176
|
const setOnHoverFalse = useCallback(() => setOnHover(false), []);
|
|
178
177
|
|
|
178
|
+
const borderClass = showError
|
|
179
|
+
? "border-red-500"
|
|
180
|
+
: internalSaved
|
|
181
|
+
? "border-green-500"
|
|
182
|
+
: isSelected
|
|
183
|
+
? "border-primary"
|
|
184
|
+
: "border-transparent";
|
|
185
|
+
|
|
179
186
|
return (
|
|
180
187
|
<div
|
|
181
|
-
|
|
182
|
-
className={cn(
|
|
188
|
+
className={cls(
|
|
183
189
|
"transition-colors duration-100 ease-in-out",
|
|
184
190
|
`flex relative h-full rounded-md p-${p} border border-4 border-opacity-75`,
|
|
185
191
|
onHover && !disabled ? "bg-gray-50 dark:bg-gray-900" : "",
|
|
186
192
|
saved ? "bg-gray-100 bg-opacity-75 dark:bg-gray-800 dark:bg-opacity-75" : "",
|
|
187
|
-
!isSelected && !internalSaved && !showError ? "border-transparent" : "",
|
|
188
193
|
hideOverflow ? "overflow-hidden" : "",
|
|
189
194
|
isSelected ? "bg-gray-50 dark:bg-gray-900" : "",
|
|
190
|
-
|
|
191
|
-
internalSaved ? "border-green-500 " : "",
|
|
192
|
-
showError ? "border-red-500" : ""
|
|
195
|
+
borderClass
|
|
193
196
|
)}
|
|
197
|
+
ref={ref}
|
|
194
198
|
style={{
|
|
195
199
|
justifyContent,
|
|
196
200
|
alignItems: disabled || !isOverflowing ? "center" : undefined,
|
|
@@ -41,7 +41,7 @@ interface PopupFormFieldProps<M extends Record<string, any>> {
|
|
|
41
41
|
* Callback when the value of a cell has been edited
|
|
42
42
|
* @param params
|
|
43
43
|
*/
|
|
44
|
-
onCellValueChange?: (params: OnCellValueChangeParams<any,
|
|
44
|
+
onCellValueChange?: (params: OnCellValueChangeParams<any, any>) => Promise<void> | void;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function PopupFormField<M extends Record<string, any>>(props: PopupFormFieldProps<M>) {
|
|
@@ -205,12 +205,10 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
|
|
|
205
205
|
return onCellValueChange({
|
|
206
206
|
value: values[propertyKey as string],
|
|
207
207
|
propertyKey: propertyKey as string,
|
|
208
|
-
entity,
|
|
208
|
+
data: entity,
|
|
209
209
|
setError: setSavingError,
|
|
210
210
|
onValueUpdated: () => {
|
|
211
211
|
},
|
|
212
|
-
fullPath: path,
|
|
213
|
-
context: fireCMSContext
|
|
214
212
|
});
|
|
215
213
|
}
|
|
216
214
|
return Promise.resolve();
|
|
@@ -266,7 +264,8 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
|
|
|
266
264
|
values,
|
|
267
265
|
path,
|
|
268
266
|
setFieldValue,
|
|
269
|
-
save: saveValue
|
|
267
|
+
save: saveValue,
|
|
268
|
+
formex
|
|
270
269
|
};
|
|
271
270
|
|
|
272
271
|
const property: ResolvedProperty<any> | undefined = propertyKey && getPropertyInPath(collection.properties, propertyKey as string);
|
|
@@ -7,13 +7,12 @@ import {
|
|
|
7
7
|
CollectionSize,
|
|
8
8
|
Entity,
|
|
9
9
|
EntityAction,
|
|
10
|
-
EntityCollection,
|
|
10
|
+
EntityCollection, EntityTableController,
|
|
11
11
|
FilterValues,
|
|
12
12
|
PartialEntityCollection,
|
|
13
13
|
PropertyOrBuilder,
|
|
14
14
|
ResolvedProperty,
|
|
15
|
-
SaveEntityProps
|
|
16
|
-
SelectionController
|
|
15
|
+
SaveEntityProps
|
|
17
16
|
} from "../../types";
|
|
18
17
|
import {
|
|
19
18
|
EntityCollectionRowActions,
|
|
@@ -25,7 +24,6 @@ import {
|
|
|
25
24
|
canCreateEntity,
|
|
26
25
|
canDeleteEntity,
|
|
27
26
|
canEditEntity,
|
|
28
|
-
fullPathToCollectionSegments,
|
|
29
27
|
getPropertyInPath,
|
|
30
28
|
mergeDeep,
|
|
31
29
|
resolveCollection,
|
|
@@ -37,6 +35,7 @@ import {
|
|
|
37
35
|
useAuthController,
|
|
38
36
|
useCustomizationController,
|
|
39
37
|
useDataSource,
|
|
38
|
+
useFireCMSContext,
|
|
40
39
|
useLargeLayout,
|
|
41
40
|
useNavigationController,
|
|
42
41
|
useSideEntityController
|
|
@@ -46,7 +45,7 @@ import { EntityCollectionViewActions } from "./EntityCollectionViewActions";
|
|
|
46
45
|
import {
|
|
47
46
|
AddIcon,
|
|
48
47
|
Button,
|
|
49
|
-
|
|
48
|
+
cls,
|
|
50
49
|
IconButton,
|
|
51
50
|
KeyboardTabIcon,
|
|
52
51
|
Markdown,
|
|
@@ -67,13 +66,11 @@ import {
|
|
|
67
66
|
} from "../common";
|
|
68
67
|
import { PopupFormField } from "../EntityCollectionTable/internal/popup_field/PopupFormField";
|
|
69
68
|
import { GetPropertyForProps } from "../EntityCollectionTable/EntityCollectionTableProps";
|
|
70
|
-
import {
|
|
71
|
-
copyEntityAction,
|
|
72
|
-
deleteEntityAction,
|
|
73
|
-
editEntityAction
|
|
74
|
-
} from "../EntityCollectionTable/internal/default_entity_actions";
|
|
69
|
+
import { copyEntityAction, deleteEntityAction, editEntityAction } from "../common/default_entity_actions";
|
|
75
70
|
import { DeleteEntityDialog } from "../DeleteEntityDialog";
|
|
76
71
|
import { useAnalyticsController } from "../../hooks/useAnalyticsController";
|
|
72
|
+
import { useSelectionController } from "./useSelectionController";
|
|
73
|
+
import { EntityCollectionViewStartActions } from "./EntityCollectionViewStartActions";
|
|
77
74
|
|
|
78
75
|
const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
|
|
79
76
|
|
|
@@ -81,10 +78,22 @@ const COLLECTION_GROUP_PARENT_ID = "collectionGroupParent";
|
|
|
81
78
|
* @group Components
|
|
82
79
|
*/
|
|
83
80
|
export type EntityCollectionViewProps<M extends Record<string, any>> = {
|
|
84
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Complete path where this collection is located.
|
|
83
|
+
* It defaults to the collection path if not provided.
|
|
84
|
+
*/
|
|
85
|
+
fullPath?: string;
|
|
86
|
+
/**
|
|
87
|
+
* If this is a subcollection, specify the parent collection ids.
|
|
88
|
+
*/
|
|
85
89
|
parentCollectionIds?: string[];
|
|
90
|
+
/**
|
|
91
|
+
* Whether this is a subcollection or not.
|
|
92
|
+
*/
|
|
86
93
|
isSubCollection?: boolean;
|
|
94
|
+
|
|
87
95
|
className?: string;
|
|
96
|
+
|
|
88
97
|
} & EntityCollection<M>;
|
|
89
98
|
|
|
90
99
|
/**
|
|
@@ -108,12 +117,12 @@ export type EntityCollectionViewProps<M extends Record<string, any>> = {
|
|
|
108
117
|
*
|
|
109
118
|
* @param fullPath
|
|
110
119
|
* @param collection
|
|
111
|
-
|
|
120
|
+
|
|
112
121
|
* @group Components
|
|
113
122
|
*/
|
|
114
123
|
export const EntityCollectionView = React.memo(
|
|
115
124
|
function EntityCollectionView<M extends Record<string, any>>({
|
|
116
|
-
fullPath,
|
|
125
|
+
fullPath: fullPathProp,
|
|
117
126
|
parentCollectionIds,
|
|
118
127
|
isSubCollection,
|
|
119
128
|
className,
|
|
@@ -121,7 +130,9 @@ export const EntityCollectionView = React.memo(
|
|
|
121
130
|
}: EntityCollectionViewProps<M>
|
|
122
131
|
) {
|
|
123
132
|
|
|
124
|
-
const
|
|
133
|
+
const context = useFireCMSContext();
|
|
134
|
+
const fullPath = fullPathProp ?? collectionProp.path;
|
|
135
|
+
const dataSource = useDataSource(collectionProp);
|
|
125
136
|
const navigation = useNavigationController();
|
|
126
137
|
const sideEntityController = useSideEntityController();
|
|
127
138
|
const authController = useAuthController();
|
|
@@ -141,8 +152,8 @@ export const EntityCollectionView = React.memo(
|
|
|
141
152
|
collectionRef.current = collection;
|
|
142
153
|
}, [collection]);
|
|
143
154
|
|
|
144
|
-
const canCreateEntities = canCreateEntity(collection, authController,
|
|
145
|
-
const [
|
|
155
|
+
const canCreateEntities = canCreateEntity(collection, authController, fullPath, null);
|
|
156
|
+
const [highlightedEntity, setHighlightedEntity] = useState<Entity<M> | undefined>(undefined);
|
|
146
157
|
const [deleteEntityClicked, setDeleteEntityClicked] = React.useState<Entity<M> | Entity<M>[] | undefined>(undefined);
|
|
147
158
|
|
|
148
159
|
const [lastDeleteTimestamp, setLastDeleteTimestamp] = React.useState<number>(0);
|
|
@@ -151,16 +162,16 @@ export const EntityCollectionView = React.memo(
|
|
|
151
162
|
const [docsCount, setDocsCount] = useState<number>(0);
|
|
152
163
|
|
|
153
164
|
const unselectNavigatedEntity = useCallback(() => {
|
|
154
|
-
const currentSelection =
|
|
165
|
+
const currentSelection = highlightedEntity;
|
|
155
166
|
setTimeout(() => {
|
|
156
|
-
if (currentSelection ===
|
|
157
|
-
|
|
167
|
+
if (currentSelection === highlightedEntity)
|
|
168
|
+
setHighlightedEntity(undefined);
|
|
158
169
|
}, 2400);
|
|
159
|
-
}, [
|
|
170
|
+
}, [highlightedEntity]);
|
|
160
171
|
|
|
161
172
|
const checkInlineEditing = useCallback((entity?: Entity<any>): boolean => {
|
|
162
173
|
const collection = collectionRef.current;
|
|
163
|
-
if (!canEditEntity(collection, authController,
|
|
174
|
+
if (!canEditEntity(collection, authController, fullPath, entity ?? null)) {
|
|
164
175
|
return false;
|
|
165
176
|
}
|
|
166
177
|
return collection.inlineEditing === undefined || collection.inlineEditing;
|
|
@@ -175,19 +186,16 @@ export const EntityCollectionView = React.memo(
|
|
|
175
186
|
const usedSelectionController = collection.selectionController ?? selectionController;
|
|
176
187
|
const {
|
|
177
188
|
selectedEntities,
|
|
178
|
-
toggleEntitySelection,
|
|
179
|
-
isEntitySelected,
|
|
180
189
|
setSelectedEntities
|
|
181
190
|
} = usedSelectionController;
|
|
182
191
|
|
|
183
|
-
useEffect(() => {
|
|
184
|
-
|
|
185
|
-
}, [selectedEntities]);
|
|
192
|
+
// useEffect(() => {
|
|
193
|
+
// setDeleteEntityClicked(undefined);
|
|
194
|
+
// }, [selectedEntities]);
|
|
186
195
|
|
|
187
196
|
const tableController = useDataSourceEntityCollectionTableController<M>({
|
|
188
197
|
fullPath,
|
|
189
|
-
collection
|
|
190
|
-
entitiesDisplayedFirst: [],
|
|
198
|
+
collection,
|
|
191
199
|
lastDeleteTimestamp
|
|
192
200
|
});
|
|
193
201
|
|
|
@@ -199,8 +207,9 @@ export const EntityCollectionView = React.memo(
|
|
|
199
207
|
}, [tableController.setPopupCell]);
|
|
200
208
|
|
|
201
209
|
const onEntityClick = useCallback((clickedEntity: Entity<M>) => {
|
|
210
|
+
console.log("Entity clicked", clickedEntity)
|
|
202
211
|
const collection = collectionRef.current;
|
|
203
|
-
|
|
212
|
+
setHighlightedEntity(clickedEntity);
|
|
204
213
|
analyticsController.onAnalyticsEvent?.("edit_entity_clicked", {
|
|
205
214
|
path: clickedEntity.path,
|
|
206
215
|
entityId: clickedEntity.id
|
|
@@ -210,9 +219,9 @@ export const EntityCollectionView = React.memo(
|
|
|
210
219
|
path: clickedEntity.path,
|
|
211
220
|
collection,
|
|
212
221
|
updateUrl: true,
|
|
213
|
-
onClose: unselectNavigatedEntity
|
|
222
|
+
onClose: unselectNavigatedEntity,
|
|
214
223
|
});
|
|
215
|
-
}, [unselectNavigatedEntity]);
|
|
224
|
+
}, [unselectNavigatedEntity, sideEntityController]);
|
|
216
225
|
|
|
217
226
|
const onNewClick = useCallback(() => {
|
|
218
227
|
|
|
@@ -224,9 +233,9 @@ export const EntityCollectionView = React.memo(
|
|
|
224
233
|
path: fullPath,
|
|
225
234
|
collection,
|
|
226
235
|
updateUrl: true,
|
|
227
|
-
onClose: unselectNavigatedEntity
|
|
236
|
+
onClose: unselectNavigatedEntity,
|
|
228
237
|
});
|
|
229
|
-
}, [fullPath]);
|
|
238
|
+
}, [fullPath, sideEntityController]);
|
|
230
239
|
|
|
231
240
|
const onMultipleDeleteClick = () => {
|
|
232
241
|
analyticsController.onAnalyticsEvent?.("multiple_delete_dialog_open", {
|
|
@@ -256,6 +265,7 @@ export const EntityCollectionView = React.memo(
|
|
|
256
265
|
fullPath: string,
|
|
257
266
|
parentCollectionIds: string[],
|
|
258
267
|
collection: EntityCollection;
|
|
268
|
+
tableController: EntityTableController;
|
|
259
269
|
}> | undefined
|
|
260
270
|
|
|
261
271
|
// we are only using the first plugin that implements this
|
|
@@ -288,7 +298,7 @@ export const EntityCollectionView = React.memo(
|
|
|
288
298
|
onCollectionModifiedForUser(fullPath, { defaultSize: size })
|
|
289
299
|
}, [onCollectionModifiedForUser, fullPath, userConfigPersistence]);
|
|
290
300
|
|
|
291
|
-
const createEnabled = canCreateEntity(collection, authController,
|
|
301
|
+
const createEnabled = canCreateEntity(collection, authController, fullPath, null);
|
|
292
302
|
|
|
293
303
|
const uniqueFieldValidator: UniqueFieldValidator = useCallback(
|
|
294
304
|
({
|
|
@@ -300,13 +310,11 @@ export const EntityCollectionView = React.memo(
|
|
|
300
310
|
[fullPath]);
|
|
301
311
|
|
|
302
312
|
const onValueChange: OnCellValueChange<any, any> = ({
|
|
303
|
-
fullPath,
|
|
304
|
-
context,
|
|
305
313
|
value,
|
|
306
314
|
propertyKey,
|
|
307
315
|
onValueUpdated,
|
|
308
316
|
setError,
|
|
309
|
-
entity,
|
|
317
|
+
data: entity,
|
|
310
318
|
}) => {
|
|
311
319
|
|
|
312
320
|
const updatedValues = setIn({ ...entity.values }, propertyKey, value);
|
|
@@ -323,10 +331,12 @@ export const EntityCollectionView = React.memo(
|
|
|
323
331
|
return saveEntityWithCallbacks({
|
|
324
332
|
...saveProps,
|
|
325
333
|
collection,
|
|
326
|
-
callbacks: collection.callbacks,
|
|
327
334
|
dataSource,
|
|
328
335
|
context,
|
|
329
|
-
onSaveSuccess: () =>
|
|
336
|
+
onSaveSuccess: () => {
|
|
337
|
+
setError(undefined);
|
|
338
|
+
onValueUpdated();
|
|
339
|
+
},
|
|
330
340
|
onSaveFailure: (e: Error) => {
|
|
331
341
|
console.error("Save failure");
|
|
332
342
|
console.error(e);
|
|
@@ -345,7 +355,6 @@ export const EntityCollectionView = React.memo(
|
|
|
345
355
|
|
|
346
356
|
const getPropertyFor = useCallback(({
|
|
347
357
|
propertyKey,
|
|
348
|
-
propertyValue,
|
|
349
358
|
entity
|
|
350
359
|
}: GetPropertyForProps<M>) => {
|
|
351
360
|
let propertyOrBuilder: PropertyOrBuilder<any, M> | undefined = getPropertyInPath<M>(collection.properties, propertyKey);
|
|
@@ -359,13 +368,12 @@ export const EntityCollectionView = React.memo(
|
|
|
359
368
|
return resolveProperty({
|
|
360
369
|
propertyKey,
|
|
361
370
|
propertyOrBuilder,
|
|
362
|
-
path:
|
|
363
|
-
propertyValue,
|
|
371
|
+
path: entity.path,
|
|
364
372
|
values: entity.values,
|
|
365
373
|
entityId: entity.id,
|
|
366
374
|
fields: customizationController.propertyConfigs
|
|
367
375
|
});
|
|
368
|
-
}, [collection.properties, customizationController.propertyConfigs,
|
|
376
|
+
}, [collection.properties, customizationController.propertyConfigs, resolvedCollection.properties]);
|
|
369
377
|
|
|
370
378
|
const displayedColumnIds = useColumnIds(resolvedCollection, true);
|
|
371
379
|
|
|
@@ -387,7 +395,7 @@ export const EntityCollectionView = React.memo(
|
|
|
387
395
|
entityId: entity.id,
|
|
388
396
|
selectedSubPath: subcollection.id ?? subcollection.path,
|
|
389
397
|
collection,
|
|
390
|
-
updateUrl: true
|
|
398
|
+
updateUrl: true,
|
|
391
399
|
});
|
|
392
400
|
}}>
|
|
393
401
|
{subcollection.name}
|
|
@@ -405,7 +413,7 @@ export const EntityCollectionView = React.memo(
|
|
|
405
413
|
Builder: ({ entity }) => {
|
|
406
414
|
const collectionsWithPath = navigation.getParentReferencesFromPath(entity.path);
|
|
407
415
|
return (
|
|
408
|
-
|
|
416
|
+
<div className={"flex flex-col gap-2 w-full"}>
|
|
409
417
|
{collectionsWithPath.map((reference) => {
|
|
410
418
|
return (
|
|
411
419
|
<ReferencePreview
|
|
@@ -414,7 +422,7 @@ export const EntityCollectionView = React.memo(
|
|
|
414
422
|
size={"tiny"}/>
|
|
415
423
|
);
|
|
416
424
|
})}
|
|
417
|
-
|
|
425
|
+
</div>
|
|
418
426
|
);
|
|
419
427
|
}
|
|
420
428
|
}]
|
|
@@ -425,7 +433,7 @@ export const EntityCollectionView = React.memo(
|
|
|
425
433
|
...subcollectionColumns,
|
|
426
434
|
...collectionGroupParentCollections
|
|
427
435
|
];
|
|
428
|
-
}, [collection, fullPath]);
|
|
436
|
+
}, [collection, fullPath, sideEntityController]);
|
|
429
437
|
|
|
430
438
|
const updateLastDeleteTimestamp = useCallback(() => {
|
|
431
439
|
setLastDeleteTimestamp(Date.now());
|
|
@@ -433,11 +441,14 @@ export const EntityCollectionView = React.memo(
|
|
|
433
441
|
|
|
434
442
|
const largeLayout = useLargeLayout();
|
|
435
443
|
|
|
436
|
-
const getActionsForEntity = ({
|
|
444
|
+
const getActionsForEntity = ({
|
|
445
|
+
entity,
|
|
446
|
+
customEntityActions
|
|
447
|
+
}: {
|
|
437
448
|
entity?: Entity<M>,
|
|
438
449
|
customEntityActions?: EntityAction[]
|
|
439
450
|
}): EntityAction[] => {
|
|
440
|
-
const deleteEnabled = entity ? canDeleteEntity(collection, authController,
|
|
451
|
+
const deleteEnabled = entity ? canDeleteEntity(collection, authController, fullPath, entity) : true;
|
|
441
452
|
const actions: EntityAction[] = [editEntityAction];
|
|
442
453
|
if (createEnabled)
|
|
443
454
|
actions.push(copyEntityAction);
|
|
@@ -448,15 +459,15 @@ export const EntityCollectionView = React.memo(
|
|
|
448
459
|
return actions;
|
|
449
460
|
};
|
|
450
461
|
|
|
451
|
-
const getIdColumnWidth =
|
|
462
|
+
const getIdColumnWidth = () => {
|
|
452
463
|
const entityActions = getActionsForEntity({});
|
|
453
464
|
const collapsedActions = entityActions.filter(a => a.collapsed !== false);
|
|
454
465
|
const uncollapsedActions = entityActions.filter(a => a.collapsed === false);
|
|
455
466
|
const actionsWidth = uncollapsedActions.length * (largeLayout ? 40 : 30);
|
|
456
467
|
return (largeLayout ? (80 + actionsWidth) : (70 + actionsWidth)) + (collapsedActions.length > 0 ? (largeLayout ? 40 : 30) : 0);
|
|
457
|
-
}
|
|
468
|
+
};
|
|
458
469
|
|
|
459
|
-
const tableRowActionsBuilder = ({
|
|
470
|
+
const tableRowActionsBuilder = useCallback(({
|
|
460
471
|
entity,
|
|
461
472
|
size,
|
|
462
473
|
width,
|
|
@@ -468,9 +479,12 @@ export const EntityCollectionView = React.memo(
|
|
|
468
479
|
frozen?: boolean
|
|
469
480
|
}) => {
|
|
470
481
|
|
|
471
|
-
const isSelected =
|
|
482
|
+
const isSelected = usedSelectionController.selectedEntities.map(e => e.id).includes(entity.id);
|
|
472
483
|
|
|
473
|
-
const actions = getActionsForEntity({
|
|
484
|
+
const actions = getActionsForEntity({
|
|
485
|
+
entity,
|
|
486
|
+
customEntityActions: collection.entityActions
|
|
487
|
+
});
|
|
474
488
|
|
|
475
489
|
return (
|
|
476
490
|
<EntityCollectionRowActions
|
|
@@ -480,7 +494,7 @@ export const EntityCollectionView = React.memo(
|
|
|
480
494
|
isSelected={isSelected}
|
|
481
495
|
selectionEnabled={selectionEnabled}
|
|
482
496
|
size={size}
|
|
483
|
-
highlightEntity={
|
|
497
|
+
highlightEntity={setHighlightedEntity}
|
|
484
498
|
unhighlightEntity={unselectNavigatedEntity}
|
|
485
499
|
collection={collection}
|
|
486
500
|
fullPath={fullPath}
|
|
@@ -491,7 +505,7 @@ export const EntityCollectionView = React.memo(
|
|
|
491
505
|
/>
|
|
492
506
|
);
|
|
493
507
|
|
|
494
|
-
};
|
|
508
|
+
}, [updateLastDeleteTimestamp, usedSelectionController]);
|
|
495
509
|
|
|
496
510
|
const title = <Popover
|
|
497
511
|
open={popOverOpen}
|
|
@@ -550,6 +564,7 @@ export const EntityCollectionView = React.memo(
|
|
|
550
564
|
property={property}
|
|
551
565
|
fullPath={fullPath}
|
|
552
566
|
collection={collection}
|
|
567
|
+
tableController={tableController}
|
|
553
568
|
parentCollectionIds={parentCollectionIds ?? []}/>;
|
|
554
569
|
})}
|
|
555
570
|
</>;
|
|
@@ -560,7 +575,8 @@ export const EntityCollectionView = React.memo(
|
|
|
560
575
|
if (typeof AddColumnComponent === "function")
|
|
561
576
|
return <AddColumnComponent fullPath={fullPath}
|
|
562
577
|
parentCollectionIds={parentCollectionIds ?? []}
|
|
563
|
-
collection={collection}
|
|
578
|
+
collection={collection}
|
|
579
|
+
tableController={tableController}/>;
|
|
564
580
|
return null;
|
|
565
581
|
}
|
|
566
582
|
: undefined;
|
|
@@ -577,12 +593,13 @@ export const EntityCollectionView = React.memo(
|
|
|
577
593
|
});
|
|
578
594
|
|
|
579
595
|
return (
|
|
580
|
-
<div className={
|
|
596
|
+
<div className={cls("overflow-hidden h-full w-full rounded-md", className)}
|
|
581
597
|
ref={containerRef}>
|
|
582
598
|
<EntityCollectionTable
|
|
583
599
|
key={`collection_table_${fullPath}`}
|
|
584
600
|
additionalFields={additionalFields}
|
|
585
601
|
tableController={tableController}
|
|
602
|
+
enablePopupIcon={true}
|
|
586
603
|
displayedColumnIds={displayedColumnIds}
|
|
587
604
|
onSizeChanged={onSizeChanged}
|
|
588
605
|
onEntityClick={onEntityClick}
|
|
@@ -592,13 +609,21 @@ export const EntityCollectionView = React.memo(
|
|
|
592
609
|
uniqueFieldValidator={uniqueFieldValidator}
|
|
593
610
|
title={title}
|
|
594
611
|
selectionController={usedSelectionController}
|
|
595
|
-
highlightedEntities={
|
|
612
|
+
highlightedEntities={highlightedEntity ? [highlightedEntity] : []}
|
|
596
613
|
defaultSize={collection.defaultSize}
|
|
597
614
|
properties={resolvedCollection.properties}
|
|
598
615
|
getPropertyFor={getPropertyFor}
|
|
599
616
|
onTextSearchClick={textSearchInitialised ? undefined : onTextSearchClick}
|
|
600
617
|
textSearchLoading={textSearchLoading}
|
|
601
618
|
textSearchEnabled={textSearchEnabled}
|
|
619
|
+
actionsStart={<EntityCollectionViewStartActions
|
|
620
|
+
parentCollectionIds={parentCollectionIds ?? []}
|
|
621
|
+
collection={collection}
|
|
622
|
+
tableController={tableController}
|
|
623
|
+
path={fullPath}
|
|
624
|
+
relativePath={collection.path}
|
|
625
|
+
selectionController={usedSelectionController}
|
|
626
|
+
collectionEntitiesCount={docsCount}/>}
|
|
602
627
|
actions={<EntityCollectionViewActions
|
|
603
628
|
parentCollectionIds={parentCollectionIds ?? []}
|
|
604
629
|
collection={collection}
|
|
@@ -676,39 +701,14 @@ export const EntityCollectionView = React.memo(
|
|
|
676
701
|
equal(a.selectionController, b.selectionController) &&
|
|
677
702
|
equal(a.Actions, b.Actions) &&
|
|
678
703
|
equal(a.defaultSize, b.defaultSize) &&
|
|
704
|
+
equal(a.initialFilter, b.initialFilter) &&
|
|
705
|
+
equal(a.initialSort, b.initialSort) &&
|
|
679
706
|
equal(a.textSearchEnabled, b.textSearchEnabled) &&
|
|
680
707
|
equal(a.additionalFields, b.additionalFields) &&
|
|
708
|
+
equal(a.sideDialogWidth, b.sideDialogWidth) &&
|
|
681
709
|
equal(a.forceFilter, b.forceFilter);
|
|
682
710
|
}) as React.FunctionComponent<EntityCollectionViewProps<any>>
|
|
683
711
|
|
|
684
|
-
export function useSelectionController<M extends Record<string, any> = any>(
|
|
685
|
-
onSelectionChange?: (entity: Entity<M>, selected: boolean) => void
|
|
686
|
-
): SelectionController<M> {
|
|
687
|
-
|
|
688
|
-
const [selectedEntities, setSelectedEntities] = useState<Entity<M>[]>([]);
|
|
689
|
-
|
|
690
|
-
const toggleEntitySelection = useCallback((entity: Entity<M>) => {
|
|
691
|
-
let newValue;
|
|
692
|
-
if (selectedEntities.map(e => e.id).includes(entity.id)) {
|
|
693
|
-
onSelectionChange?.(entity, false);
|
|
694
|
-
newValue = selectedEntities.filter((item: Entity<M>) => item.id !== entity.id);
|
|
695
|
-
} else {
|
|
696
|
-
onSelectionChange?.(entity, true);
|
|
697
|
-
newValue = [...selectedEntities, entity];
|
|
698
|
-
}
|
|
699
|
-
setSelectedEntities(newValue);
|
|
700
|
-
}, [selectedEntities]);
|
|
701
|
-
|
|
702
|
-
const isEntitySelected = useCallback((entity: Entity<M>) => selectedEntities.map(e => e.id).includes(entity.id), [selectedEntities]);
|
|
703
|
-
|
|
704
|
-
return {
|
|
705
|
-
selectedEntities,
|
|
706
|
-
setSelectedEntities,
|
|
707
|
-
isEntitySelected,
|
|
708
|
-
toggleEntitySelection
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
|
|
712
712
|
function EntitiesCount({
|
|
713
713
|
fullPath,
|
|
714
714
|
collection,
|
|
@@ -723,7 +723,7 @@ function EntitiesCount({
|
|
|
723
723
|
onCountChange?: (count: number) => void,
|
|
724
724
|
}) {
|
|
725
725
|
|
|
726
|
-
const dataSource = useDataSource();
|
|
726
|
+
const dataSource = useDataSource(collection);
|
|
727
727
|
const navigation = useNavigationController();
|
|
728
728
|
const [count, setCount] = useState<number | undefined>(undefined);
|
|
729
729
|
const [error, setError] = useState<Error | undefined>(undefined);
|
|
@@ -745,6 +745,7 @@ function EntitiesCount({
|
|
|
745
745
|
|
|
746
746
|
useEffect(() => {
|
|
747
747
|
if (onCountChange) {
|
|
748
|
+
setError(undefined);
|
|
748
749
|
onCountChange(count ?? 0);
|
|
749
750
|
}
|
|
750
751
|
}, [onCountChange, count]);
|
|
@@ -796,10 +797,10 @@ function EntityIdHeaderWidget({
|
|
|
796
797
|
if (!searchString) return;
|
|
797
798
|
setOpenPopup(false);
|
|
798
799
|
return sideEntityController.open({
|
|
799
|
-
entityId: searchString,
|
|
800
|
+
entityId: searchString.trim(),
|
|
800
801
|
path,
|
|
801
802
|
collection,
|
|
802
|
-
updateUrl: true
|
|
803
|
+
updateUrl: true,
|
|
803
804
|
});
|
|
804
805
|
}}
|
|
805
806
|
className={"text-gray-900 dark:text-white w-96 max-w-full"}>
|
|
@@ -809,11 +810,13 @@ function EntityIdHeaderWidget({
|
|
|
809
810
|
autoFocus={openPopup}
|
|
810
811
|
placeholder={"Find entity by ID"}
|
|
811
812
|
// size={"small"}
|
|
812
|
-
onChange={(e) =>
|
|
813
|
+
onChange={(e) => {
|
|
814
|
+
setSearchString(e.target.value);
|
|
815
|
+
}}
|
|
813
816
|
value={searchString}
|
|
814
817
|
className={"flex-grow bg-transparent outline-none p-1"}/>
|
|
815
818
|
<Button variant={"outlined"}
|
|
816
|
-
disabled={!searchString}
|
|
819
|
+
disabled={!(searchString.trim())}
|
|
817
820
|
type={"submit"}
|
|
818
821
|
>Go</Button>
|
|
819
822
|
</div>
|
|
@@ -44,7 +44,7 @@ export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
|
44
44
|
|
|
45
45
|
const selectedEntities = selectionController.selectedEntities;
|
|
46
46
|
|
|
47
|
-
const addButton = canCreateEntity(collection, authController,
|
|
47
|
+
const addButton = canCreateEntity(collection, authController, path, null) &&
|
|
48
48
|
onNewClick && (largeLayout
|
|
49
49
|
? <Button
|
|
50
50
|
id={`add_entity_${path}`}
|
|
@@ -57,14 +57,13 @@ export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
|
57
57
|
: <Button
|
|
58
58
|
id={`add_entity_${path}`}
|
|
59
59
|
onClick={onNewClick}
|
|
60
|
-
size="medium"
|
|
61
60
|
variant="filled"
|
|
62
61
|
color="primary"
|
|
63
62
|
>
|
|
64
63
|
<AddIcon/>
|
|
65
64
|
</Button>);
|
|
66
65
|
|
|
67
|
-
const multipleDeleteEnabled = canDeleteEntity(collection, authController,
|
|
66
|
+
const multipleDeleteEnabled = canDeleteEntity(collection, authController, path, null);
|
|
68
67
|
|
|
69
68
|
let multipleDeleteButton: React.ReactNode | undefined;
|
|
70
69
|
if (selectionEnabled) {
|
|
@@ -112,11 +111,11 @@ export function EntityCollectionViewActions<M extends Record<string, any>>({
|
|
|
112
111
|
|
|
113
112
|
if (plugins) {
|
|
114
113
|
plugins.forEach((plugin, i) => {
|
|
115
|
-
if (plugin.
|
|
116
|
-
actions.push(...toArray(plugin.
|
|
114
|
+
if (plugin.collectionView?.CollectionActions) {
|
|
115
|
+
actions.push(...toArray(plugin.collectionView?.CollectionActions)
|
|
117
116
|
.map((Action, j) => (
|
|
118
117
|
<ErrorBoundary key={`plugin_actions_${i}_${j}`}>
|
|
119
|
-
<Action {...actionProps} {...plugin.
|
|
118
|
+
<Action {...actionProps} {...plugin.collectionView?.collectionActionsProps}/>
|
|
120
119
|
</ErrorBoundary>
|
|
121
120
|
)));
|
|
122
121
|
}
|