From 2bd04d51e9eb80c2db5b59de1e128c5e18a282d6 Mon Sep 17 00:00:00 2001 From: nboisteault Date: Tue, 1 Oct 2024 11:34:19 +0200 Subject: [PATCH] Action: display html message if given --- assets/src/components/ActionSelector.js | 6 +++--- assets/src/modules/Action.js | 6 ++++++ tests/qgis-projects/tests/set_tests_module_action.sql | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/src/components/ActionSelector.js b/assets/src/components/ActionSelector.js index 410b2e6bff..2757e2eec7 100644 --- a/assets/src/components/ActionSelector.js +++ b/assets/src/components/ActionSelector.js @@ -71,7 +71,7 @@ export default class ActionSelector extends HTMLElement { onActionSelectChange(event) { // Remove previous digitizing tool if any - document.querySelector('#project-action-selector-container lizmap-digitizing')?.remove(); + document.getElementById('action-digitizing')?.remove(); // Get the host component let host = event.target.closest("lizmap-action-selector"); @@ -97,8 +97,8 @@ export default class ActionSelector extends HTMLElement { description = action.description; } if (action?.geometry) { - this._digitizingElement = ``; - document.querySelector('.action-selector-container').insertAdjacentHTML('afterend', this._digitizingElement); + const actionDigitizing = `
`; + document.querySelector('.action-selector-container').insertAdjacentHTML('afterend', actionDigitizing); mainLizmap.digitizing.context = "action"; mainLizmap.digitizing.toggleVisibility(true); } else { diff --git a/assets/src/modules/Action.js b/assets/src/modules/Action.js index a2f66ce7aa..6cf675cc4f 100644 --- a/assets/src/modules/Action.js +++ b/assets/src/modules/Action.js @@ -456,6 +456,12 @@ export default class Action { if (message) { mainLizmap.lizmap3.addMessage(message, 'info', true).attr('id', 'lizmap-action-message'); } + + // Display the HTML message if given + const message_html = featureProperties?.message_html?.trim(); + if (message_html) { + document.getElementById('action-message-html').innerHTML = message_html; + } } } diff --git a/tests/qgis-projects/tests/set_tests_module_action.sql b/tests/qgis-projects/tests/set_tests_module_action.sql index ac3a48d6c3..ea82debc73 100644 --- a/tests/qgis-projects/tests/set_tests_module_action.sql +++ b/tests/qgis-projects/tests/set_tests_module_action.sql @@ -125,7 +125,8 @@ BEGIN ST_GeomFromText('%2$s', 4326)::geography, %3$s )::geometry(POLYGON, 4326) AS geom, - 'The displayed geometry represents the buffer %3$s m of the point drawn by the user' AS message + 'The displayed geometry represents the buffer %3$s m of the point drawn by the user' AS message, + '

The displayed geometry represents the buffer %3$s m of the point drawn by the user

' AS message_html $$, lizmap_project, wkt,