Add category search functionality with results display
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Search results for "{{ query }}"</h5>
|
||||
|
||||
{% for group_name, items in results.items %}
|
||||
{% if items.exists %}
|
||||
<h6 class="mt-3">{{ group_name|capfirst }}</h6>
|
||||
<ul class="list-unstyled">
|
||||
{% for item in items %}
|
||||
<li>
|
||||
{% if group_name == 'conditions' %}
|
||||
<a href="{% url 'atlas:condition_detail' item.pk %}">{{ item.name }}</a>
|
||||
{% elif group_name == 'findings' %}
|
||||
<a href="{% url 'atlas:finding_detail' item.pk %}">{{ item.name }}</a>
|
||||
{% elif group_name == 'structures' %}
|
||||
<a href="{% url 'atlas:structure_detail' item.pk %}">{{ item.name }}</a>
|
||||
{% elif group_name == 'subspecialties' %}
|
||||
<a href="{% url 'atlas:subspecialty_detail' item.pk %}">{{ item.name }}</a>
|
||||
{% elif group_name == 'presentations' %}
|
||||
<a href="{% url 'atlas:presentation_detail' item.pk %}">{{ item.name }}</a>
|
||||
{% else %}
|
||||
{{ item.name }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if not results.conditions.exists and not results.findings.exists and not results.structures.exists and not results.subspecialties.exists and not results.presentations.exists %}
|
||||
<p class="text-muted">No matches found.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -12,6 +12,24 @@
|
||||
<li><a href="{% url 'atlas:pathological_process_view' %}">Pathological Process</li></a>
|
||||
</ul>
|
||||
|
||||
<div class="mt-4 mb-3">
|
||||
<form method="get" class="d-flex" action="" id="category-search-form">
|
||||
<input id="category-search-input" type="search" name="q" placeholder="Search all categories (conditions, findings, structures...)" value="{{ query|default:'' }}" class="form-control me-2"
|
||||
hx-get="{% url 'atlas:categories_search_partial' %}"
|
||||
hx-trigger="keyup changed delay:500ms"
|
||||
hx-target="#category-search-results"
|
||||
hx-swap="innerHTML"
|
||||
hx-include="#category-search-input" />
|
||||
<button class="btn btn-primary" type="submit">Search</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="category-search-results">
|
||||
{% if results is not None %}
|
||||
{% include 'atlas/_categories_search_results.html' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if request.user.is_staff %}
|
||||
<p>Manage <a href="{% url 'generic:examination_view' %}">Examinations</a>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user