Picto field: fix clicking on preview to open the form

This commit is contained in:
Yohan Boniface 2023-11-16 11:40:18 +01:00
parent cdfcce297d
commit c99892b51e
3 changed files with 10 additions and 15 deletions

View file

@ -535,6 +535,7 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
onDefine: function () { onDefine: function () {
this.buttons.innerHTML = '' this.buttons.innerHTML = ''
this.footer.innerHTML = ''
this.buildTabs() this.buildTabs()
const value = this.value() const value = this.value()
if (!value || value.startsWith('/')) this.showSymbolsTab() if (!value || value.startsWith('/')) this.showSymbolsTab()
@ -556,6 +557,7 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
}, },
buildTabs: function () { buildTabs: function () {
this.tabs.innerHTML = ''
const symbol = L.DomUtil.add( const symbol = L.DomUtil.add(
'button', 'button',
'flat tab-symbols', 'flat tab-symbols',
@ -613,22 +615,14 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
if (this.isDefault()) return if (this.isDefault()) return
if (!L.Util.hasVar(this.value())) { if (!L.Util.hasVar(this.value())) {
// Do not try to render URL with variables // Do not try to render URL with variables
const box = L.DomUtil.create('div', 'umap-pictogram-choice', this.buttons)
L.DomEvent.on(box, 'click', this.onDefine, this)
if (this.isImg()) { if (this.isImg()) {
const img = L.DomUtil.create( const img = L.DomUtil.create('img', '', box)
'img',
'',
L.DomUtil.create('div', 'umap-pictogram-choice', this.buttons)
)
img.src = this.value() img.src = this.value()
L.DomEvent.on(img, 'click', this.showSymbolsTab, this)
} else { } else {
const el = L.DomUtil.create( const el = L.DomUtil.create('span', '', box)
'span',
'',
L.DomUtil.create('div', 'umap-pictogram-choice', this.buttons)
)
el.textContent = this.value() el.textContent = this.value()
L.DomEvent.on(el, 'click', this.showSymbolsTab, this)
} }
} }
this.button = L.DomUtil.createButton( this.button = L.DomUtil.createButton(

View file

@ -1269,6 +1269,7 @@ a.add-datalayer:hover,
vertical-align: middle; vertical-align: middle;
color: white; color: white;
font-weight: bold; font-weight: bold;
font-size: 1.2rem;
} }
.umap-circle-icon { .umap-circle-icon {
border: 1px solid white; border: 1px solid white;

View file

@ -210,8 +210,8 @@ def test_can_use_char_as_picto(map, live_server, page, pictos):
close.click() close.click()
edit_settings.click() edit_settings.click()
shape_settings.click() shape_settings.click()
modify = page.locator(".umap-field-iconUrl").get_by_text("Change") preview = page.locator(".umap-pictogram-choice")
expect(modify).to_be_visible() expect(preview).to_be_visible()
modify.click() preview.click()
# Should be on URL tab # Should be on URL tab
expect(input_el).to_be_visible() expect(input_el).to_be_visible()