From d47486969c424e386fd0f7f96b1eeaeacbbd88a5 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 15:31:47 +0100
Subject: [PATCH 1/3] invalidates cache of tags after feature removal
---
.../project/inventory-panel/features/modals/delete/index.tsx | 1 +
1 file changed, 1 insertion(+)
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..7eb51710b4 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
@@ -52,6 +52,7 @@ const DeleteModal = ({
bulkDeleteFeatureFromProject(pid, deletableFeatureIds, session)
.then(async () => {
await queryClient.invalidateQueries(['all-features', pid]);
+ await queryClient.invalidateQueries(['project-tags', pid]);
onDismiss();
From 9b23707fc324830c03ceb44b4ce9ee8926b5fe65 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 15:32:34 +0100
Subject: [PATCH 2/3] fixes issue typing tag after opening modal twice or more
---
.../features/modals/upload/index.tsx | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx
index 4417304f2a..5b4886677e 100644
--- a/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx
+++ b/app/layout/project/sidebar/project/inventory-panel/features/modals/upload/index.tsx
@@ -224,9 +224,10 @@ export const FeatureUploadModal = ({
const handleKeyPress = useCallback(
(event: Parameters['onKeyDown']>[0]) => {
+ formRef.current.change('tag', event.currentTarget.value);
+
if (event.key === 'Enter') {
setTagIsDone(true);
- formRef.current.change('tag', event.currentTarget.value);
setTagsMenuOpen(false);
}
},
@@ -260,6 +261,12 @@ export const FeatureUploadModal = ({
);
}, [pid, downloadShapefileTemplateMutation, addToast]);
+ useEffect(() => {
+ if (!isOpen) {
+ setTagIsDone(false);
+ }
+ }, [setTagIsDone, isOpen]);
+
return (
@@ -329,8 +336,9 @@ export const FeatureUploadModal = ({
className="h-10 w-full rounded-md border border-gray-600 px-3 text-gray-900 focus:border-none focus:outline-none focus:ring-1 focus:ring-blue-600"
placeholder="Type to pick or create tag..."
value={fprops.input.value}
- onFocus={() => setTagsMenuOpen(true)}
- onBlur={() => setTagIsDone(true)}
+ onFocus={() => {
+ setTagsMenuOpen(true);
+ }}
onKeyDown={handleKeyPress}
/>
@@ -370,7 +378,7 @@ export const FeatureUploadModal = ({
>
From a54883ecef0c2ef1750fc9a1330319145aa13da4 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 17:50:25 +0100
Subject: [PATCH 3/3] invalidates tags cache on feature upload
---
.../features/modals/edit-bulk/index.tsx | 4 ++--
.../inventory-panel/features/modals/edit/index.tsx | 4 ++--
.../inventory-panel/features/modals/upload/index.tsx | 10 +++++++---
.../features/add/add-modal/uploader/component.tsx | 4 ++--
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/app/layout/project/sidebar/project/inventory-panel/features/modals/edit-bulk/index.tsx b/app/layout/project/sidebar/project/inventory-panel/features/modals/edit-bulk/index.tsx
index a7232b7521..1f3cecc240 100644
--- a/app/layout/project/sidebar/project/inventory-panel/features/modals/edit-bulk/index.tsx
+++ b/app/layout/project/sidebar/project/inventory-panel/features/modals/edit-bulk/index.tsx
@@ -191,11 +191,11 @@ const EditBulkModal = ({
)}
- {tagsMenuOpen && (
+ {tagsMenuOpen && tagsQuery.data?.length > 0 && (
Recent:
- {tagsQuery.data?.map((tag) => (
+ {tagsQuery.data.map((tag) => (
- {tagsMenuOpen && (
+ {tagsMenuOpen && tagsQuery.data?.length > 0 && (
Recent:
- {tagsQuery.data?.map((tag) => (
+ {tagsQuery.data.map((tag) => (