From b17774aa7c195d2d1b575d40b1b249931be7c829 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 23 Mar 2026 10:35:07 +0000 Subject: [PATCH] Refactor modal reopening logic to streamline URL parameter handling and improve code clarity --- atlas/templates/atlas/case_display_block.html | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html index f9913088..884a4781 100755 --- a/atlas/templates/atlas/case_display_block.html +++ b/atlas/templates/atlas/case_display_block.html @@ -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 - 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); - } else { - btn.click(); - } - return; + const url = btn ? btn.dataset.url : null; + if (dsFull) { + loadDisplaysetFullscreen(url, dsId); + } else { + loadDisplaysetModal(url, dsId); } - } - 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); } })();