diff --git a/atlas/templates/atlas/partials/_case_displaysets.html b/atlas/templates/atlas/partials/_case_displaysets.html index 9fb75b10..3029f8f5 100644 --- a/atlas/templates/atlas/partials/_case_displaysets.html +++ b/atlas/templates/atlas/partials/_case_displaysets.html @@ -96,6 +96,33 @@ if (!window.__displaysetPartialInitDone) { window.__displaysetPartialInitDone = true; + if (typeof window.mountDisplaysetViewersSafely !== 'function') { + window.mountDisplaysetViewersSafely = async function () { + try { + await new Promise(function (resolve) { + requestAnimationFrame(function () { + requestAnimationFrame(resolve); + }); + }); + + if (typeof window.mountDicomViewersSafely === 'function') { + await window.mountDicomViewersSafely(); + } else if (typeof window.mountDicomViewers === 'function') { + window.mountDicomViewers(); + } + + requestAnimationFrame(function () { + try { window.dispatchEvent(new Event('resize')); } catch (e) {} + if (typeof window.resizeDicomViewers === 'function') { + try { window.resizeDicomViewers(); } catch (e) {} + } + }); + } catch (e) { + console.warn('displayset viewer mount failed', e); + } + }; + } + if (typeof window.loadDisplaysetModal !== 'function') { window.loadDisplaysetModal = async function (url, dsId) { if (!url && dsId) url = '/atlas/' + dsId + '/display_sets/modal'; @@ -118,6 +145,7 @@ } bootstrap.Modal.getOrCreateInstance(modalEl).show(); + await window.mountDisplaysetViewersSafely(); } catch (error) { console.error('Error loading display set details:', error); modalBody.innerHTML = '
Failed to load display set.
'; @@ -164,6 +192,7 @@ rightEl.innerHTML = tmp.innerHTML; bootstrap.Modal.getOrCreateInstance(fullModalEl).show(); + await window.mountDisplaysetViewersSafely(); } catch (error) { console.error('Error loading fullscreen display set:', error); leftEl.innerHTML = 'Failed to load viewer
';