@firecms/core 3.3.0-canary.451aa49 → 3.3.0-canary.5906216
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/app/AppBar.d.ts +1 -1
- package/dist/app/Drawer.d.ts +1 -1
- package/dist/app/useApp.d.ts +1 -0
- package/dist/components/AIIcon.d.ts +3 -2
- package/dist/components/ArrayContainer.d.ts +3 -3
- package/dist/components/CircularProgressCenter.d.ts +2 -1
- package/dist/components/ClearFilterSortButton.d.ts +1 -1
- package/dist/components/ConfirmationDialog.d.ts +1 -1
- package/dist/components/DeleteEntityDialog.d.ts +2 -1
- package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +1 -1
- package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +2 -1
- package/dist/components/EntityCollectionTable/column_utils.d.ts +4 -3
- package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +1 -1
- package/dist/components/EntityCollectionTable/fields/TableStorageUpload.d.ts +2 -2
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/EntityTableCellActions.d.ts +1 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +4 -3
- package/dist/components/EntityCollectionView/Board.d.ts +2 -1
- package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +1 -1
- package/dist/components/EntityCollectionView/BoardSortableList.d.ts +1 -1
- package/dist/components/EntityCollectionView/CollectionDataErrorBanner.d.ts +2 -1
- package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCard.d.ts +2 -1
- package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionCardView.d.ts +1 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +2 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +2 -1
- package/dist/components/EntityCollectionView/FiltersDialog.d.ts +3 -1
- package/dist/components/EntityCollectionView/ViewModeToggle.d.ts +2 -1
- package/dist/components/EntityJsonPreview.d.ts +2 -1
- package/dist/components/EntityPreview.d.ts +4 -2
- package/dist/components/EntityView.d.ts +2 -1
- package/dist/components/ErrorBoundary.d.ts +1 -1
- package/dist/components/ErrorTooltip.d.ts +2 -1
- package/dist/components/FieldCaption.d.ts +1 -1
- package/dist/components/FireCMSLogo.d.ts +1 -1
- package/dist/components/HomePage/DefaultHomePage.d.ts +1 -1
- package/dist/components/HomePage/FavouritesView.d.ts +1 -1
- package/dist/components/HomePage/HomePageDnD.d.ts +4 -4
- package/dist/components/HomePage/NavigationCardBinding.d.ts +2 -1
- package/dist/components/HomePage/NavigationGroup.d.ts +2 -2
- package/dist/components/HomePage/RenameGroupDialog.d.ts +2 -1
- package/dist/components/HomePage/SmallNavigationCard.d.ts +1 -1
- package/dist/components/LanguageToggle.d.ts +2 -1
- package/dist/components/NotFoundPage.d.ts +2 -1
- package/dist/components/PropertyCollectionView.d.ts +2 -1
- package/dist/components/PropertyIdCopyTooltip.d.ts +2 -2
- package/dist/components/ReferenceTable/ReferenceSelectionTable.d.ts +1 -1
- package/dist/components/ReferenceWidget.d.ts +2 -1
- package/dist/components/SearchIconsView.d.ts +2 -1
- package/dist/components/SelectableTable/SelectableTable.d.ts +1 -1
- package/dist/components/SelectableTable/filters/BooleanFilterField.d.ts +2 -1
- package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
- package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
- package/dist/components/SelectableTable/filters/StringNumberFilterField.d.ts +2 -1
- package/dist/components/UnsavedChangesDialog.d.ts +1 -1
- package/dist/components/UserDisplay.d.ts +1 -1
- package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +2 -1
- package/dist/components/VirtualTable/fields/VirtualTableDateField.d.ts +1 -1
- package/dist/components/VirtualTable/fields/VirtualTableInput.d.ts +2 -1
- package/dist/components/VirtualTable/fields/VirtualTableNumberInput.d.ts +2 -1
- package/dist/components/VirtualTable/fields/VirtualTableSelect.d.ts +1 -1
- package/dist/components/VirtualTable/fields/VirtualTableSwitch.d.ts +2 -1
- package/dist/components/VirtualTable/fields/VirtualTableUserSelect.d.ts +1 -1
- package/dist/core/DefaultAppBar.d.ts +1 -1
- package/dist/core/DefaultDrawer.d.ts +12 -5
- package/dist/core/DrawerNavigationGroup.d.ts +1 -1
- package/dist/core/DrawerNavigationItem.d.ts +1 -1
- package/dist/core/EntityEditView.d.ts +2 -2
- package/dist/core/EntityEditViewFormActions.d.ts +2 -1
- package/dist/core/EntitySidePanel.d.ts +2 -1
- package/dist/core/FireCMS.d.ts +2 -1
- package/dist/core/FireCMSRouter.d.ts +1 -1
- package/dist/core/SideDialogs.d.ts +1 -1
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/editor/components/SlashCommandMenu.d.ts +2 -1
- package/dist/editor/editor.d.ts +1 -1
- package/dist/editor/selectors/color-selector.d.ts +1 -1
- package/dist/editor/selectors/link-selector.d.ts +1 -1
- package/dist/editor/selectors/node-selector.d.ts +1 -1
- package/dist/editor/selectors/text-buttons.d.ts +1 -1
- package/dist/form/EntityForm.d.ts +1 -1
- package/dist/form/EntityFormActions.d.ts +1 -1
- package/dist/form/components/CustomIdField.d.ts +2 -1
- package/dist/form/components/FieldHelperText.d.ts +1 -1
- package/dist/form/components/FormEntry.d.ts +1 -1
- package/dist/form/components/FormLayout.d.ts +1 -1
- package/dist/form/components/LabelWithIconAndTooltip.d.ts +1 -1
- package/dist/form/components/LocalChangesMenu.d.ts +2 -1
- package/dist/form/components/StorageItemPreview.d.ts +2 -1
- package/dist/form/components/StorageUploadProgress.d.ts +2 -1
- package/dist/form/field_bindings/ArrayCustomShapedFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/ArrayOfReferencesFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/BlockFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/DateTimeFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +5 -0
- package/dist/form/field_bindings/KeyValueFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/MapFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/MarkdownEditorFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/MultiSelectFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/ReadOnlyFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/ReferenceAsStringFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/ReferenceFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/RepeatFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/SelectFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +3 -2
- package/dist/form/field_bindings/SwitchFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/TextFieldBinding.d.ts +2 -1
- package/dist/form/field_bindings/UserSelectFieldBinding.d.ts +2 -1
- package/dist/form/index.d.ts +1 -0
- package/dist/i18n/FireCMSi18nProvider.d.ts +2 -2
- package/dist/index.es.js +2409 -965
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2408 -964
- package/dist/index.umd.js.map +1 -1
- package/dist/locales/pl.d.ts +2 -0
- package/dist/preview/components/ArrayEnumPreview.d.ts +2 -1
- package/dist/preview/components/AsyncPreviewComponent.d.ts +1 -1
- package/dist/preview/components/EmptyValue.d.ts +2 -1
- package/dist/preview/components/EnumValuesChip.d.ts +1 -1
- package/dist/preview/components/ImagePreview.d.ts +2 -1
- package/dist/preview/components/ReferencePreview.d.ts +1 -1
- package/dist/preview/components/StorageThumbnail.d.ts +1 -1
- package/dist/preview/components/UserPreview.d.ts +2 -1
- package/dist/preview/index.d.ts +1 -0
- package/dist/preview/property_previews/ArrayOfMapsPreview.d.ts +2 -1
- package/dist/preview/property_previews/ArrayOfReferencesPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +2 -1
- package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +2 -1
- package/dist/preview/property_previews/ArrayOneOfPreview.d.ts +2 -1
- package/dist/preview/property_previews/ArrayPropertyEnumPreview.d.ts +1 -1
- package/dist/preview/property_previews/ArrayPropertyPreview.d.ts +2 -1
- package/dist/preview/property_previews/GeopointPropertyPreview.d.ts +4 -0
- package/dist/preview/property_previews/MapPropertyPreview.d.ts +3 -2
- package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +5 -4
- package/dist/routes/FireCMSRoute.d.ts +2 -1
- package/dist/types/collections.d.ts +17 -0
- package/dist/types/translations.d.ts +11 -3
- package/dist/util/entities.d.ts +1 -0
- package/dist/util/geopoint.d.ts +22 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/navigation_blocking.d.ts +22 -0
- package/dist/util/navigation_from_path.d.ts +10 -0
- package/dist/util/navigation_utils.d.ts +20 -0
- package/dist/util/property_utils.d.ts +1 -1
- package/package.json +18 -11
- package/src/app/Scaffold.tsx +47 -45
- package/src/app/useApp.tsx +1 -0
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +2 -1
- package/src/components/EntityCollectionTable/column_utils.tsx +11 -19
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/common.tsx +2 -2
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +5 -2
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +4 -1
- package/src/components/EntityCollectionView/FiltersDialog.tsx +39 -28
- package/src/components/EntityPreview.tsx +41 -40
- package/src/components/HomePage/NavigationCardBinding.tsx +6 -3
- package/src/components/ReferenceWidget.tsx +1 -1
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +2 -2
- package/src/components/VirtualTable/VirtualTable.tsx +19 -8
- package/src/components/common/useDataSourceTableController.tsx +66 -10
- package/src/core/DefaultDrawer.tsx +151 -65
- package/src/core/DrawerNavigationGroup.tsx +27 -29
- package/src/core/DrawerNavigationItem.tsx +10 -12
- package/src/core/EntityEditView.tsx +57 -32
- package/src/core/field_configs.tsx +15 -0
- package/src/editor/editor.tsx +20 -1
- package/src/editor/markdown.ts +89 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -1
- package/src/form/field_bindings/GeopointFieldBinding.tsx +139 -0
- package/src/form/index.tsx +1 -0
- package/src/hooks/useBuildNavigationController.tsx +5 -1
- package/src/i18n/FireCMSi18nProvider.tsx +2 -0
- package/src/internal/useBuildSideEntityController.tsx +3 -2
- package/src/locales/de.ts +13 -5
- package/src/locales/en.ts +13 -5
- package/src/locales/es.ts +13 -5
- package/src/locales/fr.ts +13 -5
- package/src/locales/hi.ts +13 -5
- package/src/locales/it.ts +13 -5
- package/src/locales/pl.ts +730 -0
- package/src/locales/pt.ts +13 -5
- package/src/preview/PropertyPreview.tsx +15 -3
- package/src/preview/index.ts +1 -0
- package/src/preview/property_previews/GeopointPropertyPreview.tsx +23 -0
- package/src/routes/FireCMSRoute.tsx +44 -25
- package/src/types/collections.ts +18 -0
- package/src/types/translations.ts +11 -3
- package/src/util/entities.ts +13 -0
- package/src/util/geopoint.ts +81 -0
- package/src/util/index.ts +1 -0
- package/src/util/navigation_blocking.ts +45 -0
- package/src/util/navigation_from_path.ts +23 -6
- package/src/util/navigation_utils.ts +36 -2
- package/src/util/parent_references_from_path.ts +4 -2
- package/src/util/resolutions.ts +3 -0
package/src/app/useApp.tsx
CHANGED
|
@@ -245,7 +245,8 @@ export const EntityCollectionTable = function EntityCollectionTable<M extends Re
|
|
|
245
245
|
const columnsResult: VirtualTableColumn[] = propertiesToColumns({
|
|
246
246
|
properties,
|
|
247
247
|
sortable,
|
|
248
|
-
|
|
248
|
+
forcedFilters: tableController.forcedFilters,
|
|
249
|
+
allowedFilters: tableController.allowedFilters,
|
|
249
250
|
AdditionalHeaderWidget
|
|
250
251
|
});
|
|
251
252
|
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { getTableCellAlignment, getTablePropertyColumnWidth } from "./internal/common";
|
|
3
3
|
import { FilterValues, ResolvedProperties, ResolvedProperty } from "../../types";
|
|
4
4
|
import { VirtualTableColumn } from "../VirtualTable";
|
|
5
|
-
import { getIconForProperty, getResolvedPropertyInPath } from "../../util";
|
|
5
|
+
import { getIconForProperty, getResolvedPropertyInPath, isDataTypeFilterable } from "../../util";
|
|
6
6
|
import { getColumnKeysForProperty } from "../common/useColumnsIds";
|
|
7
7
|
|
|
8
8
|
export function buildIdColumn(largeLayout?: boolean): VirtualTableColumn {
|
|
@@ -20,7 +20,8 @@ export function buildIdColumn(largeLayout?: boolean): VirtualTableColumn {
|
|
|
20
20
|
export interface PropertiesToColumnsParams<M extends Record<string, any>> {
|
|
21
21
|
properties: ResolvedProperties<M>;
|
|
22
22
|
sortable?: boolean;
|
|
23
|
-
|
|
23
|
+
forcedFilters?: (keyof M)[];
|
|
24
|
+
allowedFilters?: (keyof M)[];
|
|
24
25
|
AdditionalHeaderWidget?: React.ComponentType<{
|
|
25
26
|
property: ResolvedProperty,
|
|
26
27
|
propertyKey: string,
|
|
@@ -28,8 +29,7 @@ export interface PropertiesToColumnsParams<M extends Record<string, any>> {
|
|
|
28
29
|
}>;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
export function propertiesToColumns<M extends Record<string, any>>({ properties, sortable,
|
|
32
|
-
const disabledFilter = Boolean(forceFilter);
|
|
32
|
+
export function propertiesToColumns<M extends Record<string, any>>({ properties, sortable, forcedFilters, AdditionalHeaderWidget, allowedFilters }: PropertiesToColumnsParams<M>): VirtualTableColumn[] {
|
|
33
33
|
return Object.entries<ResolvedProperty>(properties)
|
|
34
34
|
.flatMap(([key, property]) => getColumnKeysForProperty(property, key))
|
|
35
35
|
.map(({
|
|
@@ -39,14 +39,19 @@ export function propertiesToColumns<M extends Record<string, any>>({ properties,
|
|
|
39
39
|
const property = getResolvedPropertyInPath(properties, key);
|
|
40
40
|
if (!property)
|
|
41
41
|
throw Error("Internal error: no property found in path " + key);
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
const filterable = property.dataType === 'array' ? isDataTypeFilterable(property.of?.dataType, true) : isDataTypeFilterable(property.dataType);
|
|
44
|
+
const isFilterForced = forcedFilters?.includes(key) ?? false;
|
|
45
|
+
const isFilterAllowed = allowedFilters ? allowedFilters.includes(key) : filterable;
|
|
46
|
+
|
|
47
|
+
const filterEnabled = filterable && isFilterAllowed && !isFilterForced;
|
|
43
48
|
return {
|
|
44
49
|
key: key as string,
|
|
45
50
|
align: getTableCellAlignment(property),
|
|
46
51
|
icon: getIconForProperty(property, "small"),
|
|
47
52
|
title: property.name ?? key as string,
|
|
48
53
|
sortable: sortable,
|
|
49
|
-
filter:
|
|
54
|
+
filter: filterEnabled,
|
|
50
55
|
width: getTablePropertyColumnWidth(property),
|
|
51
56
|
resizable: true,
|
|
52
57
|
custom: {
|
|
@@ -59,16 +64,3 @@ export function propertiesToColumns<M extends Record<string, any>>({ properties,
|
|
|
59
64
|
} satisfies VirtualTableColumn;
|
|
60
65
|
});
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
function filterableProperty(property: ResolvedProperty, partOfArray = false): boolean {
|
|
64
|
-
if (partOfArray) {
|
|
65
|
-
return ["string", "number", "date", "reference"].includes(property.dataType);
|
|
66
|
-
}
|
|
67
|
-
if (property.dataType === "array") {
|
|
68
|
-
if (property.of)
|
|
69
|
-
return filterableProperty(property.of, true);
|
|
70
|
-
else
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
return ["string", "number", "boolean", "date", "reference", "array"].includes(property.dataType);
|
|
74
|
-
}
|
|
@@ -70,7 +70,7 @@ export const TableReferenceFieldInternal = React.memo(
|
|
|
70
70
|
}, [updateValue]);
|
|
71
71
|
|
|
72
72
|
const onMultipleEntitiesSelected = useCallback((entities: Entity<any>[]) => {
|
|
73
|
-
updateValue(entities.map((e) => getReferenceFrom(e)));
|
|
73
|
+
updateValue(entities.filter(Boolean).map((e) => getReferenceFrom(e)));
|
|
74
74
|
}, [updateValue]);
|
|
75
75
|
|
|
76
76
|
const selectedEntityIds = internalValue
|
|
@@ -23,14 +23,14 @@ export function getTablePropertyColumnWidth(property: ResolvedProperty): number
|
|
|
23
23
|
if (property.dataType === "string") {
|
|
24
24
|
if (property.url) {
|
|
25
25
|
return 280;
|
|
26
|
+
} else if (property.markdown) {
|
|
27
|
+
return 300;
|
|
26
28
|
} else if (property.storage) {
|
|
27
29
|
return 160;
|
|
28
30
|
} else if (property.enumValues) {
|
|
29
31
|
return 200;
|
|
30
32
|
} else if (property.multiline) {
|
|
31
33
|
return 300;
|
|
32
|
-
} else if (property.markdown) {
|
|
33
|
-
return 300;
|
|
34
34
|
} else if (property.email) {
|
|
35
35
|
return 200;
|
|
36
36
|
} else {
|
|
@@ -178,7 +178,9 @@ export const EntityCollectionView = React.memo(
|
|
|
178
178
|
|
|
179
179
|
const collection = useMemo(() => {
|
|
180
180
|
const userOverride = userConfigPersistence?.getCollectionConfig<M>(fullPath);
|
|
181
|
-
|
|
181
|
+
if (!userOverride) return collectionProp;
|
|
182
|
+
const { properties, ...rest } = userOverride;
|
|
183
|
+
return mergeDeep(collectionProp, rest) as EntityCollection<M>;
|
|
182
184
|
}, [collectionProp, fullPath, userConfigPersistence?.getCollectionConfig]);
|
|
183
185
|
|
|
184
186
|
const openEntityMode = collection?.openEntityMode ?? DEFAULT_ENTITY_OPEN_MODE;
|
|
@@ -507,7 +509,8 @@ export const EntityCollectionView = React.memo(
|
|
|
507
509
|
path: fullPath,
|
|
508
510
|
propertyConfigs: customizationController.propertyConfigs,
|
|
509
511
|
authController,
|
|
510
|
-
|
|
512
|
+
userConfigPersistence,
|
|
513
|
+
}), [collection, fullPath, userConfigPersistence]);
|
|
511
514
|
|
|
512
515
|
// Check if Kanban view is possible (collection has at least one string enum property)
|
|
513
516
|
const hasEnumProperty = useMemo(() => {
|
|
@@ -66,8 +66,10 @@ export function EntityCollectionViewStartActions<M extends Record<string, any>>(
|
|
|
66
66
|
collectionEntitiesCount
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
const hasAnyAllowedFilters = !tableController.allowedFilters || tableController.allowedFilters.length > 0;
|
|
70
|
+
|
|
69
71
|
// Filters button
|
|
70
|
-
const filtersButton = resolvedProperties && tableController.setFilterValues && (
|
|
72
|
+
const filtersButton = resolvedProperties && tableController.setFilterValues && hasAnyAllowedFilters && (
|
|
71
73
|
<Tooltip title={t("filters")}
|
|
72
74
|
key={"filters_tooltip"}>
|
|
73
75
|
<Badge
|
|
@@ -131,6 +133,7 @@ export function EntityCollectionViewStartActions<M extends Record<string, any>>(
|
|
|
131
133
|
filterValues={tableController.filterValues}
|
|
132
134
|
setFilterValues={(filterValues) => tableController.setFilterValues?.(filterValues ?? {})}
|
|
133
135
|
forceFilter={collection.forceFilter}
|
|
136
|
+
allowedFilters={tableController.allowedFilters?.map(key => key.toString())}
|
|
134
137
|
/>
|
|
135
138
|
)}
|
|
136
139
|
</>
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
DialogActions,
|
|
13
13
|
DialogContent,
|
|
14
14
|
DialogTitle,
|
|
15
|
-
FilterListIcon,
|
|
16
15
|
Typography
|
|
17
16
|
} from "@firecms/ui";
|
|
18
17
|
import { useTranslation } from "../../hooks/useTranslation";
|
|
@@ -30,6 +29,7 @@ export interface FiltersDialogProps {
|
|
|
30
29
|
filterValues: FilterValues<any> | undefined;
|
|
31
30
|
setFilterValues: (filterValues?: FilterValues<any>) => void;
|
|
32
31
|
forceFilter?: FilterValues<any>;
|
|
32
|
+
allowedFilters?: string[];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -42,7 +42,8 @@ export function FiltersDialog({
|
|
|
42
42
|
properties,
|
|
43
43
|
filterValues,
|
|
44
44
|
setFilterValues,
|
|
45
|
-
forceFilter
|
|
45
|
+
forceFilter,
|
|
46
|
+
allowedFilters
|
|
46
47
|
}: FiltersDialogProps) {
|
|
47
48
|
const { t } = useTranslation();
|
|
48
49
|
|
|
@@ -59,18 +60,18 @@ export function FiltersDialog({
|
|
|
59
60
|
}
|
|
60
61
|
}, [open, filterValues]);
|
|
61
62
|
|
|
62
|
-
// Get list of
|
|
63
|
-
const
|
|
64
|
-
return Object.entries(properties).filter(([key
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!baseProperty) return false;
|
|
71
|
-
return ["string", "number", "boolean", "date", "reference"].includes(baseProperty.dataType);
|
|
63
|
+
// Get list of editable filter properties
|
|
64
|
+
const editableFilterProperties = useMemo(() => {
|
|
65
|
+
return Object.entries(properties).filter(([key]) => {
|
|
66
|
+
const isFilterAllowed = !allowedFilters || allowedFilters.includes(key);
|
|
67
|
+
|
|
68
|
+
const isFilterForced = Boolean(forceFilter && Object.keys(forceFilter).includes(key));
|
|
69
|
+
|
|
70
|
+
return isFilterAllowed && !isFilterForced;
|
|
72
71
|
});
|
|
73
|
-
}, [properties, forceFilter]);
|
|
72
|
+
}, [properties, allowedFilters, forceFilter]);
|
|
73
|
+
|
|
74
|
+
const hasEditableFilterProperties = editableFilterProperties.length > 0;
|
|
74
75
|
|
|
75
76
|
const handleFilterChange = useCallback((propertyKey: string, value?: [VirtualTableWhereFilterOp, any]) => {
|
|
76
77
|
setLocalFilters(prev => {
|
|
@@ -103,7 +104,13 @@ export function FiltersDialog({
|
|
|
103
104
|
|
|
104
105
|
// Check if any reference field's dialog is currently open (should hide this dialog)
|
|
105
106
|
const isAnyFieldHidden = Object.values(hiddenFields).some(hidden => hidden);
|
|
106
|
-
|
|
107
|
+
|
|
108
|
+
const getActiveFilterCount = () => {
|
|
109
|
+
const editableLocalFilters = Object.keys(localFilters).filter((key) => !forceFilter || !(key in forceFilter));
|
|
110
|
+
return editableLocalFilters.length;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const activeFilterCount = getActiveFilterCount();
|
|
107
114
|
|
|
108
115
|
const renderFilterField = useCallback((propertyKey: string, property: ResolvedProperty) => {
|
|
109
116
|
const isArray = property.dataType === "array";
|
|
@@ -185,14 +192,14 @@ export function FiltersDialog({
|
|
|
185
192
|
</DialogTitle>
|
|
186
193
|
|
|
187
194
|
<DialogContent >
|
|
188
|
-
{
|
|
195
|
+
{!hasEditableFilterProperties ? (
|
|
189
196
|
<Typography color="secondary" className="py-8 text-center">
|
|
190
197
|
{t("no_filterable_properties")}
|
|
191
198
|
</Typography>
|
|
192
199
|
) : (
|
|
193
200
|
<table className="w-full border-collapse">
|
|
194
201
|
<tbody>
|
|
195
|
-
{
|
|
202
|
+
{editableFilterProperties.map(([propertyKey, property], index) => {
|
|
196
203
|
const hasFilter = propertyKey in localFilters;
|
|
197
204
|
|
|
198
205
|
return (
|
|
@@ -234,18 +241,22 @@ export function FiltersDialog({
|
|
|
234
241
|
{t("clear")}
|
|
235
242
|
</Button>
|
|
236
243
|
<div className="flex-grow" />
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
{hasEditableFilterProperties && (
|
|
245
|
+
<>
|
|
246
|
+
<Button
|
|
247
|
+
variant="text"
|
|
248
|
+
onClick={() => onOpenChange(false)}
|
|
249
|
+
>
|
|
250
|
+
{t("cancel")}
|
|
251
|
+
</Button>
|
|
252
|
+
<Button
|
|
253
|
+
variant="filled"
|
|
254
|
+
onClick={handleApply}
|
|
255
|
+
>
|
|
256
|
+
{t("apply_filters")}
|
|
257
|
+
</Button>
|
|
258
|
+
</>
|
|
259
|
+
)}
|
|
249
260
|
</DialogActions>
|
|
250
261
|
</Dialog>
|
|
251
262
|
);
|
|
@@ -200,43 +200,44 @@ export type EntityPreviewContainerProps = {
|
|
|
200
200
|
onClick?: (e: React.SyntheticEvent) => void;
|
|
201
201
|
};
|
|
202
202
|
|
|
203
|
-
export
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
203
|
+
export function EntityPreviewContainer({
|
|
204
|
+
children,
|
|
205
|
+
hover,
|
|
206
|
+
onClick,
|
|
207
|
+
size = "medium",
|
|
208
|
+
style,
|
|
209
|
+
className,
|
|
210
|
+
fullwidth = true,
|
|
211
|
+
ref
|
|
212
|
+
}: EntityPreviewContainerProps & { ref?: React.Ref<HTMLDivElement> }) {
|
|
213
|
+
const divClassName = cls(
|
|
214
|
+
"bg-white dark:bg-surface-900",
|
|
215
|
+
"min-h-[44px]",
|
|
216
|
+
fullwidth ? "w-full" : "",
|
|
217
|
+
"items-center",
|
|
218
|
+
hover ? "hover:bg-surface-accent-50 dark:hover:bg-surface-800 group-hover:bg-surface-accent-50 dark:group-hover:bg-surface-800" : "",
|
|
219
|
+
size === "small" ? "p-1" : "px-2 py-1",
|
|
220
|
+
"flex border rounded-lg",
|
|
221
|
+
onClick ? "cursor-pointer" : "",
|
|
222
|
+
defaultBorderMixin,
|
|
223
|
+
className
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
const handleClick = onClick
|
|
227
|
+
? (event: React.MouseEvent<HTMLDivElement>) => {
|
|
228
|
+
event.preventDefault();
|
|
229
|
+
onClick(event);
|
|
230
|
+
}
|
|
231
|
+
: undefined;
|
|
232
|
+
|
|
233
|
+
const divProps: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> } = {
|
|
234
|
+
ref,
|
|
235
|
+
tabIndex: 0,
|
|
236
|
+
style,
|
|
237
|
+
className: divClassName,
|
|
238
|
+
onClick: handleClick,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
return <div {...divProps}>{children}</div>;
|
|
242
|
+
}
|
|
243
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useNavigate } from "react-router-dom";
|
|
2
2
|
|
|
3
|
-
import { useCustomizationController, useFireCMSContext } from "../../hooks";
|
|
3
|
+
import { useCustomizationController, useFireCMSContext, useTranslation } from "../../hooks";
|
|
4
4
|
import { NavigationEntry, PluginHomePageActionsProps } from "../../types";
|
|
5
5
|
import { IconForView } from "../../util";
|
|
6
6
|
import { useUserConfigurationPersistence } from "../../hooks/useUserConfigurationPersistence";
|
|
@@ -38,6 +38,7 @@ export function NavigationCardBinding({
|
|
|
38
38
|
}) {
|
|
39
39
|
|
|
40
40
|
const userConfigurationPersistence = useUserConfigurationPersistence();
|
|
41
|
+
const { t } = useTranslation();
|
|
41
42
|
const collectionIcon = <IconForView collectionOrView={collection ?? view}/>;
|
|
42
43
|
|
|
43
44
|
const navigate = useNavigate();
|
|
@@ -92,15 +93,17 @@ export function NavigationCardBinding({
|
|
|
92
93
|
{actionsArray}
|
|
93
94
|
</>
|
|
94
95
|
|
|
96
|
+
const translatedName = t(name);
|
|
97
|
+
|
|
95
98
|
if (type === "admin") {
|
|
96
99
|
return <SmallNavigationCard icon={collectionIcon}
|
|
97
|
-
name={
|
|
100
|
+
name={translatedName}
|
|
98
101
|
url={url}/>;
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
return <NavigationCard
|
|
102
105
|
icon={collectionIcon}
|
|
103
|
-
name={
|
|
106
|
+
name={translatedName}
|
|
104
107
|
description={description}
|
|
105
108
|
actions={actions}
|
|
106
109
|
onClick={() => {
|
|
@@ -73,7 +73,7 @@ export function ReferenceWidget<M extends Record<string, any>>({
|
|
|
73
73
|
if (disabled)
|
|
74
74
|
return;
|
|
75
75
|
if (onMultipleReferenceSelected) {
|
|
76
|
-
const references = entities ? entities.map(e => getReferenceFrom(e)) : null;
|
|
76
|
+
const references = entities ? entities.filter(Boolean).map(e => getReferenceFrom(e)) : null;
|
|
77
77
|
onMultipleReferenceSelected({
|
|
78
78
|
references,
|
|
79
79
|
entities
|
|
@@ -113,11 +113,11 @@ export function ReferenceFilterField({
|
|
|
113
113
|
}, [path]);
|
|
114
114
|
|
|
115
115
|
const onSingleEntitySelected = (entity: Entity<any>) => {
|
|
116
|
-
updateFilter(operation, getReferenceFrom(entity));
|
|
116
|
+
if (entity) updateFilter(operation, getReferenceFrom(entity));
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
const onMultipleEntitiesSelected = (entities: Entity<any>[]) => {
|
|
120
|
-
updateFilter(operation, entities.map(e => getReferenceFrom(e)));
|
|
120
|
+
updateFilter(operation, entities.filter(Boolean).map(e => getReferenceFrom(e)));
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const multiple = multipleSelectOperations.includes(operation);
|
|
@@ -135,7 +135,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
135
135
|
const [columns, setColumns] = useState(columnsProp);
|
|
136
136
|
|
|
137
137
|
const tableRef = useRef<HTMLDivElement>(null);
|
|
138
|
-
const
|
|
138
|
+
const lastEndReachedDataLength = useRef<number | undefined>(undefined);
|
|
139
139
|
|
|
140
140
|
const debouncedScroll = useDebounceCallback(onScrollProp, 200);
|
|
141
141
|
|
|
@@ -242,7 +242,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
242
242
|
}, [filterInput]);
|
|
243
243
|
|
|
244
244
|
const scrollToTop = useCallback(() => {
|
|
245
|
-
|
|
245
|
+
lastEndReachedDataLength.current = undefined;
|
|
246
246
|
if (tableRef.current) {
|
|
247
247
|
tableRef.current.scrollTo(tableRef.current?.scrollLeft, 0);
|
|
248
248
|
}
|
|
@@ -278,13 +278,24 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
278
278
|
|
|
279
279
|
const maxScroll = Math.max((data?.length ?? 0) * rowHeight - bounds.height, 0);
|
|
280
280
|
|
|
281
|
-
const onEndReachedInternal = useCallback((
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
const onEndReachedInternal = useCallback(() => {
|
|
282
|
+
const dataLength = data?.length ?? 0;
|
|
283
|
+
|
|
284
|
+
if (onEndReached && dataLength > 0 && lastEndReachedDataLength.current !== dataLength) {
|
|
285
|
+
lastEndReachedDataLength.current = dataLength;
|
|
284
286
|
onEndReached();
|
|
285
287
|
}
|
|
286
288
|
}, [data?.length, onEndReached]);
|
|
287
289
|
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (!onEndReached || loading || !data?.length || !bounds.height || !tableRef.current) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
if (tableRef.current.scrollHeight <= tableRef.current.clientHeight) {
|
|
295
|
+
onEndReachedInternal();
|
|
296
|
+
}
|
|
297
|
+
}, [bounds.height, data?.length, loading, onEndReached, onEndReachedInternal]);
|
|
298
|
+
|
|
288
299
|
const onScroll = useCallback(({
|
|
289
300
|
scrollDirection,
|
|
290
301
|
scrollOffset,
|
|
@@ -302,12 +313,12 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
|
|
|
302
313
|
})
|
|
303
314
|
}
|
|
304
315
|
if (!scrollUpdateWasRequested && (scrollOffset >= maxScroll - endOffset))
|
|
305
|
-
onEndReachedInternal(
|
|
306
|
-
}, [maxScroll, onEndReachedInternal]);
|
|
316
|
+
onEndReachedInternal();
|
|
317
|
+
}, [endOffset, maxScroll, onEndReachedInternal]);
|
|
307
318
|
|
|
308
319
|
const onFilterUpdateInternal = useCallback((column: VirtualTableColumn, filterForProperty?: [VirtualTableWhereFilterOp, any]) => {
|
|
309
320
|
|
|
310
|
-
|
|
321
|
+
lastEndReachedDataLength.current = undefined;
|
|
311
322
|
const filter = filterRef.current;
|
|
312
323
|
let newFilterValue: VirtualTableFilterValues<any> = filter ? { ...filter } : {};
|
|
313
324
|
|
|
@@ -4,6 +4,7 @@ import { useLocation } from "react-router-dom";
|
|
|
4
4
|
import { useDataSource, useFireCMSContext, useNavigationController } from "../../hooks";
|
|
5
5
|
import { useDataOrder } from "../../hooks/data/useDataOrder";
|
|
6
6
|
import {
|
|
7
|
+
DataType,
|
|
7
8
|
Entity,
|
|
8
9
|
EntityCollection,
|
|
9
10
|
EntityReference,
|
|
@@ -16,6 +17,8 @@ import {
|
|
|
16
17
|
} from "../../types";
|
|
17
18
|
import { useDebouncedData } from "./useDebouncedData";
|
|
18
19
|
import { ScrollRestorationController } from "./useScrollRestoration";
|
|
20
|
+
import { isDataTypeFilterable } from "../../util";
|
|
21
|
+
import { decodeEntityId, encodeEntityId } from "../../util/navigation_utils";
|
|
19
22
|
|
|
20
23
|
const DEFAULT_PAGE_SIZE = 50;
|
|
21
24
|
|
|
@@ -135,8 +138,41 @@ export function useDataSourceTableController<M extends Record<string, any> = any
|
|
|
135
138
|
filterValues: initialFilterUrl,
|
|
136
139
|
sortBy: initialSortUrl,
|
|
137
140
|
} = parseFilterAndSort(location.search);
|
|
141
|
+
|
|
142
|
+
const availableFilterKeys = collection.allowedFilters ?? Object.keys(collection.properties);
|
|
143
|
+
const forcedFilterKeys = collection.forceFilter ? Object.keys(collection.forceFilter) : [];
|
|
138
144
|
|
|
139
|
-
const
|
|
145
|
+
const allowedFilterKeys = useMemo(() => {
|
|
146
|
+
const availableKeys = availableFilterKeys.filter((key) => {
|
|
147
|
+
const property = collection.properties[key];
|
|
148
|
+
|
|
149
|
+
if (!property) return false;
|
|
150
|
+
|
|
151
|
+
if (typeof property === "function") return false;
|
|
152
|
+
|
|
153
|
+
const dataType = property.dataType;
|
|
154
|
+
const filterable = dataType === "array"
|
|
155
|
+
? isDataTypeFilterable((property as { of?: { dataType: DataType } }).of?.dataType as DataType, true)
|
|
156
|
+
: isDataTypeFilterable(dataType);
|
|
157
|
+
|
|
158
|
+
return filterable;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const forcedKeys = forcedFilterKeys.filter((key) => !availableKeys.includes(key));
|
|
162
|
+
|
|
163
|
+
return [...availableKeys, ...forcedKeys];
|
|
164
|
+
|
|
165
|
+
}, [collection.properties, availableFilterKeys, forcedFilterKeys]);
|
|
166
|
+
|
|
167
|
+
const removeUnallowedFilters = useCallback((filters?: FilterValues<Extract<keyof M, string>>) => {
|
|
168
|
+
if (!filters) return;
|
|
169
|
+
|
|
170
|
+
return Object.fromEntries(Object.entries(filters).filter(([key]) => allowedFilterKeys.includes(key as keyof M))) as FilterValues<Extract<keyof M, string>>;
|
|
171
|
+
}, [allowedFilterKeys]);
|
|
172
|
+
|
|
173
|
+
const initFilters = forceFilter ?? (updateUrl ? initialFilterUrl : undefined) ?? initialFilter ?? undefined
|
|
174
|
+
|
|
175
|
+
const [filterValues, setFilterValues] = React.useState<FilterValues<Extract<keyof M, string>> | undefined>(removeUnallowedFilters(initFilters));
|
|
140
176
|
const [sortBy, setSortBy] = React.useState<[Extract<keyof M, string>, "asc" | "desc"] | undefined>((updateUrl ? initialSortUrl : undefined) ?? initialSortInternal);
|
|
141
177
|
|
|
142
178
|
useUpdateUrl(filterValues, sortBy, searchString, updateUrl);
|
|
@@ -168,7 +204,7 @@ export function useDataSourceTableController<M extends Record<string, any> = any
|
|
|
168
204
|
const [dataLoadingError, setDataLoadingError] = useState<Error | undefined>();
|
|
169
205
|
const [noMoreToLoad, setNoMoreToLoad] = useState<boolean>(false);
|
|
170
206
|
|
|
171
|
-
const clearFilter = useCallback(() => setFilterValues(forceFilter
|
|
207
|
+
const clearFilter = useCallback(() => setFilterValues(removeUnallowedFilters(forceFilter)), [forceFilter, removeUnallowedFilters]);
|
|
172
208
|
|
|
173
209
|
const updateFilterValues = useCallback((updatedFilter: FilterValues<Extract<keyof M, string>> | undefined) => {
|
|
174
210
|
if (forceFilter) {
|
|
@@ -178,9 +214,9 @@ export function useDataSourceTableController<M extends Record<string, any> = any
|
|
|
178
214
|
if (updatedFilter && Object.keys(updatedFilter).length === 0) {
|
|
179
215
|
setFilterValues(undefined);
|
|
180
216
|
} else {
|
|
181
|
-
setFilterValues(updatedFilter);
|
|
217
|
+
setFilterValues(removeUnallowedFilters(updatedFilter));
|
|
182
218
|
}
|
|
183
|
-
}, [forceFilter]);
|
|
219
|
+
}, [forceFilter, removeUnallowedFilters]);
|
|
184
220
|
|
|
185
221
|
useEffect(() => {
|
|
186
222
|
|
|
@@ -268,6 +304,8 @@ export function useDataSourceTableController<M extends Record<string, any> = any
|
|
|
268
304
|
dataLoadingError,
|
|
269
305
|
filterValues,
|
|
270
306
|
setFilterValues: updateFilterValues,
|
|
307
|
+
allowedFilters: allowedFilterKeys,
|
|
308
|
+
forcedFilters: forcedFilterKeys,
|
|
271
309
|
sortBy,
|
|
272
310
|
setSortBy,
|
|
273
311
|
searchString,
|
|
@@ -342,7 +380,13 @@ function encodeFilterAndSort(filterValues?: FilterValues<string>, sortBy?: [stri
|
|
|
342
380
|
}
|
|
343
381
|
if (encodedValue !== undefined) {
|
|
344
382
|
entries[encodeURIComponent(`${key}_op`)] = encodeURIComponent(op);
|
|
345
|
-
|
|
383
|
+
// Note: check for null/undefined explicitly instead of truthiness,
|
|
384
|
+
// otherwise falsy-but-valid values (boolean `false`, number `0`)
|
|
385
|
+
// would be serialized as "null" and round-trip back as `null`,
|
|
386
|
+
// breaking filters like `archived == false`.
|
|
387
|
+
entries[encodeURIComponent(`${key}_value`)] = encodedValue !== null && encodedValue !== undefined
|
|
388
|
+
? encodeURIComponent(encodedValue.toString())
|
|
389
|
+
: "null";
|
|
346
390
|
}
|
|
347
391
|
}
|
|
348
392
|
});
|
|
@@ -394,7 +438,21 @@ function isDate(dateString: string): boolean {
|
|
|
394
438
|
}
|
|
395
439
|
|
|
396
440
|
function encodeRef(val: EntityReference) {
|
|
397
|
-
return `ref::${val.path}/${val.id}`;
|
|
441
|
+
return `ref::${val.path}/${encodeEntityId(val.id)}`;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Split a "path/id" reference on its LAST separator: the path may itself be a
|
|
446
|
+
* subcollection path with several segments, and the id is escaped so it is always exactly
|
|
447
|
+
* one segment.
|
|
448
|
+
*/
|
|
449
|
+
function decodeRef(encoded: string): EntityReference {
|
|
450
|
+
const separatorIndex = encoded.lastIndexOf("/");
|
|
451
|
+
if (separatorIndex < 0) return new EntityReference(encoded, "");
|
|
452
|
+
return new EntityReference(
|
|
453
|
+
decodeEntityId(encoded.substring(separatorIndex + 1)),
|
|
454
|
+
encoded.substring(0, separatorIndex)
|
|
455
|
+
);
|
|
398
456
|
}
|
|
399
457
|
|
|
400
458
|
function decodeString(val: string): EntityReference | Date | string {
|
|
@@ -410,8 +468,7 @@ function decodeString(val: string): EntityReference | Date | string {
|
|
|
410
468
|
try {
|
|
411
469
|
parsedFilterVal = JSON.parse(parsedFilterVal, (key, value) => {
|
|
412
470
|
if (typeof value === "string" && value.startsWith("ref::")) {
|
|
413
|
-
|
|
414
|
-
return new EntityReference(id, path);
|
|
471
|
+
return decodeRef(value.substring(5));
|
|
415
472
|
}
|
|
416
473
|
return value;
|
|
417
474
|
});
|
|
@@ -421,8 +478,7 @@ function decodeString(val: string): EntityReference | Date | string {
|
|
|
421
478
|
}
|
|
422
479
|
|
|
423
480
|
if (typeof parsedFilterVal === "string" && parsedFilterVal.startsWith("ref::")) {
|
|
424
|
-
|
|
425
|
-
return new EntityReference(id, path);
|
|
481
|
+
return decodeRef(parsedFilterVal.substring(5));
|
|
426
482
|
}
|
|
427
483
|
return parsedFilterVal;
|
|
428
484
|
}
|