Skip to content

Commit

Permalink
Allow importing files that only contain types/views
Browse files Browse the repository at this point in the history
  • Loading branch information
cdauth committed Feb 26, 2024
1 parent df78811 commit 38a6424
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions frontend/src/lib/components/import-tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/components/search-results/search-results.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@
<div class="carousel slide fm-flex-carousel" ref="carouselRef">
<div class="carousel-item" :class="{ active: carousel.tab === 0 }">
<div class="fm-search-box-collapse-point">
<slot name="before"></slot>

<div
v-if="(!searchResults || searchResults.length == 0) && (!mapResults || mapResults.length == 0)"
class="alert alert-danger"
>
No results have been found.
</div>

<slot name="before"></slot>

<ul v-if="mapResults && mapResults.length > 0" class="list-group">
<!-- eslint-disable-next-line vue/require-v-for-key -->
<li
Expand Down

0 comments on commit 38a6424

Please sign in to comment.