From 1cadbab7423f70d921ff7cfa327ad442348d9105 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 16 Mar 2026 12:08:34 +0000 Subject: [PATCH] Enhance JSON display by integrating pretty JSON formatter in various templates --- .../templates/anatomy/question_detail.html | 8 +- atlas/templates/atlas/case_display_block.html | 6 +- .../atlas/case_displayset_modal.html | 6 +- .../atlas/partials/displayset_row.html | 40 ++++---- .../templates/atlas/partials/json_pretty.html | 98 +++++++++---------- 5 files changed, 80 insertions(+), 78 deletions(-) diff --git a/anatomy/templates/anatomy/question_detail.html b/anatomy/templates/anatomy/question_detail.html index b1f217a5..5cd03b37 100644 --- a/anatomy/templates/anatomy/question_detail.html +++ b/anatomy/templates/anatomy/question_detail.html @@ -169,7 +169,13 @@
Annotation JSON -
{% if question.image_annotations %}
{{ question.image_annotations }}
{% else %}No saved annotations.{% endif %}
+
+ {% if question.image_annotations %} + {% include 'atlas/partials/json_pretty.html' with json_value=question.image_annotations title='Image annotations' %} + {% else %} + No saved annotations. + {% endif %} +
diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html index 689ec95a..17bbfd8a 100755 --- a/atlas/templates/atlas/case_display_block.html +++ b/atlas/templates/atlas/case_display_block.html @@ -743,12 +743,10 @@
Show advanced (viewer state & annotations)
- Viewer State: -
{{ ds.viewerstate|default:"{}" }}
+ {% include 'atlas/partials/json_pretty.html' with json_value=ds.viewerstate title='Viewer State' %}
- Annotations: -
{{ ds.annotations|default:"{}" }}
+ {% include 'atlas/partials/json_pretty.html' with json_value=ds.annotations title='Annotations' %}
diff --git a/atlas/templates/atlas/case_displayset_modal.html b/atlas/templates/atlas/case_displayset_modal.html index eabc755e..a443991d 100644 --- a/atlas/templates/atlas/case_displayset_modal.html +++ b/atlas/templates/atlas/case_displayset_modal.html @@ -67,12 +67,10 @@
Show advanced (viewer state & annotations)
- Viewer State: -
{{ ds.viewerstate|default:"{}" }}
+ {% include 'atlas/partials/json_pretty.html' with json_value=ds.viewerstate title='Viewer State' %}
- Annotations: -
{{ ds.annotations|default:"{}" }}
+ {% include 'atlas/partials/json_pretty.html' with json_value=ds.annotations title='Annotations' %}
diff --git a/atlas/templates/atlas/partials/displayset_row.html b/atlas/templates/atlas/partials/displayset_row.html index 5bfead5b..fd365b8b 100644 --- a/atlas/templates/atlas/partials/displayset_row.html +++ b/atlas/templates/atlas/partials/displayset_row.html @@ -71,26 +71,26 @@ hx-after class="btn btn-warning btn-sm" onclick=" - this.style.display='none'; - var li = this.closest('li'); - var ul = li.parentNode; - ul.insertBefore(li, ul.firstChild); - li.scrollIntoView({behavior: 'smooth', block: 'center'}); - setTimeout(function() { - var form = document.querySelector('#displayset-edit-form-{{ ds.pk }} form'); - if (form) { - var cancelBtn = document.createElement('button'); - cancelBtn.type = 'button'; - cancelBtn.className = 'btn btn-secondary btn-sm ms-2'; - cancelBtn.textContent = 'Cancel'; - cancelBtn.onclick = function() { - document.querySelector('#displayset-edit-form-{{ ds.pk }}').innerHTML = ''; - document.querySelector('#displayset-{{ ds.pk }}-edit-btn').style.display = ''; - }; - form.appendChild(cancelBtn); - } - }, 100); - " + this.style.display='none'; + var li = this.closest('li'); + var ul = li.parentNode; + ul.insertBefore(li, ul.firstChild); + li.scrollIntoView({behavior: 'smooth', block: 'center'}); + setTimeout(function() { + var form = document.querySelector('#displayset-edit-form-{{ ds.pk }} form'); + if (form) { + var cancelBtn = document.createElement('button'); + cancelBtn.type = 'button'; + cancelBtn.className = 'btn btn-secondary btn-sm ms-2'; + cancelBtn.textContent = 'Cancel'; + cancelBtn.onclick = function() { + document.querySelector('#displayset-edit-form-{{ ds.pk }}').innerHTML = ''; + document.querySelector('#displayset-{{ ds.pk }}-edit-btn').style.display = ''; + }; + form.appendChild(cancelBtn); + } + }, 100); + " >Edit