Compare commits

..

No commits in common. "2c64745c527956257da1e6a3d58f05cee546f322" and "7de3ebd2d18a1997175d37f181ce01dc3db2bc4d" have entirely different histories.

6 changed files with 16 additions and 38 deletions

View file

@ -35,7 +35,7 @@ dependencies = [
"Pillow==11.0.0", "Pillow==11.0.0",
"psycopg==3.2.3", "psycopg==3.2.3",
"requests==2.32.3", "requests==2.32.3",
"rcssmin==1.2.0", "rcssmin==1.1.3",
"rjsmin==1.2.3", "rjsmin==1.2.3",
"social-auth-core==4.5.4", "social-auth-core==4.5.4",
"social-auth-app-django==5.4.2", "social-auth-app-django==5.4.2",
@ -44,7 +44,7 @@ dependencies = [
[project.optional-dependencies] [project.optional-dependencies]
dev = [ dev = [
"hatch==1.13.0", "hatch==1.13.0",
"ruff==0.7.4", "ruff==0.7.3",
"djlint==1.36.1", "djlint==1.36.1",
"mkdocs==1.6.1", "mkdocs==1.6.1",
"mkdocs-material==9.5.44", "mkdocs-material==9.5.44",

View file

@ -35,7 +35,6 @@ class PopupTemplate {
feature.properties.description || '', feature.properties.description || '',
properties properties
) )
properties.name = properties.name ?? feature.getDisplayName()
let content = Utils.greedyTemplate(template, properties) let content = Utils.greedyTemplate(template, properties)
content = Utils.toHTML(content, { target: target }) content = Utils.toHTML(content, { target: target })
return Utils.loadTemplate(`<div class="umap-popup-container text">${content}</div>`) return Utils.loadTemplate(`<div class="umap-popup-container text">${content}</div>`)

View file

@ -196,10 +196,10 @@ export default class Rules {
constructor(umap) { constructor(umap) {
this._umap = umap this._umap = umap
this.rules = [] this.rules = []
this.load() this.loadRules()
} }
load() { loadRules() {
if (!this._umap.properties.rules?.length) return if (!this._umap.properties.rules?.length) return
for (const { condition, options } of this._umap.properties.rules) { for (const { condition, options } of this._umap.properties.rules) {
if (!condition) continue if (!condition) continue

View file

@ -18,7 +18,7 @@ export default class Slideshow extends WithTemplate {
this._umap = umap this._umap = umap
this._id = null this._id = null
this.CLASSNAME = 'umap-slideshow-active' this.CLASSNAME = 'umap-slideshow-active'
this.load() this.setProperties(properties)
this._current = null this._current = null
if (this.properties.autoplay) { if (this.properties.autoplay) {
@ -54,11 +54,7 @@ export default class Slideshow extends WithTemplate {
return this.current.getNext() return this.current.getNext()
} }
load() { setProperties(properties) {
this.setProperties(this._umap.properties.slideshow)
}
setProperties(properties = {}) {
this.properties = Object.assign( this.properties = Object.assign(
{ {
delay: 5000, delay: 5000,

View file

@ -94,7 +94,7 @@ export default class Umap extends ServerStored {
// Needed to render controls // Needed to render controls
this.permissions = new MapPermissions(this) this.permissions = new MapPermissions(this)
this.urls = new URLs(this.properties.urls) this.urls = new URLs(this.properties.urls)
this.slideshow = new Slideshow(this, this._leafletMap) this.slideshow = new Slideshow(this, this._leafletMap, this.properties.slideshow)
this._leafletMap.setup() this._leafletMap.setup()
@ -671,17 +671,6 @@ export default class Umap extends ServerStored {
this.permissions.properties = Object.assign({}, this._backupProperties.permissions) this.permissions.properties = Object.assign({}, this._backupProperties.permissions)
} }
setProperties(newProperties) {
for (const key of Object.keys(SCHEMA)) {
if (newProperties[key] !== undefined) {
this.properties[key] = newProperties[key]
if (key === 'rules') this.rules.load()
if (key === 'slideshow') this.slideshow.load()
// TODO: sync ?
}
}
}
hasData() { hasData() {
for (const datalayer of this.datalayersIndex) { for (const datalayer of this.datalayersIndex) {
if (datalayer.hasData()) return true if (datalayer.hasData()) return true
@ -1004,7 +993,7 @@ export default class Umap extends ServerStored {
], ],
] ]
const slideshowBuilder = new U.FormBuilder(this, slideshowFields, { const slideshowBuilder = new U.FormBuilder(this, slideshowFields, {
callback: () => this.slideshow.load(), callback: () => this.slideshow.setProperties(this.properties.slideshow),
umap: this, umap: this,
}) })
slideshow.appendChild(slideshowBuilder.build()) slideshow.appendChild(slideshowBuilder.build())
@ -1494,9 +1483,15 @@ export default class Umap extends ServerStored {
importRaw(rawData) { importRaw(rawData) {
const importedData = JSON.parse(rawData) const importedData = JSON.parse(rawData)
const mustReindex = 'sortKey' in Object.keys(importedData.properties)
this.setProperties(importedData.properties) let mustReindex = false
for (const option of Object.keys(SCHEMA)) {
if (typeof importedData.properties[option] !== 'undefined') {
this.properties[option] = importedData.properties[option]
if (option === 'sortKey') mustReindex = true
}
}
if (importedData.geometry) { if (importedData.geometry) {
this.properties.center = this._leafletMap.latLng(importedData.geometry) this.properties.center = this._leafletMap.latLng(importedData.geometry)

View file

@ -57,18 +57,6 @@ def test_should_handle_locale_var_in_description(live_server, map, page):
expect(link).to_have_attribute("href", "https://domain.org/?locale=en") 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): def test_should_display_tooltip_with_variable(live_server, map, page, bootstrap):
map.settings["properties"]["showLabel"] = True map.settings["properties"]["showLabel"] = True
map.settings["properties"]["labelKey"] = "Foo {name}" map.settings["properties"]["labelKey"] = "Foo {name}"