Skip to content

Commit

Permalink
Merge pull request #1222 from geoadmin/fix-pb-1004-delete-point-right…
Browse files Browse the repository at this point in the history
…-click

PB-1004: Drawing polygone - Move delete point to right click
  • Loading branch information
sommerfe authored Jan 29, 2025
2 parents 1658eeb + 6170e26 commit 6edf3a2
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 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
2 changes: 1 addition & 1 deletion tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ Cypress.Commands.add('writeStoreValue', (action, value) => {

// Reads a value from the window
Cypress.Commands.add('readWindowValue', (key) => {
return cy.window().its(key)
return cy.window({ timeout: 15000 }).its(key)
})

// from https://github.com/cypress-io/cypress/issues/1123#issuecomment-672640129
Expand Down
14 changes: 10 additions & 4 deletions tests/cypress/tests-e2e/drawing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ describe('Drawing module tests', () => {
cy.wrap(offset[0]).should('be.lessThan', 0)
cy.wrap(offset[1]).should('be.lessThan', 0)
})

cy.wait('@update-kml')
.its('request')
.should((request) =>
Expand All @@ -262,8 +261,11 @@ describe('Drawing module tests', () => {
),
])
)
cy.get('[data-cy="drawing-style-text-button"]').click()

cy.viewport(320, 600)
cy.get('[data-cy="close-popover-button"]').click()
cy.get('[data-cy="drawing-style-text-popup"]').should('not.exist')
cy.viewport(320, 568)

// changing/editing the description of this marker
const description = 'A description for this marker'
Expand Down Expand Up @@ -1447,6 +1449,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 +1474,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 6edf3a2

Please sign in to comment.