Allow to reopen a dialog in dashboard previews
This commit is contained in:
parent
ded244c9ff
commit
c3cb813c23
2 changed files with 9 additions and 3 deletions
|
@ -67,7 +67,7 @@
|
||||||
const container = this.parentNode
|
const container = this.parentNode
|
||||||
container.innerHTML = data
|
container.innerHTML = data
|
||||||
Array.prototype.forEach.call(
|
Array.prototype.forEach.call(
|
||||||
container.querySelectorAll('script'),
|
container.querySelectorAll('script:not([type="application/json"])'),
|
||||||
function (item) {
|
function (item) {
|
||||||
eval(item.firstChild.textContent)
|
eval(item.firstChild.textContent)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,18 @@
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
!(function () {
|
!(function () {
|
||||||
|
const CACHE = {}
|
||||||
for (const mapOpener of document.querySelectorAll("button.map-opener")) {
|
for (const mapOpener of document.querySelectorAll("button.map-opener")) {
|
||||||
mapOpener.addEventListener('click', (event) => {
|
mapOpener.addEventListener('click', (event) => {
|
||||||
event.target.nextElementSibling.showModal()
|
event.target.nextElementSibling.showModal()
|
||||||
const mapId = event.target.dataset.mapId
|
const mapId = event.target.dataset.mapId
|
||||||
|
if (!document.querySelector(`#${mapId}_target`).hasChildNodes()) {
|
||||||
const previewSettings = JSON.parse(document.getElementById(mapId).textContent)
|
const previewSettings = JSON.parse(document.getElementById(mapId).textContent)
|
||||||
const map = new L.U.Map(`${mapId}_target`, previewSettings)
|
const map = new L.U.Map(`${mapId}_target`, previewSettings)
|
||||||
|
CACHE[mapId] = map
|
||||||
|
} else {
|
||||||
|
CACHE[mapId].invalidateSize()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
Loading…
Reference in a new issue