Refactor case display logic by creating partials for findings and display sets to enhance maintainability and readability
This commit is contained in:
@@ -678,133 +678,10 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<details open>
|
|
||||||
<summary><b>Findings</b></summary>
|
|
||||||
|
|
||||||
{% if can_edit %}
|
{% include 'atlas/partials/_case_findings.html' %}
|
||||||
<details class="help-text">
|
|
||||||
<summary><i class="bi bi-info-circle"></i> Help</summary>
|
|
||||||
<p>Findings are display sets that can be added to series. Once added they will appear here on linked cases.</p>
|
|
||||||
<p>To add a finding to a series, select the series and then click the "Add finding" button.</p>
|
|
||||||
</details>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<!-- Series Findings -->
|
{% include 'atlas/partials/_case_displaysets.html' %}
|
||||||
<h5>Series Findings</h5>
|
|
||||||
{% for series in case.ordered_series %}
|
|
||||||
{% for finding in series.findings.all %}
|
|
||||||
<div class="finding-box" id="finding-box-{{ finding.pk }}" data-series="{{ series.pk }}">
|
|
||||||
<span>
|
|
||||||
<a href="{{series.get_absolute_url}}?show_finding={{finding.pk}}">
|
|
||||||
<button class="btn btn-primary btn-sm">View</button>
|
|
||||||
</a>
|
|
||||||
<button class="btn btn-secondary btn-sm view-finding-modal" data-finding-id="{{ finding.pk }}" data-series-id="{{ series.pk }}">
|
|
||||||
View in Modal
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
{% if finding.findings %}
|
|
||||||
<span>
|
|
||||||
Findings: {% for f in finding.findings.all %}
|
|
||||||
{{f.get_link}},
|
|
||||||
{% endfor %}
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
{% if finding.conditions %}
|
|
||||||
<span>
|
|
||||||
Conditions: {% for c in finding.conditions.all %}
|
|
||||||
{{c.get_link}},
|
|
||||||
{% endfor %}
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
{% if finding.structures %}
|
|
||||||
<span>
|
|
||||||
Structure: {% for s in finding.structures.all %}
|
|
||||||
{{s.get_link}},
|
|
||||||
{% endfor %}
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
{% if finding.description %}
|
|
||||||
<span>
|
|
||||||
Description: {{finding.description}}
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% empty%}
|
|
||||||
No series associated with case.
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
<!-- Case Display Sets -->
|
|
||||||
<h5 class="mt-3">Case Display Sets</h5>
|
|
||||||
<ul class="list-group">
|
|
||||||
{% for ds in case.display_sets.all %}
|
|
||||||
<li class="list-group-item">
|
|
||||||
<b>Name: {{ ds.name }}</b>
|
|
||||||
{% if ds.description %}
|
|
||||||
<span class="text-muted">({{ ds.description }})</span>
|
|
||||||
{% endif %}
|
|
||||||
<span>
|
|
||||||
<a href="{% url 'atlas:case_displaysets_detail' ds.pk %}">View Display Set</a>
|
|
||||||
<button type="button" class="btn btn-secondary btn-sm view-displayset-modal ms-2" data-ds-id="{{ ds.pk }}" data-url="{% url 'atlas:case_displaysets_modal' ds.pk %}">View in Modal</button>
|
|
||||||
</span>
|
|
||||||
<div>
|
|
||||||
<strong>Findings:</strong>
|
|
||||||
{% if ds.findings.all %}
|
|
||||||
<ul>
|
|
||||||
{% for finding in ds.findings.all %}
|
|
||||||
<li>{{ finding.get_link }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% else %}
|
|
||||||
<span class="text-muted">None</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<strong>Structures:</strong>
|
|
||||||
{% if ds.structures.all %}
|
|
||||||
<ul>
|
|
||||||
{% for structure in ds.structures.all %}
|
|
||||||
<li>{{ structure.get_link }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% else %}
|
|
||||||
<span class="text-muted">None</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<strong>Conditions:</strong>
|
|
||||||
{% if ds.conditions.all %}
|
|
||||||
<ul>
|
|
||||||
{% for condition in ds.conditions.all %}
|
|
||||||
<li>{{ condition.get_link }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% else %}
|
|
||||||
<span class="text-muted">None</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<details>
|
|
||||||
<summary class="small text-muted" style="cursor:pointer;">Show advanced (viewer state & annotations)</summary>
|
|
||||||
<div>
|
|
||||||
{% include 'atlas/partials/json_pretty.html' with json_value=ds.viewerstate title='Viewer State' %}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
{% include 'atlas/partials/json_pretty.html' with json_value=ds.annotations title='Annotations' %}
|
|
||||||
</div>
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% empty %}
|
|
||||||
<div class="displayset-empty-state">
|
|
||||||
<span class="text-muted">No display sets for this case.</span>
|
|
||||||
{% if can_edit %}
|
|
||||||
<a class="displayset-empty-link" href="{% url 'atlas:case_displaysets' case.pk %}">Add one now</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<details open>
|
<details open>
|
||||||
|
|||||||
@@ -184,8 +184,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if collection.show_findings_post or collection.show_displaysets_post %}
|
{% if collection.show_findings_post %}
|
||||||
{% include 'atlas/case_display_block.html' %}
|
{% include 'atlas/partials/_case_findings.html' %}
|
||||||
|
{% endif %}
|
||||||
|
{% if collection.show_displaysets_post %}
|
||||||
|
{% include 'atlas/partials/_case_displaysets.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if resources %}
|
{% if resources %}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
{# Partial: Case Display Sets (displaysets) #}
|
||||||
|
<div>
|
||||||
|
<h5 class="mt-3">Case Display Sets</h5>
|
||||||
|
<ul class="list-group">
|
||||||
|
{% for ds in case.display_sets.all %}
|
||||||
|
<li class="list-group-item">
|
||||||
|
<b>Name: {{ ds.name }}</b>
|
||||||
|
{% if ds.description %}
|
||||||
|
<span class="text-muted">({{ ds.description }})</span>
|
||||||
|
{% endif %}
|
||||||
|
<span>
|
||||||
|
<a href="{% url 'atlas:case_displaysets_detail' ds.pk %}">View Display Set</a>
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm view-displayset-modal ms-2" data-ds-id="{{ ds.pk }}" data-url="{% url 'atlas:case_displaysets_modal' ds.pk %}">View in Modal</button>
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<strong>Findings:</strong>
|
||||||
|
{% if ds.findings.all %}
|
||||||
|
<ul>
|
||||||
|
{% for finding in ds.findings.all %}
|
||||||
|
<li>{{ finding.get_link }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">None</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Structures:</strong>
|
||||||
|
{% if ds.structures.all %}
|
||||||
|
<ul>
|
||||||
|
{% for structure in ds.structures.all %}
|
||||||
|
<li>{{ structure.get_link }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">None</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Conditions:</strong>
|
||||||
|
{% if ds.conditions.all %}
|
||||||
|
<ul>
|
||||||
|
{% for condition in ds.conditions.all %}
|
||||||
|
<li>{{ condition.get_link }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<span class="text-muted">None</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<details>
|
||||||
|
<summary class="small text-muted" style="cursor:pointer;">Show advanced (viewer state & annotations)</summary>
|
||||||
|
<div>
|
||||||
|
{% include 'atlas/partials/json_pretty.html' with json_value=ds.viewerstate title='Viewer State' %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{% include 'atlas/partials/json_pretty.html' with json_value=ds.annotations title='Annotations' %}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{% empty %}
|
||||||
|
<div class="displayset-empty-state">
|
||||||
|
<span class="text-muted">No display sets for this case.</span>
|
||||||
|
{% if can_edit %}
|
||||||
|
<a class="displayset-empty-link" href="{% url 'atlas:case_displaysets' case.pk %}">Add one now</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
{# Partial: Series Findings for a Case #}
|
||||||
|
<div>
|
||||||
|
<details open>
|
||||||
|
<summary><b>Findings</b></summary>
|
||||||
|
|
||||||
|
{% if can_edit %}
|
||||||
|
<details class="help-text">
|
||||||
|
<summary><i class="bi bi-info-circle"></i> Help</summary>
|
||||||
|
<p>Findings are display sets that can be added to series. Once added they will appear here on linked cases.</p>
|
||||||
|
<p>To add a finding to a series, select the series and then click the "Add finding" button.</p>
|
||||||
|
</details>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Series Findings -->
|
||||||
|
<h5>Series Findings</h5>
|
||||||
|
{% for series in case.ordered_series %}
|
||||||
|
{% for finding in series.findings.all %}
|
||||||
|
<div class="finding-box" id="finding-box-{{ finding.pk }}" data-series="{{ series.pk }}">
|
||||||
|
<span>
|
||||||
|
<a href="{{series.get_absolute_url}}?show_finding={{finding.pk}}">
|
||||||
|
<button class="btn btn-primary btn-sm">View</button>
|
||||||
|
</a>
|
||||||
|
<button class="btn btn-secondary btn-sm view-finding-modal" data-finding-id="{{ finding.pk }}" data-series-id="{{ series.pk }}">
|
||||||
|
View in Modal
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
{% if finding.findings %}
|
||||||
|
<span>
|
||||||
|
Findings: {% for f in finding.findings.all %}
|
||||||
|
{{f.get_link}},
|
||||||
|
{% endfor %}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if finding.conditions %}
|
||||||
|
<span>
|
||||||
|
Conditions: {% for c in finding.conditions.all %}
|
||||||
|
{{c.get_link}},
|
||||||
|
{% endfor %}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if finding.structures %}
|
||||||
|
<span>
|
||||||
|
Structure: {% for s in finding.structures.all %}
|
||||||
|
{{s.get_link}},
|
||||||
|
{% endfor %}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
{% if finding.description %}
|
||||||
|
<span>
|
||||||
|
Description: {{finding.description}}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% empty %}
|
||||||
|
No series associated with case.
|
||||||
|
{% endfor %}
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user