From 4a787aa3ebf5d2f5bbd1f910dcfc52be462b9af4 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 27 Apr 2026 23:10:20 +0100 Subject: [PATCH] feat: Add show select button option to case search widget and related templates for improved case selection --- atlas/templates/atlas/case_display_block.html | 2 +- .../templates/atlas/partials/_case_search_item.html | 8 ++++++-- .../atlas/partials/case_search_results.html | 4 ++-- .../atlas/partials/case_search_widget.html | 13 +++++++++---- atlas/templates/atlas/user_uploads.html | 2 +- atlas/templatetags/case_widgets.py | 13 ++++++++++++- atlas/views.py | 9 ++++++++- 7 files changed, 39 insertions(+), 12 deletions(-) diff --git a/atlas/templates/atlas/case_display_block.html b/atlas/templates/atlas/case_display_block.html index c3455ab9..9f514fdc 100755 --- a/atlas/templates/atlas/case_display_block.html +++ b/atlas/templates/atlas/case_display_block.html @@ -480,7 +480,7 @@ {{ move_series_form.destination_case }}
Click any case row below to select the destination case.
No destination case selected.
- {% case_search_widget collection=None input_id='move-series-case-search-input' target_id='move-series-case-search-results' %} + {% case_search_widget collection=None input_id='move-series-case-search-input' target_id='move-series-case-search-results' show_select_button=True %} - View + {% if show_select_button %} + + View + {% else %} + View + {% endif %} {% endif %} diff --git a/atlas/templates/atlas/partials/case_search_results.html b/atlas/templates/atlas/partials/case_search_results.html index 3b1e16e9..7980f2c2 100644 --- a/atlas/templates/atlas/partials/case_search_results.html +++ b/atlas/templates/atlas/partials/case_search_results.html @@ -2,7 +2,7 @@ {% if cases and cases|length > 0 %}
{% for case in cases %} - {% include 'atlas/partials/_case_search_item.html' with case=case collection=collection %} + {% include 'atlas/partials/_case_search_item.html' with case=case collection=collection show_select_button=show_select_button %} {% endfor %}
{% else %} @@ -15,7 +15,7 @@
Recently created
{% for case in recent_cases %} - {% include 'atlas/partials/_case_search_item.html' with case=case collection=collection %} + {% include 'atlas/partials/_case_search_item.html' with case=case collection=collection show_select_button=show_select_button %} {% endfor %}
diff --git a/atlas/templates/atlas/partials/case_search_widget.html b/atlas/templates/atlas/partials/case_search_widget.html index e4edb5f0..5d19faa1 100644 --- a/atlas/templates/atlas/partials/case_search_widget.html +++ b/atlas/templates/atlas/partials/case_search_widget.html @@ -1,18 +1,23 @@
{% with input_id=input_id|default:'case-search-input' target_id=target_id|default:'case-search-results' %} + {% if collection %} + + {% endif %} + {% if show_select_button %} + + {% endif %}
{# Render initial results (search + recent) on initial GET; HTMX searches will replace this div with partial results #} - {% include 'atlas/partials/case_search_results.html' with cases=cases recent_cases=recent_cases collection=collection %} + {% include 'atlas/partials/case_search_results.html' with cases=cases recent_cases=recent_cases collection=collection show_select_button=show_select_button %}
{% endwith %}
@@ -28,7 +33,7 @@ timer = setTimeout(function(){ try { var q = encodeURIComponent(input.value || ''); - var url = "{% url 'atlas:case_search' %}?q=" + q + ({% if collection %} "&collection={{ collection.pk }}" {% else %} '' {% endif %}); + var url = "{% url 'atlas:case_search' %}?q=" + q + ({% if collection %} "&collection={{ collection.pk }}" {% else %} '' {% endif %}) + ({% if show_select_button %} "&show_select=1" {% else %} '' {% endif %}); var target = '#{{ target_id|default:"case-search-results" }}'; if (window.htmx && typeof window.htmx.ajax === 'function') { window.htmx.ajax('GET', url, { target: target, swap: 'innerHTML' }); diff --git a/atlas/templates/atlas/user_uploads.html b/atlas/templates/atlas/user_uploads.html index 8f191457..602bf8c6 100644 --- a/atlas/templates/atlas/user_uploads.html +++ b/atlas/templates/atlas/user_uploads.html @@ -132,7 +132,7 @@