From 51c3f221935ee6a43a9c6e6db958ef374100b417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez=20Mu=C3=B1oz?= Date: Thu, 16 Nov 2023 16:55:13 +0100 Subject: [PATCH] excludes platform-wide features from selected counter and bulk operation --- .../project/inventory-panel/features/index.tsx | 18 +++++++++--------- .../features/modals/delete/index.tsx | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/layout/project/sidebar/project/inventory-panel/features/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/index.tsx index 6ba7a9dbd3..e97438309a 100644 --- a/app/layout/project/sidebar/project/inventory-panel/features/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/features/index.tsx @@ -87,7 +87,9 @@ const InventoryPanelFeatures = ({ noData: noDataMessage }: { noData: string }): } ); - const featureIds = allFeaturesQuery.data?.map((feature) => feature.id); + const featureIds = allFeaturesQuery.data + ?.filter(({ isCustom }) => isCustom) + .map((feature) => feature.id); const handleSelectAll = useCallback( (evt: ChangeEvent) => { @@ -131,14 +133,6 @@ const InventoryPanelFeatures = ({ noData: noDataMessage }: { noData: string }): const feature = allFeaturesQuery.data?.find(({ id }) => featureId === id); const isContinuous = feature.amountRange.min !== null && feature.amountRange.max !== null; - // const isIncluded = newSelectedFeatures.includes(featureId); - // if (!isIncluded) { - // newSelectedFeatures.push(featureId); - // } else { - // const i = newSelectedFeatures.indexOf(featureId); - // newSelectedFeatures.splice(i, 1); - // } - if (isContinuous) { if (!isIncludedInContinuous) { continuousFeatures.push(featureId); @@ -184,6 +178,12 @@ const InventoryPanelFeatures = ({ noData: noDataMessage }: { noData: string }): isVisibleOnMap: layerSettings[feature.id]?.visibility ?? false, })); + useEffect(() => { + if (allFeaturesQuery.isRefetching) { + setSelectedFeaturesIds([]); + } + }, [allFeaturesQuery.isRefetching]); + return (
diff --git a/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx index 4073ca02f8..5473f5d3ff 100644 --- a/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx +++ b/app/layout/project/sidebar/project/inventory-panel/features/modals/delete/index.tsx @@ -36,7 +36,7 @@ const DeleteModal = ({ .getQueryData<{ data: Feature[]; meta: Pagination }>(['all-features', pid], { exact: false, }) - ?.data?.filter(({ id, isCustom }) => selectedFeaturesIds.includes(id) && isCustom) ?? [], + ?.data?.filter(({ id }) => selectedFeaturesIds.includes(id)) ?? [], [queryClient, selectedFeaturesIds, pid] );