inital case selection widget

This commit is contained in:
Ross
2024-11-11 13:36:53 +00:00
parent a65ceffbfb
commit ed933c8104
5 changed files with 67 additions and 10 deletions
+3
View File
@@ -127,6 +127,9 @@ def uncategorised_dicoms(request):
def import_dicoms_helper(request, case_id: int | None = None): def import_dicoms_helper(request, case_id: int | None = None):
# TODO: move this out of the api (would be better with HTMX)
# dicoms = UncategorisedDicom.objects.filter(user=request.user) # dicoms = UncategorisedDicom.objects.filter(user=request.user)
if "selection" in request.POST: if "selection" in request.POST:
dicoms = UncategorisedDicom.objects.filter( dicoms = UncategorisedDicom.objects.filter(
+15 -2
View File
@@ -47,7 +47,7 @@ from generic.models import Examination#, Sign
# from generic.models import Examination, Site, Condition, Sign # from generic.models import Examination, Site, Condition, Sign
from django.contrib.admin.widgets import FilteredSelectMultiple from django.contrib.admin.widgets import FilteredSelectMultiple
from django.forms.widgets import RadioSelect, TextInput, Textarea from django.forms.widgets import RadioSelect, TextInput, Textarea, Select
from tinymce.widgets import TinyMCE from tinymce.widgets import TinyMCE
@@ -63,6 +63,18 @@ from crispy_forms.helper import FormHelper
from atlas.helpers import get_cases_available_to_user from atlas.helpers import get_cases_available_to_user
class CaseSelect(Select):
template_name = "atlas/case_select_widget.html"
def create_option(self, *args, **kwargs):
option = super().create_option(*args, **kwargs)
print(option)
return option
pass
class ConditionForm(ModelForm): class ConditionForm(ModelForm):
class Meta: class Meta:
@@ -365,7 +377,8 @@ class CaseForm(ModelForm):
url="atlas:presentation-autocomplete" url="atlas:presentation-autocomplete"
), ),
"subspecialty": CheckboxSelectMultiple(), "subspecialty": CheckboxSelectMultiple(),
"pathological_process": CheckboxSelectMultiple() "pathological_process": CheckboxSelectMultiple(),
"previous_case": CaseSelect(),
} }
def save(self, commit=True): def save(self, commit=True):
@@ -0,0 +1,19 @@
<details>
<summary>Cases</summary>
<ul>
{% for group_name, group_choices, group_index in widget.optgroups %}
{% for widget in group_choices %}
{% include widget.template_name %}
{{ widget.instance }}
{% endfor %}
{% endfor %}
</ul>
</detailS>
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.optgroups %}{% if group_name %}
<optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}
{% include widget.template_name %}{% endfor %}{% if group_name %}
</optgroup>{% endif %}{% endfor %}
</select>
+30 -3
View File
@@ -18,10 +18,11 @@
{% for series, n, tags, date in series_list %} {% for series, n, tags, date in series_list %}
<li> <li>
<span _=" <span _="
on click toggle .selected on me on click toggle .selected on me.closest('li')
then set i to the first <input/> in me then set i to the first <input/> in me
then set i.checked to not i.checked" > then set i.checked to not i.checked" >
{{date}}: {{series}} [{{n}} images] <br/> Uploaded: {{date}}<br/>
Series: {{series}} [{{n}} images] <br/>
{{tags}} {{tags}}
<input class="hidden" type="checkbox" name="selection" value="{{ series }}"> <input class="hidden" type="checkbox" name="selection" value="{{ series }}">
</span> </span>
@@ -34,7 +35,7 @@
</ul> </ul>
{% if case %} {% if case %}
<p>Importing into case {{case}}</p> <p>Importing into case: <a href='{% url "atlas:case_detail" case.pk %}'>{{case}}</a></p>
{% endif %} {% endif %}
<details><summary>Upload settings</summary> <details><summary>Upload settings</summary>
<form> <form>
@@ -93,3 +94,29 @@
<p><a href="{% url 'atlas:series_view' %}?case=null&sort=-modified_date">View orphan series</a></p> <p><a href="{% url 'atlas:series_view' %}?case=null&sort=-modified_date">View orphan series</a></p>
{% endblock %} {% endblock %}
{% block css %}
<style>
#series-list {
user-select: none;
cursor: pointer;
}
#series-list li {
}
#series-list .selected {
color: white;
border: 1px solid #52057b;
user-select: none;
margin: -1px;
}
.series-block-popup-link {
float: right;
}
</style>
{% endblock css %}
-5
View File
@@ -1040,11 +1040,6 @@ table .peninsula-trainee::before {
width: 20px; width: 20px;
} }
#series-list .selected {
color: white;
background-color: #52057b;
user-select: none;
}
.form-control, .form-control,
.form-control:focus, .form-control:focus,