Merge pull request #1766 from umap-project/redraw-popup-on-marker-change
fix: redraw popup on marker’s modifications
This commit is contained in:
commit
dc40addef4
2 changed files with 31 additions and 7 deletions
|
@ -65,9 +65,8 @@ U.FeatureMixin = {
|
||||||
},
|
},
|
||||||
|
|
||||||
view: function (e) {
|
view: function (e) {
|
||||||
if (this.map.editEnabled) return
|
const outlink = this.getOption('outlink')
|
||||||
const outlink = this.getOption('outlink'),
|
const target = this.getOption('outlinkTarget')
|
||||||
target = this.getOption('outlinkTarget')
|
|
||||||
if (outlink) {
|
if (outlink) {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case 'self':
|
case 'self':
|
||||||
|
@ -77,19 +76,31 @@ U.FeatureMixin = {
|
||||||
window.top.location = outlink
|
window.top.location = outlink
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
const win = window.open(this.properties._umap_options.outlink)
|
window.open(this.properties._umap_options.outlink)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO deal with an event instead?
|
// TODO deal with an event instead?
|
||||||
if (this.map.slideshow) this.map.slideshow.current = this
|
if (this.map.slideshow) {
|
||||||
|
this.map.slideshow.current = this
|
||||||
|
}
|
||||||
this.map.currentFeature = this
|
this.map.currentFeature = this
|
||||||
this.attachPopup()
|
this.attachPopup()
|
||||||
this.openPopup((e && e.latlng) || this.getCenter())
|
this.openPopup(e?.latlng || this.getCenter())
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function (fields) {
|
||||||
|
const impactData = fields.some((field) => {
|
||||||
|
return field.startsWith('properties.')
|
||||||
|
})
|
||||||
|
if (impactData) {
|
||||||
|
if (this.map.currentFeature === this) {
|
||||||
|
this.view()
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
openPopup: function () {
|
openPopup: function () {
|
||||||
if (this.map.editEnabled) return
|
|
||||||
this.parentClass.prototype.openPopup.apply(this, arguments)
|
this.parentClass.prototype.openPopup.apply(this, arguments)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,19 @@ def test_should_open_an_edit_toolbar_on_click(live_server, openmap, page, bootst
|
||||||
expect(page.get_by_role("link", name="Delete this feature")).to_be_visible()
|
expect(page.get_by_role("link", name="Delete this feature")).to_be_visible()
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_update_open_popup_on_edit(live_server, openmap, page, bootstrap):
|
||||||
|
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
|
||||||
|
expect(page.locator(".umap-icon-active")).to_be_hidden()
|
||||||
|
page.locator(".leaflet-marker-icon").click()
|
||||||
|
expect(page.locator(".leaflet-popup-content-wrapper")).to_be_visible()
|
||||||
|
expect(page.get_by_role("heading", name="test marker")).to_be_visible()
|
||||||
|
expect(page.get_by_text("Some description")).to_be_visible()
|
||||||
|
page.get_by_role("button", name="Edit").click()
|
||||||
|
page.locator(".leaflet-marker-icon").click(modifiers=["Shift"])
|
||||||
|
page.locator('input[name="name"]').fill("test marker edited")
|
||||||
|
expect(page.get_by_role("heading", name="test marker edited")).to_be_visible()
|
||||||
|
|
||||||
|
|
||||||
def test_should_follow_datalayer_style_when_changing_datalayer(
|
def test_should_follow_datalayer_style_when_changing_datalayer(
|
||||||
live_server, openmap, page
|
live_server, openmap, page
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in a new issue