Allow to reopen a dialog in dashboard previews

This commit is contained in:
Yohan Boniface 2023-12-22 17:16:06 +01:00 committed by David Larlet
parent ded244c9ff
commit c3cb813c23
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
2 changed files with 9 additions and 3 deletions

View file

@ -67,7 +67,7 @@
const container = this.parentNode
container.innerHTML = data
Array.prototype.forEach.call(
container.querySelectorAll('script'),
container.querySelectorAll('script:not([type="application/json"])'),
function (item) {
eval(item.firstChild.textContent)
}

View file

@ -28,12 +28,18 @@
{{ block.super }}
<script type="text/javascript">
!(function () {
const CACHE = {}
for (const mapOpener of document.querySelectorAll("button.map-opener")) {
mapOpener.addEventListener('click', (event) => {
event.target.nextElementSibling.showModal()
const mapId = event.target.dataset.mapId
if (!document.querySelector(`#${mapId}_target`).hasChildNodes()) {
const previewSettings = JSON.parse(document.getElementById(mapId).textContent)
const map = new L.U.Map(`${mapId}_target`, previewSettings)
CACHE[mapId] = map
} else {
CACHE[mapId].invalidateSize()
}
})
}
})()