Refactor modal reopening logic to streamline URL parameter handling and improve code clarity
This commit is contained in:
@@ -1333,34 +1333,26 @@
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
}
|
||||
|
||||
// On load: reopen modals if URL params present
|
||||
// On load: reopen modals if URL params present — call loader functions directly
|
||||
(function reopenModalsFromUrl() {
|
||||
const params = new URL(window.location.href).searchParams;
|
||||
const dsId = params.get('displayset');
|
||||
const dsFull = params.get('displayset_full');
|
||||
const findingId = params.get('finding');
|
||||
if (dsId) {
|
||||
// try to find a button for this displayset and click it
|
||||
// prefer to use existing button url if present, otherwise construct endpoint
|
||||
const btn = document.querySelector(`.view-displayset-modal[data-ds-id="${dsId}"]`);
|
||||
if (btn) {
|
||||
// open fullscreen if requested
|
||||
const url = btn ? btn.dataset.url : null;
|
||||
if (dsFull) {
|
||||
// ensure the modal content is loaded then trigger fullscreen
|
||||
btn.click();
|
||||
// wait for content then trigger fullscreen button
|
||||
setTimeout(function () {
|
||||
const fs = document.querySelector('.displayset-fullscreen-btn');
|
||||
if (fs) fs.click();
|
||||
}, 800);
|
||||
loadDisplaysetFullscreen(url, dsId);
|
||||
} else {
|
||||
btn.click();
|
||||
loadDisplaysetModal(url, dsId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (findingId) {
|
||||
} else if (findingId) {
|
||||
// open finding modal
|
||||
const fbtn = document.querySelector(`.view-finding-modal[data-finding-id="${findingId}"]`);
|
||||
if (fbtn) fbtn.click();
|
||||
const url = fbtn ? fbtn.getAttribute('data-url') : null;
|
||||
loadFindingModal(findingId, url);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user