From cd4b2189eecc88a37e6d514fd321a3789234b9a3 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 11 Sep 2024 10:00:13 +0200 Subject: [PATCH] fix: delete shape from edit toolbar fix #2124 --- umap/static/umap/js/umap.controls.js | 2 +- umap/tests/integration/test_draw_polyline.py | 32 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 8fc6a5df..41953d16 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -231,7 +231,7 @@ U.DeleteShapeAction = U.BaseFeatureAction.extend({ }, onClick: function (e) { - this.feature.enableEdit().deleteShapeAt(e.latlng) + this.feature.ui.enableEdit().deleteShapeAt(e.latlng) }, }) diff --git a/umap/tests/integration/test_draw_polyline.py b/umap/tests/integration/test_draw_polyline.py index 6043fa94..d652365e 100644 --- a/umap/tests/integration/test_draw_polyline.py +++ b/umap/tests/integration/test_draw_polyline.py @@ -319,3 +319,35 @@ def test_can_transform_polyline_to_polygon(live_server, page, tilelayer, setting data = save_and_get_json(page) assert len(data["features"]) == 1 assert data["features"][0]["geometry"]["type"] == "Polygon" + + +def test_can_delete_shape_using_toolbar(live_server, page, tilelayer, settings): + settings.UMAP_ALLOW_ANONYMOUS = True + page.goto(f"{live_server.url}/en/map/new/") + page.get_by_title("Draw a polyline").click() + map = page.locator("#map") + map.click(position={"x": 200, "y": 100}) + map.click(position={"x": 100, "y": 100}) + map.click(position={"x": 100, "y": 200}) + map.click(position={"x": 100, "y": 200}) + + # Now split the line + map.click(position={"x": 100, "y": 100}) + page.get_by_role("link", name="Split line").click() + + # Delete part of it + map.click(position={"x": 125, "y": 100}) + page.get_by_role("link", name="Delete this shape").click() + data = save_and_get_json(page) + assert len(data["features"]) == 1 + assert data["features"][0]["geometry"]["type"] == "LineString" + assert data["features"][0]["geometry"]["coordinates"] == [ + [ + -9.865723, + 54.457267, + ], + [ + -9.865723, + 53.159947, + ], + ]