diff --git a/assets/src/components/Digitizing.js b/assets/src/components/Digitizing.js index f4cfce15c2..90f088dbaf 100644 --- a/assets/src/components/Digitizing.js +++ b/assets/src/components/Digitizing.js @@ -41,6 +41,7 @@ import '../images/svg/file-upload.svg'; * It is mandatory and provide a way to use this element for different contexts. * * The other attributes are: + * active - Activate the element on load or when the attribute is added * selected-tool - Start selected drawing tools one of DigitizingAvailableTools or available-tools * available-tools - List of available drawing tools based on DigitizingAvailableTools * save - Enable save capability @@ -50,6 +51,7 @@ import '../images/svg/file-upload.svg'; * @example Example of use * { @@ -46,11 +47,46 @@ export default class Edition { mainEventDispatcher.dispatch('edition.formDisplayed'); }, lizmapeditionformclosed: () => { + this.deactivateDigitizing(); mainEventDispatcher.dispatch('edition.formClosed'); } }); } + /** + * Get the lizmap-digitizing element + * @returns {HTMLElement|null} The digitizing element or null if not found + */ + get digitizingElement() { + return document.querySelector('lizmap-digitizing[context="draw"]'); + } + + /** + * Activate the lizmap-digitizing web component when feature editing starts + * @private + */ + activateDigitizing() { + if (this.layerGeometry) { + const digitizingElement = this.digitizingElement; + if (digitizingElement) { + // Activate the component using the active attribute + digitizingElement.setAttribute('active', ''); + } + } + } + + /** + * Deactivate the lizmap-digitizing web component when feature editing ends + * @private + */ + deactivateDigitizing() { + const digitizingElement = this.digitizingElement; + if (digitizingElement) { + // Remove the active attribute to deactivate the component + digitizingElement.removeAttribute('active'); + } + } + get layerId() { return this._layerId; } diff --git a/lizmap/modules/view/templates/map_edition.tpl b/lizmap/modules/view/templates/map_edition.tpl index d47a7fa0c1..7e9ebb10b7 100644 --- a/lizmap/modules/view/templates/map_edition.tpl +++ b/lizmap/modules/view/templates/map_edition.tpl @@ -35,112 +35,12 @@
- - - - -
-
-
-
-

{@view~edition.point.coord.title@}

-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
- - -
-
- - -
-
- - -
- -
-
-
+
diff --git a/tests/end2end/playwright/dnd-form.spec.js b/tests/end2end/playwright/dnd-form.spec.js index ff6b75cb66..793c1eba7c 100644 --- a/tests/end2end/playwright/dnd-form.spec.js +++ b/tests/end2end/playwright/dnd-form.spec.js @@ -20,7 +20,7 @@ test.describe( await project.dock.getByText('tab2').click(); await project.editingField('field_in_dnd_form').fill('value in DND form'); - await project.clickOnMapLegacy(600, 200); + await project.clickOnMap(600, 200); await project.editingSubmitForm(); const ids = await editedFeatureIds(page); diff --git a/tests/end2end/playwright/editing-geometry.spec.js b/tests/end2end/playwright/editing-geometry.spec.js index d88e83a112..18cfc7be5c 100644 --- a/tests/end2end/playwright/editing-geometry.spec.js +++ b/tests/end2end/playwright/editing-geometry.spec.js @@ -33,12 +33,12 @@ test.describe('Geometry editing', const x1 = 600; const y1 = 200; - await project.clickOnMapLegacy(x1, y1); + await project.clickOnMap(x1, y1); if (geom === 'polygon'){ - await project.clickOnMapLegacy(x1, y1 + 100); + await project.clickOnMap(x1, y1 + 100); } if (geom === 'line' || geom === 'polygon') { - await project.dblClickOnMapLegacy(x1 + 100, y1); + await project.dblClickOnMap(x1 + 100, y1); } await project.editingSubmitForm(); diff --git a/tests/end2end/playwright/editing-value-relation.spec.js b/tests/end2end/playwright/editing-value-relation.spec.js index 91b7c4ee33..0d579dbe77 100644 --- a/tests/end2end/playwright/editing-value-relation.spec.js +++ b/tests/end2end/playwright/editing-value-relation.spec.js @@ -15,11 +15,11 @@ test.describe('Value relation widget', const select = await page.locator("#jforms_view_edition_code_with_geom_exp"); - await project.clickOnMapLegacy(650, 200); + await project.clickOnMap(650, 200); await select.selectOption({value: ''}); - await project.mapOl2.dragTo(project.mapOl2, { + await project.map.dragTo(project.map, { sourcePosition: { x: 650, y: 200 }, targetPosition: { x: 500, y: 200 }, }); diff --git a/tests/end2end/playwright/edition-form.spec.js b/tests/end2end/playwright/edition-form.spec.js index 09d327ce29..2a1f97e87d 100644 --- a/tests/end2end/playwright/edition-form.spec.js +++ b/tests/end2end/playwright/edition-form.spec.js @@ -705,7 +705,7 @@ test.describe( await project.checkEditionFormTextField('Name check', '', 'Name check', true); // insert a point feature - await project.clickOnMapLegacy(488, 331); + await project.clickOnMap(488, 331); // fill the form await project.fillEditionFormTextInput('point_name', 'text insert'); let editFeatureRequestPromiseUpdate = page.waitForResponse(response => response.url().includes('editFeature')); diff --git a/tests/end2end/playwright/form_advanced.spec.js b/tests/end2end/playwright/form_advanced.spec.js index f90ffa2467..a2512f4574 100644 --- a/tests/end2end/playwright/form_advanced.spec.js +++ b/tests/end2end/playwright/form_advanced.spec.js @@ -17,7 +17,7 @@ test.describe('Advanced form', function () { const getDataPromise = page.waitForResponse(/jelix\/forms\/getdata/) // Click on map as form needs a geometry - project.clickOnMapLegacy(410, 175); + project.clickOnMap(410, 175); // wait for the response completed let getDataResponse = await getDataPromise; @@ -149,7 +149,7 @@ test.describe('Advanced form', function () { request.postData()?.includes('_ref=sousquartier') ); // Assert quartier value is good for another drawn point - project.clickOnMapLegacy(455, 250); + project.clickOnMap(455, 250); // Wait for GetData quartier completed (based on geometry) let getDataQuartier = await (await getDataQuartierPromise).response(); expect(getDataQuartier.status()).toBe(200); diff --git a/tests/end2end/playwright/form_edition.spec.js b/tests/end2end/playwright/form_edition.spec.js index b17c45295c..ab4d78ada8 100644 --- a/tests/end2end/playwright/form_edition.spec.js +++ b/tests/end2end/playwright/form_edition.spec.js @@ -135,7 +135,7 @@ test.describe('Form edition', function () { await expect(page.locator('#edition .edition-tabs')).toBeVisible(); await expect(page.locator('#edition-form-container')).toBeVisible(); - await project.clickOnMapLegacy(630-30 , 325-75); + await project.clickOnMap(630-30 , 325-75); // submit the form saveFeatureRequestPromise = page.waitForRequest(/lizmap\/edition\/saveFeature/); diff --git a/tests/end2end/playwright/form_edition_value_relation_field.spec.js b/tests/end2end/playwright/form_edition_value_relation_field.spec.js index 4744d393ef..4ea06a9681 100644 --- a/tests/end2end/playwright/form_edition_value_relation_field.spec.js +++ b/tests/end2end/playwright/form_edition_value_relation_field.spec.js @@ -248,7 +248,7 @@ test.describe('Form edition all field type', function () { // Intercept getData query to wait for its end let getDataRequestPromise = page.waitForRequest(/jelix\/forms\/getdata/); // Click on the map over Zone A1 - project.clickOnMapLegacy(530-150, 375-50); + project.clickOnMap(530-150, 375-50); // Wait for getData query ends, check request parameters and response let getDataRequest = await getDataRequestPromise; let getDataExpectedParameters = { diff --git a/tests/end2end/playwright/singleWMS.spec.js b/tests/end2end/playwright/singleWMS.spec.js index 9570e38060..ea3591418f 100644 --- a/tests/end2end/playwright/singleWMS.spec.js +++ b/tests/end2end/playwright/singleWMS.spec.js @@ -393,7 +393,7 @@ test.describe('Single WMS layer', () => { await formRequest.response(); // edition id done on #map - await project.clickOnMapLegacy(532, 293); + await project.clickOnMap(532, 293); await project.fillEditionFormTextInput('title', 'Test insert'); // submit the form