Add inline collection management features; implement search and add functionality for collections in case view
This commit is contained in:
@@ -453,7 +453,7 @@
|
||||
Add to collection</button>
|
||||
{% endif %}
|
||||
<div id="collection-form"></div>
|
||||
<ul>
|
||||
<ul id="case-{{ case.pk }}-collections">
|
||||
{% for collection in case.casecollection_set.all %}
|
||||
<li id="collection-{{ collection.pk }}">
|
||||
<a href="{% url 'atlas:collection_detail' pk=collection.pk %}">{{ collection.name }}</a>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="d-flex align-items-center">
|
||||
<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-trigger="keyup delay:500ms"
|
||||
hx-target="#category-search-results"
|
||||
hx-swap="innerHTML"
|
||||
hx-include="#category-search-form"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
{% endhelp%}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-4">
|
||||
<div class="col-12">
|
||||
<form method="get" class="form-inline">
|
||||
{% crispy filter.form %}
|
||||
<div class="mb-2">
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<div id="add-collection-inline" class="p-2 border rounded">
|
||||
<div class="mb-2">
|
||||
<div class="input-group">
|
||||
<input class="form-control" id="collection-inline-search" name="q" type="search" placeholder="Search collections"
|
||||
{% if case %}
|
||||
hx-get="{% url 'atlas:collection_inline_search' case.pk %}"
|
||||
{% else %}
|
||||
hx-get="{% url 'atlas:collection_inline_search' 0 %}"
|
||||
{% endif %}
|
||||
hx-trigger="input delay:400ms, keyup[key=='Enter']"
|
||||
hx-target="#collection-inline-list"
|
||||
hx-indicator="#collection-inline-indicator">
|
||||
<span class="input-group-text" id="collection-inline-indicator" aria-hidden="true">
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="collection-inline-list">
|
||||
{% include 'atlas/partials/collection_inline_list.html' with collections=recent_collections case=case %}
|
||||
</div>
|
||||
|
||||
<div class="mt-2">
|
||||
<button class="btn btn-sm btn-secondary" _="on click remove #add-collection-inline">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
<ul class="list-group" id="collection-inline-list-items">
|
||||
{% if collections and collections|length > 0 %}
|
||||
{% for collection in collections %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center" data-collection-pk="{{ collection.pk }}">
|
||||
<div class="flex-fill">
|
||||
<div class="d-flex align-items-baseline">
|
||||
<a href="{% url 'atlas:collection_detail' pk=collection.pk %}" class="me-2">{{ collection.name }}</a>
|
||||
<small class="text-muted">{% if collection.author.all %}By {{ collection.author.all|join:", " }}{% endif %}</small>
|
||||
</div>
|
||||
{% if collection.description %}<div class="small text-muted">{{ collection.description|truncatechars:120 }}</div>{% endif %}
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<a class="btn btn-sm btn-outline-secondary" href="{% url 'atlas:collection_detail' pk=collection.pk %}" target="_blank" rel="noopener">Open</a>
|
||||
{% if case %}
|
||||
<button class="btn btn-sm btn-primary" hx-post="{% url 'atlas:add_collection_to_case_inline' case.pk collection.pk %}" hx-target="#case-{{ case.pk }}-collections" hx-swap="beforeend">Add</button>
|
||||
{% else %}
|
||||
<span class="text-muted small">Open a case to add</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<li class="list-group-item text-muted">No collections found.</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
@@ -0,0 +1,12 @@
|
||||
<li id="collection-{{ collection.pk }}">
|
||||
<a href="{% url 'atlas:collection_detail' pk=collection.pk %}">{{ collection.name }}</a>
|
||||
{% if can_edit %}
|
||||
<button class="btn btn-danger btn-sm remove-button"
|
||||
hx-post="{% url 'atlas:remove_case_from_collection' case.pk collection.pk %}"
|
||||
hx-target="#collection-{{ collection.pk }}"
|
||||
hx-swap="outerHTML"
|
||||
hx-confirm="Are you sure you want to remove this case from the collection?">
|
||||
Remove
|
||||
</button>
|
||||
{% endif %}
|
||||
</li>
|
||||
Reference in New Issue
Block a user