Skip to content

Commit

Permalink
PB-1004: Drawing polygone - Move delete point to right click
Browse files Browse the repository at this point in the history
  • Loading branch information
sommerfe committed Jan 27, 2025
1 parent ee67480 commit 4f2a7ab
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
13 changes: 11 additions & 2 deletions src/modules/drawing/components/useModifyInteraction.composable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { noModifierKeys, singleClick } from 'ol/events/condition'
import { doubleClick, noModifierKeys, primaryAction } from 'ol/events/condition'
import ModifyInteraction from 'ol/interaction/Modify'
import { computed, inject, onBeforeUnmount, onMounted, watch } from 'vue'
import { useStore } from 'vuex'
Expand Down Expand Up @@ -27,14 +27,23 @@ export default function useModifyInteraction(features) {
const reverseLineStringExtension = computed(
() => store.state.drawing.reverseLineStringExtension
)
const isPhoneMode = computed(() => store.getters.isPhoneMode)

const olMap = inject('olMap')
const { willModify, debounceSaveDrawing } = useSaveKmlOnChange()

const modifyInteraction = new ModifyInteraction({
features,
style: editingVertexStyleFunction,
deleteCondition: (event) => noModifierKeys(event) && singleClick(event),
condition: (event) =>
primaryAction(event) ||
(event.type === 'pointerdown' &&
event.originalEvent.button === 2 &&
noModifierKeys(event)), // To delete a point with right click (contextmenu) one has to first select the point and then right click on it, therefore this select vertex condition is needed
deleteCondition: (event) =>
isPhoneMode.value
? doubleClick(event)
: event.type === 'contextmenu' && noModifierKeys(event),
// This seems to be calculated differently than the hitTolerance properties of
// SelectInteraction and forEachFeatureAtPixel. That's why we have to manually correct the
// value here.
Expand Down
4 changes: 2 additions & 2 deletions src/modules/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@
"modify_color_label": "Farbe",
"modify_description": "Beschreibung",
"modify_existing_vertex_annotation": "Verschieben von Text: klicken und ziehen ",
"modify_existing_vertex_linepolygon": "Klicke, um den Punkt zu löschen (mind. 2 Punkte).<br/> Punkt verschieben: klicken und ziehen ",
"modify_existing_vertex_linepolygon": "Rechtsklicken, um den Punkt zu löschen (mind. 2 Punkte).<br/> Punkt verschieben: klicken und ziehen ",
"modify_existing_vertex_marker": "Verschieben des Symbols: klicken und ziehen ",
"modify_existing_vertex_measure": "Klicke, um den Punkt zu löschen (mind. 2 Punkte).<br/> Punkt verschieben: klicken und ziehen ",
"modify_existing_vertex_measure": "Rechtsklicken, um den Punkt zu löschen (mind. 2 Punkte).<br/> Punkt verschieben: klicken und ziehen ",
"modify_icon_category_babs-v2-de_label": "Zivile Signaturen",
"modify_icon_category_babs-v2-fr_label": "Zivile Signaturen",
"modify_icon_category_babs-v2-it_label": "Zivile Signaturen",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@
"modify_color_label": "Color",
"modify_description": "Description",
"modify_existing_vertex_annotation": "Click then drag to move the text",
"modify_existing_vertex_linepolygon": "Click to delete the point (2 points min.)<br/>Click then drag to move the point",
"modify_existing_vertex_linepolygon": "Right click to delete the point (2 points min.)<br/>Click then drag to move the point",
"modify_existing_vertex_marker": "Click then drag to move the marker",
"modify_existing_vertex_measure": "Click to delete the point (2 points min.)<br/>Click then drag to move the point",
"modify_existing_vertex_measure": "Right click to delete the point (2 points min.)<br/>Click then drag to move the point",
"modify_icon_category_babs-v2-de_label": "Civil symbols",
"modify_icon_category_babs-v2-fr_label": "Civil symbols",
"modify_icon_category_babs-v2-it_label": "Civil symbols",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@
"modify_color_label": "Couleur",
"modify_description": "Description",
"modify_existing_vertex_annotation": "Cliquer puis bouger le curseur pour déplacer l'annotation",
"modify_existing_vertex_linepolygon": "Cliquer pour supprimer le point (2 points min.)<br/>Cliquer puis bouger le curseur pour déplacer le point ",
"modify_existing_vertex_linepolygon": "Faire un clic droit pour supprimer le point (2 points min.)<br/>Cliquer puis bouger le curseur pour déplacer le point ",
"modify_existing_vertex_marker": "Cliquer puis bouger le curseur pour déplacer le symbole",
"modify_existing_vertex_measure": "Cliquer pour supprimer le point (2 points min.)<br/>Cliquer puis bouger le curseur pour déplacer le point",
"modify_existing_vertex_measure": "Faire un clic droit pour supprimer le point (2 points min.)<br/>Cliquer puis bouger le curseur pour déplacer le point",
"modify_icon_category_babs-v2-de_label": "Signes conventionnels civils",
"modify_icon_category_babs-v2-fr_label": "Signes conventionnels civils",
"modify_icon_category_babs-v2-it_label": "Signes conventionnels civils",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@
"modify_color_label": "Colore",
"modify_description": "Descrizione",
"modify_existing_vertex_annotation": "Cliccare quindi trascinare per spostare il testo",
"modify_existing_vertex_linepolygon": "Cliccare per eliminare il punto (2 punti min.)<br/>Cliccare quindi trascinare per spostare il punto",
"modify_existing_vertex_linepolygon": "Fare clic con il tasto destro del mouse per eliminare il punto (2 punti min.)<br/>Cliccare quindi trascinare per spostare il punto",
"modify_existing_vertex_marker": "Cliccare quindi trascinare per spostare il simbolo",
"modify_existing_vertex_measure": "Cliccare per eliminare il punto (2 punti min.)<br/>Cliccare quindi trascinare per spostare il punto",
"modify_existing_vertex_measure": "Fare clic con il tasto destro del mouse per eliminare il punto (2 punti min.)<br/>Cliccare quindi trascinare per spostare il punto",
"modify_icon_category_babs-v2-de_label": "Segni convenzionali civili",
"modify_icon_category_babs-v2-fr_label": "Segni convenzionali civili",
"modify_icon_category_babs-v2-it_label": "Segni convenzionali civili",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/i18n/locales/rm.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@
"modify_color_label": "Colur",
"modify_description": "Descripziun",
"modify_existing_vertex_annotation": "Spustar text :cliccar e trair",
"modify_existing_vertex_linepolygon": "Cliccar per stizzar il punct (2 puncts minimum).</br> Spustar punct :cliccar e trair",
"modify_existing_vertex_linepolygon": "Cliccar endretg per stizzar il punct (2 puncts minimum).</br> Spustar punct :cliccar e trair",
"modify_existing_vertex_marker": "Spustar signalisaziun :cliccar e trair",
"modify_existing_vertex_measure": "Cliccar per stizzar il punct (2 puncts minimum).</br> Spustar punct :cliccar e trair",
"modify_existing_vertex_measure": "Cliccar endretg per stizzar il punct (2 puncts minimum).</br> Spustar punct :cliccar e trair",
"modify_icon_category_babs-v2-de_label": "Zivile Signaturen",
"modify_icon_category_babs-v2-fr_label": "Zivile Signaturen",
"modify_icon_category_babs-v2-it_label": "Zivile Signaturen",
Expand Down
8 changes: 6 additions & 2 deletions tests/cypress/tests-e2e/drawing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ describe('Drawing module tests', () => {
cy.clickDrawingTool(EditableFeatureTypes.LINEPOLYGON)
cy.get('[data-cy="ol-map"]').click(100, 240)
cy.get('[data-cy="ol-map"]').click(150, 250)
cy.get('[data-cy="ol-map"]').click(190, 250)
cy.get('[data-cy="ol-map"]').dblclick(120, 270)
cy.wait('@profile')

Expand All @@ -1471,8 +1472,11 @@ describe('Drawing module tests', () => {
)
cy.get('[data-cy="profile-graph"]').trigger('mouseleave')

cy.log('check that profile gets updated when feature is modified')
cy.get('[data-cy="ol-map"]').click(150, 250)
cy.log('check that profile gets updated when feature is modified by removing a point')
// for mobile double click and on desktop right click
cy.get('[data-cy="ol-map"]').dblclick(190, 250)
cy.wait('@profile')
cy.get('[data-cy="ol-map"]').rightclick(150, 250)
cy.wait('@profile')

// clicking on the header of the profile container
Expand Down

0 comments on commit 4f2a7ab

Please sign in to comment.