enable priors in atlas

This commit is contained in:
Ross
2024-07-17 22:00:57 +01:00
parent 35e4b81e34
commit 7075bba7a2
8 changed files with 312 additions and 6 deletions
@@ -0,0 +1,101 @@
{% extends 'atlas/exams.html' %}
{% block content %}
<div>
{% if previous %}
<a href="{% url 'atlas:collection_case_details' collection.id previous.id %}">Previous question</a>
{% endif %}
Viewing question as part of collection: <a href="{% url 'atlas:collection_detail' collection.id %}">{{collection.name}}</a> [{{case_number|add:1}}/{{collection_length}}]
{% if next %}
<a href="{% url 'atlas:collection_case_details' collection.id next.id %}">Next question</a>
{% endif %}
</div>
<h2>Case: <a href="{% url 'atlas:case_detail' case_detail.case.pk %}">{{case_detail.case.title}}</a></h2>
<p>This page allows you to add series from prior cases to a case in a collection. In order to be available here the cases must be linked on the system.</p>
<p>It is necessary to give a description of how the cases are related that will be displayed to the user when viewing the case.</p>
<h3>Available priors</h3>
<ul>
{% for case, added, relation in available_priors %}
<li class='
{% if added %}
added
{% else %}
not-added
{% endif %}
' data-case={{case.id}}>
{{case.title}} / {{added}} / {{relation}}
<br/>{{case.get_series_blocks|safe}}
<br/>
{% if not added %}
<form hx-post="{% url 'atlas:collection_case_priors' collection.id case_detail.case.pk %}"
hx-target="#htmx-response-{{case.id}}"
_="on htmx:afterRequest log 'test' then remove me"
>
{% csrf_token %}
<input type="hidden" name="prior_case_id" value="{{case.id}}" />
<input type="text" name="relation" value="{{relation}}" placeholder="relation to case" />
<button class="btn primary">Add to case</button>
</form>
{% else %}
<form hx-post="{% url 'atlas:collection_case_priors' collection.id case_detail.case.pk %}"
hx-target="#htmx-response-{{case.id}}"
_="on htmx:afterRequest log 'test' then remove me"
>
Case available: {{relation}}
<input type="hidden" name="remove" value="{{case.id}}" />
<button class="btn primary">Remove from case</button>
</form>
{% endif %}
<span id="htmx-response-{{case.id}}"></span>
</li>
{% endfor %}
</ul>
{% comment %} <form method="POST">
{% csrf_token %}
{{ form }}
<button type="submit" value="save" name="submit">Submit</button>
</form> {% endcomment %}
{% comment %} <h2>Blank form</h2>
<form>
{{ blank_form}}
</form> {% endcomment %}
{% endblock %}
{% block css %}
<style>
.added {
border: 1px solid green;
}
.not-added {
border: 1px solid white;
}
</style>
{% endblock %}
{% block js %}
{% endblock %}
@@ -63,13 +63,21 @@
<summary>
Images
</summary>
{% for series in series_list %}
<span class="series-block">
{% for series, prior, relation in series_to_load %}
<span class="series-block
{% if prior %}
prior
{% endif %}
">
<a href="#" onclick='window.loadDicomViewer(window.images[{{forloop.counter0}}])'>
<span>
<span class="series-block-series-number">Series {{ forloop.counter }}:</span>
{{series.get_block}}
</span>
{% if prior %}
<br/><span class="relation">Prior: {{relation}}</span>
{% endif %}
</a>
</span>
{% endfor %}
@@ -263,6 +271,10 @@
background-color: darkblue;
}
.series-block.prior {
border: darkgray solid 1px;
}
fieldset:disabled textarea {
background-color: black;
}
@@ -291,6 +303,11 @@
.answer-block>div {
padding-top: 10px;
}
.relation {
opacity: 0.5;
font-size: 0.8em;
}
</style>
{% endblock %}
@@ -299,9 +316,13 @@
{% comment %} <script src="https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"></script> {% endcomment %}
<script type="text/javascript">
window.images = {
{% for series in series_list %}
{% comment %} {% for series in series_list %}
{{ forloop.counter0 }}: ["{{ series.get_image_url_array_not_json }}"],
{% endfor %} {% endcomment %}
{% for series, prior, relation in series_to_load %}
{{ forloop.counter0 }}: ["{{ series.get_image_url_array_not_json }}"],
{% endfor %}
}
$(document).ready(function () {