From 72852553570891892060c7d9039a67190c823d06 Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Tue, 26 Nov 2024 16:13:08 +0700 Subject: [PATCH 1/8] PB-1212: Allow delete last point by button when on line editing mode. --- .../drawing/components/DrawingInteractions.vue | 1 + .../components/DrawingSelectInteraction.vue | 3 ++- .../drawing/components/DrawingToolbox.vue | 17 ++++++++++++++++- .../useModifyInteraction.composable.js | 10 +++++++++- 4 files changed, 28 insertions(+), 3 deletions(-) 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..6211bdbe7 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,20 @@ const isDrawingLineOrMeasure = computed(() => currentDrawingMode.value ) ) +const selectedEditableFeatures = computed(() => store.state.features.selectedEditableFeatures) +const isSelectedALine = computed(() => { + if (selectedEditableFeatures.value && selectedEditableFeatures.value.length > 0) { + const selectedFeature = selectedEditableFeatures.value[0] + return ( + selectedFeature.geometry.type === 'LineString' && + (selectedFeature.featureType === EditableFeatureTypes.LINEPOLYGON || + selectedFeature.featureType === EditableFeatureTypes.MEASURE) + ) + } + return false +}) +const editMode = computed(() => store.state.drawing.editingMode) +const isEditingLineMode = computed(() => editMode.value !== EditMode.OFF && isSelectedALine.value) const activeKmlLayer = computed(() => store.getters.activeKmlLayer) const drawingName = computed({ get: () => store.state.drawing.name, @@ -208,7 +223,7 @@ const debounceSaveDrawingName = debounce(async (newName) => { -
+
-
+