Merge pull request #1584 from umap-project/color-browser

fix: use variable for color in browser if any
This commit is contained in:
Yohan Boniface 2024-02-07 22:58:39 +01:00 committed by GitHub
commit a94a8b75cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View file

@ -22,7 +22,7 @@ L.U.Browser = L.Class.extend({
edit.title = L._('Edit this feature')
del.title = L._('Delete this feature')
title.textContent = feature.getDisplayName() || '—'
const bgcolor = feature.getOption('color')
const bgcolor = feature.getDynamicOption('color')
colorBox.style.backgroundColor = bgcolor
if (symbol && symbol !== this.map.options.default_iconUrl) {
const icon = L.U.Icon.makeIconElement(symbol, colorBox)

View file

@ -228,3 +228,22 @@ def test_should_show_header_for_display_on_load_false(
browser = page.locator(".umap-browse-data")
expect(browser).to_be_visible()
expect(browser.get_by_text("This layer is not loaded")).to_be_visible()
def test_should_use_color_variable(live_server, map, page):
map.settings["properties"]["onLoadPanel"] = "databrowser"
map.settings["properties"]["color"] = "{mycolor}"
map.save()
datalayer_data = deepcopy(DATALAYER_DATA)
datalayer_data["features"][0]["properties"]["mycolor"] = "DarkRed"
datalayer_data["features"][2]["properties"]["mycolor"] = "DarkGreen"
DataLayerFactory(map=map, data=datalayer_data)
page.goto(f"{live_server.url}{map.get_absolute_url()}")
features = page.locator(".umap-browse-data li .feature-color")
expect(features).to_have_count(3)
# DarkGreen
expect(features.nth(0)).to_have_css("background-color", "rgb(0, 100, 0)")
# DarkRed
expect(features.nth(1)).to_have_css("background-color", "rgb(139, 0, 0)")
# DarkBlue (default color)
expect(features.nth(2)).to_have_css("background-color", "rgb(0, 0, 139)")