diff --git a/src/modules/drawing/DrawingModule.vue b/src/modules/drawing/DrawingModule.vue index 2d30f6781..da7e2f193 100644 --- a/src/modules/drawing/DrawingModule.vue +++ b/src/modules/drawing/DrawingModule.vue @@ -34,9 +34,10 @@ const activeKmlLayer = computed(() => store.getters.activeKmlLayer) const featureIds = computed(() => store.state.drawing.featureIds) const isDrawingEmpty = computed(() => store.getters.isDrawingEmpty) const noFeatureInfo = computed(() => store.getters.noFeatureInfo) +const currentDrawingMode = computed(() => store.state.drawing.mode) const online = computed(() => store.state.drawing.online) const selectedEditableFeatures = computed(() => store.state.features.selectedEditableFeatures) -const selectedLineString = computed(() => { +const selectedLineFeature = computed(() => { if (selectedEditableFeatures.value && selectedEditableFeatures.value.length > 0) { const selectedFeature = selectedEditableFeatures.value[0] if ( @@ -50,7 +51,7 @@ const selectedLineString = computed(() => { return null }) const showAddVertexButton = computed(() => { - return store.state.drawing.editingMode === EditMode.MODIFY && !!selectedLineString.value + return store.state.drawing.editingMode === EditMode.MODIFY && !!selectedLineFeature.value }) const hasKml = computed(() => { @@ -200,7 +201,10 @@ function createSourceForProjection() { }) } function removeLastPoint() { - drawingInteractions.value.removeLastPoint() + // Only active on drawing mode + if (currentDrawingMode.value) { + drawingInteractions.value.removeLastPoint() + } } function removeLastPointOnDeleteKeyUp(event) { @@ -242,7 +246,7 @@ async function closeDrawing() { diff --git a/src/modules/drawing/components/AddVertexButton.vue b/src/modules/drawing/components/AddVertexButton.vue index 3df450d6d..452886e81 100644 --- a/src/modules/drawing/components/AddVertexButton.vue +++ b/src/modules/drawing/components/AddVertexButton.vue @@ -1,7 +1,6 @@ diff --git a/src/modules/drawing/components/DrawingInteractions.vue b/src/modules/drawing/components/DrawingInteractions.vue index fbeb11889..61ab2205c 100644 --- a/src/modules/drawing/components/DrawingInteractions.vue +++ b/src/modules/drawing/components/DrawingInteractions.vue @@ -38,6 +38,7 @@ function removeLastPoint() { if (currentInteraction.value?.removeLastPoint) { currentInteraction.value.removeLastPoint() } + selectInteraction.value.removeLastPoint() } defineExpose({ removeLastPoint, diff --git a/src/modules/drawing/components/DrawingSelectInteraction.vue b/src/modules/drawing/components/DrawingSelectInteraction.vue index 01f1fa5ed..1a4fb2d7c 100644 --- a/src/modules/drawing/components/DrawingSelectInteraction.vue +++ b/src/modules/drawing/components/DrawingSelectInteraction.vue @@ -30,7 +30,7 @@ const selectInteraction = new SelectInteraction({ // to select. We will try to add a bigger hit tolerance to mitigate that. hitTolerance: DRAWING_HIT_TOLERANCE, }) -useModifyInteraction(selectInteraction.getFeatures()) +const { removeLastPoint } = useModifyInteraction(selectInteraction.getFeatures()) /** OpenLayers feature currently selected */ const currentlySelectedFeature = ref(null) @@ -116,6 +116,7 @@ function selectFeature(feature) { defineExpose({ selectFeature, + removeLastPoint, }) diff --git a/src/modules/drawing/components/DrawingToolbox.vue b/src/modules/drawing/components/DrawingToolbox.vue index 1d60a76ae..06ae91985 100644 --- a/src/modules/drawing/components/DrawingToolbox.vue +++ b/src/modules/drawing/components/DrawingToolbox.vue @@ -12,6 +12,7 @@ import DrawingToolboxButton from '@/modules/drawing/components/DrawingToolboxBut import SharePopup from '@/modules/drawing/components/SharePopup.vue' import { DrawingState } from '@/modules/drawing/lib/export-utils' import useSaveKmlOnChange from '@/modules/drawing/useKmlDataManagement.composable' +import { EditMode } from '@/store/modules/drawing.store' import ModalWithBackdrop from '@/utils/components/ModalWithBackdrop.vue' import { useTippyTooltip } from '@/utils/composables/useTippyTooltip' import debounce from '@/utils/debounce' @@ -38,6 +39,31 @@ const isDrawingLineOrMeasure = computed(() => currentDrawingMode.value ) ) +const selectedEditableFeatures = computed(() => store.state.features.selectedEditableFeatures) +const selectedLineString = computed(() => { + return selectedEditableFeatures.value.find((feature) => { + return ( + feature.geometry.type === 'LineString' && + [EditableFeatureTypes.LINEPOLYGON, EditableFeatureTypes.MEASURE].includes( + feature.featureType + ) + ) + }) +}) + +const selectedLineCoordinates = computed(() => { + if (selectedLineString.value) { + return selectedLineString.value.geometry.coordinates + } + return null +}) +const editMode = computed(() => store.state.drawing.editingMode) +const isAllowDeletePointOnSelectedLine = computed( + () => + editMode.value !== EditMode.OFF && + selectedLineString.value && + selectedLineCoordinates.value?.length > 2 +) const activeKmlLayer = computed(() => store.getters.activeKmlLayer) const drawingName = computed({ get: () => store.state.drawing.name, @@ -208,7 +234,10 @@ const debounceSaveDrawingName = debounce(async (newName) => { -
+