From ec0bad02c6c4a87397e3ffbebe2408f8c44f4b54 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 23 Mar 2026 16:51:25 +0000 Subject: [PATCH] Implement modal opening for tokens in markup; replace popup actions with modal invocations for display sets and findings --- atlas/static/atlas/js/markup_inserter.js | 29 +++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/atlas/static/atlas/js/markup_inserter.js b/atlas/static/atlas/js/markup_inserter.js index ab71813c..2a7b0956 100644 --- a/atlas/static/atlas/js/markup_inserter.js +++ b/atlas/static/atlas/js/markup_inserter.js @@ -374,6 +374,29 @@ }, 10); } + // Try to open a modal for a token (prefer page-specific modal loaders) + function openModalForToken(element){ + var type = element.getAttribute('data-type'); var pk = element.getAttribute('data-pk'); var label = element.getAttribute('data-label') || element.textContent || ''; + var url = getDetailUrl(type, pk); + try{ + if(type === 'displayset'){ + if(typeof window.loadDisplaysetModal === 'function'){ + window.loadDisplaysetModal(url, pk); return; + } + var dsBtn = document.querySelector('.view-displayset-modal[data-ds-id="'+pk+'"]'); + if(dsBtn){ dsBtn.click(); return; } + } + if(type === 'seriesfinding' || type === 'finding'){ + if(typeof window.loadFindingModal === 'function'){ + window.loadFindingModal(pk, url); return; + } + var fBtn = document.querySelector('.view-finding-modal[data-finding-id="'+pk+'"]'); + if(fBtn){ fBtn.click(); return; } + } + }catch(e){ console.warn('error invoking page modal loader', e); } + if(url) showModalForUrl(url, label); + } + // Replace tokens in text nodes with styled spans function renderMarkupTokens(root){ injectMarkupStyles(); @@ -397,7 +420,7 @@ else if(type === 'displayset') span.className += ' badge bg-success text-white'; else span.className += ' badge bg-info text-dark'; span.textContent = label ? label : (type + ':' + pk); - span.addEventListener('click', function(e){ e.stopPropagation(); showPopupFor(span); }); + span.addEventListener('click', function(e){ e.stopPropagation(); openModalForToken(span); }); a.parentNode.replaceChild(span, a); }catch(e){} }); @@ -426,7 +449,7 @@ else if(type === 'displayset') span.className += ' badge bg-success text-white'; else span.className += ' badge bg-info text-dark'; span.textContent = label ? label : (type + ':' + pk); - span.addEventListener('click', function(e){ e.stopPropagation(); showPopupFor(span); }); + span.addEventListener('click', function(e){ e.stopPropagation(); openModalForToken(span); }); frag.appendChild(span); lastIndex = re.lastIndex; } @@ -445,7 +468,7 @@ var type = span.getAttribute('data-type') || ''; var pk = span.getAttribute('data-pk') || ''; var label = span.getAttribute('data-label') || span.textContent || ''; - span.addEventListener('click', function(e){ e.stopPropagation(); showPopupFor(span); }); + span.addEventListener('click', function(e){ e.stopPropagation(); openModalForToken(span); }); }catch(e){} }); }