From de5b6c36f39c2f03f18001e8967439d0d2263261 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 23 Mar 2026 16:13:56 +0000 Subject: [PATCH] Refactor modal handling for display sets and findings; extract modals into partials for improved maintainability --- atlas/static/atlas/js/markup_inserter.js | 27 +++++++- atlas/templates/atlas/case_display_block.html | 66 +------------------ .../atlas/partials/_displayset_modals.html | 47 +++++++++++++ .../atlas/partials/_finding_modal.html | 17 +++++ 4 files changed, 92 insertions(+), 65 deletions(-) create mode 100644 atlas/templates/atlas/partials/_displayset_modals.html create mode 100644 atlas/templates/atlas/partials/_finding_modal.html diff --git a/atlas/static/atlas/js/markup_inserter.js b/atlas/static/atlas/js/markup_inserter.js index f60dfbfc..ab71813c 100644 --- a/atlas/static/atlas/js/markup_inserter.js +++ b/atlas/static/atlas/js/markup_inserter.js @@ -331,7 +331,32 @@ var popup = document.createElement('div'); popup.id = 'markup-popup'; popup.className = 'markup-popup'; popup.innerHTML = '
'+ (label||type+':'+pk) +'
'; var openBtn = document.createElement('button'); openBtn.type='button'; openBtn.className='btn btn-sm btn-outline-primary me-2'; openBtn.textContent='Open'; - openBtn.addEventListener('click', function(){ var url = getDetailUrl(type, pk); if(url) showModalForUrl(url, label); popup.remove(); }); + openBtn.addEventListener('click', function(){ + var url = getDetailUrl(type, pk); + try{ + // Prefer page-specific modal loaders if present so we reuse existing Bootstrap modals/viewers + if(type === 'displayset'){ + if(typeof window.loadDisplaysetModal === 'function'){ + window.loadDisplaysetModal(url, pk); + popup.remove(); + return; + } + var dsBtn = document.querySelector('.view-displayset-modal[data-ds-id="'+pk+'"]'); + if(dsBtn){ dsBtn.click(); popup.remove(); return; } + } + if(type === 'seriesfinding' || type === 'finding'){ + if(typeof window.loadFindingModal === 'function'){ + window.loadFindingModal(pk, url); + popup.remove(); + return; + } + var fBtn = document.querySelector('.view-finding-modal[data-finding-id="'+pk+'"]'); + if(fBtn){ fBtn.click(); popup.remove(); return; } + } + }catch(e){ console.warn('error invoking page modal loader', e); } + if(url) showModalForUrl(url, label); + popup.remove(); + }); var closeBtn = document.createElement('button'); closeBtn.type='button'; closeBtn.className='btn btn-sm btn-outline-secondary'; closeBtn.textContent='Close'; closeBtn.addEventListener('click', function(){ popup.remove(); }); popup.appendChild(openBtn); popup.appendChild(closeBtn); document.body.appendChild(popup); diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html index 4449701f..09c5ca31 100755 --- a/atlas/templates/atlas/case_display_block.html +++ b/atlas/templates/atlas/case_display_block.html @@ -868,53 +868,7 @@ {% include 'question_notes.html' %} - - - - - - +{% include 'atlas/partials/_displayset_modals.html' %}

Checked by: {% for verified in case.verified.all %} {{verified}}, {% endfor %}

@@ -925,23 +879,7 @@

Case size: {{ case.get_total_series_images_size | filesizeformat }}

- +{% include 'atlas/partials/_finding_modal.html' %}