Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: honour custom labelKey in default popup template #2271

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions umap/static/umap/js/modules/rendering/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class PopupTemplate {
feature.properties.description || '',
properties
)
properties.name = properties.name ?? feature.getDisplayName()
let content = Utils.greedyTemplate(template, properties)
content = Utils.toHTML(content, { target: target })
return Utils.loadTemplate(`<div class="umap-popup-container text">${content}</div>`)
Expand Down
12 changes: 12 additions & 0 deletions umap/tests/integration/test_view_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ def test_should_handle_locale_var_in_description(live_server, map, page):
expect(link).to_have_attribute("href", "https://domain.org/?locale=en")


def test_should_use_custom_label_key_in_popup_default_template(live_server, map, page):
data = deepcopy(DATALAYER_DATA)
data["features"][0]["properties"] = {
"libellé": "my custom label",
}
data["_umap_options"] = {"labelKey": "libellé"}
DataLayerFactory(map=map, data=data)
page.goto(f"{live_server.url}{map.get_absolute_url()}")
page.locator(".leaflet-marker-icon").click()
expect(page.locator(".umap-popup h4")).to_have_text("my custom label")


def test_should_display_tooltip_with_variable(live_server, map, page, bootstrap):
map.settings["properties"]["showLabel"] = True
map.settings["properties"]["labelKey"] = "Foo {name}"
Expand Down