Skip to content

Commit

Permalink
Action: display html message if given
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault committed Oct 1, 2024
1 parent 44a5636 commit 2bd04d5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions assets/src/components/ActionSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -97,8 +97,8 @@ export default class ActionSelector extends HTMLElement {
description = action.description;
}
if (action?.geometry) {
this._digitizingElement = `<lizmap-digitizing context="action" selected-tool="${action.geometry}" available-tools="${action.geometry}"></lizmap-digitizing>`;
document.querySelector('.action-selector-container').insertAdjacentHTML('afterend', this._digitizingElement);
const actionDigitizing = `<div id="action-digitizing"><lizmap-digitizing context="action" selected-tool="${action.geometry}" available-tools="${action.geometry}"></lizmap-digitizing><div id="action-message-html"></div></div>`;
document.querySelector('.action-selector-container').insertAdjacentHTML('afterend', actionDigitizing);
mainLizmap.digitizing.context = "action";
mainLizmap.digitizing.toggleVisibility(true);
} else {
Expand Down
6 changes: 6 additions & 0 deletions assets/src/modules/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/qgis-projects/tests/set_tests_module_action.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
'<p>The displayed geometry represents the buffer <strong>%3$s m</strong> of the point drawn by the user</p>' AS message_html
$$,
lizmap_project,
wkt,
Expand Down

0 comments on commit 2bd04d5

Please sign in to comment.