Skip to content

Commit

Permalink
PB-1299: Going into drawing module with pre-loaded empty KML breaks t…
Browse files Browse the repository at this point in the history
…he drawing module
  • Loading branch information
sommerfe committed Jan 23, 2025
1 parent 19b95ea commit d09be62
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/modules/drawing/DrawingModule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const showAddVertexButton = computed(() => {
const hasKml = computed(() => {
if (online.value) {
return !!activeKmlLayer.value
return !!activeKmlLayer.value && !activeKmlLayer.value.isEmpty()
}
return !!store.state.layers.systemLayers.find(
(l) => l.id === store.state.drawing.temporaryKmlId
Expand Down
6 changes: 6 additions & 0 deletions src/modules/drawing/components/DrawingToolbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ function onCloseClearConfirmation(confirmed) {
drawingLayer.getSource().clear()
debounceSaveDrawing()
store.dispatch('setDrawingMode', { mode: null, ...dispatcher })
store.dispatch('removeLayer', {
layerId: activeKmlLayer.value.id,
isExternal: activeKmlLayer.value.isExternal,
baseUrl: activeKmlLayer.value.baseUrl,
...dispatcher,
})
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/modules/drawing/useKmlDataManagement.composable.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ export default function useSaveKmlOnChange(drawingLayerDirectReference) {
...dispatcher,
})
}
await store.dispatch('addLayer', {
layer: kmlLayer,
...dispatcher,
})
if (!kmlLayer.isEmpty()) {
await store.dispatch('addLayer', {
layer: kmlLayer,
...dispatcher,
})
}
} else {
// if a KMLLayer is already defined, we update it
const kmlMetadata = await updateKml(
Expand Down
6 changes: 1 addition & 5 deletions src/views/MapView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ const showDragAndDropOverlay = computed(() => store.state.ui.showDragAndDropOver
const isOpeningNewTab = computed(() => store.state.ui.isOpeningNewTab)
const showNotSharedDrawingWarning = computed(() => store.getters.showNotSharedDrawingWarning)
const loadDrawingModule = computed(() => {
return (
(!activeKmlLayer.value || activeKmlLayer.value?.kmlData) &&
isDrawingMode.value &&
!is3DActive.value
)
return isDrawingMode.value && !is3DActive.value
})
onMounted(() => {
Expand Down

0 comments on commit d09be62

Please sign in to comment.