From 38a642450cea95bce3e3c9946472fe47dea5d8ad Mon Sep 17 00:00:00 2001 From: Candid Dauth Date: Mon, 26 Feb 2024 20:09:33 +0100 Subject: [PATCH] Allow importing files that only contain types/views --- frontend/src/lib/components/import-tab.vue | 10 +++++++--- .../lib/components/search-results/search-results.vue | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/import-tab.vue b/frontend/src/lib/components/import-tab.vue index a35d62ed..9a43ffd2 100644 --- a/frontend/src/lib/components/import-tab.vue +++ b/frontend/src/lib/components/import-tab.vue @@ -82,16 +82,20 @@ ...await parseFiles(loadedFiles), title: (fileList.length == 1 && fileList[0].name) || pluralize("file", fileList.length, true) }; - if (result.features.length == 0 && result.errors) + const hasAnyItems = result.features.length > 0 || Object.keys(result.types).length > 0 || Object.keys(result.views).length > 0; + if (!hasAnyItems && result.errors) toasts.showErrorToast(`fm${context.id}-import-error`, "Parsing error", `The selected ${pluralize("file", fileList.length)} could not be parsed.`); - else if (result.features.length == 0) + else if (!hasAnyItems) toasts.showErrorToast(`fm${context.id}-import-error`, "No geometries", `The selected ${pluralize("file", fileList.length)} did not contain any geometries.`); else { if (result.errors) toasts.showErrorToast(`fm${context.id}-import-error`, "Parsing error", "Some of the selected files could not be parsed.", { variant: "warning" }); const layer = markRaw(new SearchResultsLayer(result.features, { pathOptions: { weight: 7 } }).addTo(mapContext.value.components.map)); - mapContext.value.components.map.flyToBounds(layer.getBounds()); + if (result.features.length > 0) { + mapContext.value.components.map.flyToBounds(layer.getBounds()); + } + mapContext.value.components.selectionHandler.addSearchResultLayer(layer); files.value.push(result); diff --git a/frontend/src/lib/components/search-results/search-results.vue b/frontend/src/lib/components/search-results/search-results.vue index 4b930ec1..e3a07a6d 100644 --- a/frontend/src/lib/components/search-results/search-results.vue +++ b/frontend/src/lib/components/search-results/search-results.vue @@ -162,6 +162,8 @@