Refactor actions section in case view template for improved readability and structure

This commit is contained in:
Ross
2025-10-20 13:01:14 +01:00
parent 2a94e40a1e
commit 42b64c11ff
2 changed files with 58 additions and 57 deletions
+57 -57
View File
@@ -23,64 +23,64 @@
View my <a href='{% url "atlas:case_view" %}?author={{request.user.id}}'>cases</a>. View my <a href='{% url "atlas:case_view" %}?author={{request.user.id}}'>cases</a>.
</details> </details>
<form> <form>
<details id="actions-detail" class="mt-3"> <details id="actions-detail" class="mt-3">
<summary> <summary>
<strong>Actions</strong> <strong>Actions</strong>
</summary> </summary>
<div class="row mb-2"> <div class="row mb-2">
<div class="col-auto"> <div class="col-auto">
<select id="collection-select" name="collection_id" class="form-select form-select-sm"> <select id="collection-select" name="collection_id" class="form-select form-select-sm">
<!-- Dynamically load collection options via HTMX --> <!-- Dynamically load collection options via HTMX -->
<option value="">Loading collections...</option> <option value="">Loading collections...</option>
<option hx-trigger="every 1s[document.getElementById('actions-detail').open] once" hx-get="{% url 'atlas:collection_options' %}" hx-target="#collection-select" hx-swap="innerHTML"></option> <option hx-trigger="every 1s[document.getElementById('actions-detail').open] once" hx-get="{% url 'atlas:collection_options' %}" hx-target="#collection-select" hx-swap="innerHTML"></option>
</select> </select>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button id="add-to-collection-btn" <button id="add-to-collection-btn"
class="btn btn-sm btn-outline-primary" class="btn btn-sm btn-outline-primary"
hx-post="{% url 'atlas:add_cases_to_collection' %}" hx-post="{% url 'atlas:add_cases_to_collection' %}"
hx-include="[name='selection']:checked, #collection-select" hx-include="[name='selection']:checked, #collection-select"
hx-target="#action-result" hx-target="#action-result"
hx-swap="innerHTML" hx-swap="innerHTML"
> >
Add selected cases to collection Add selected cases to collection
</button> </button>
<button id="remove-from-collection-btn" <button id="remove-from-collection-btn"
class="btn btn-sm btn-outline-danger ms-2" class="btn btn-sm btn-outline-danger ms-2"
hx-post="{% url 'atlas:remove_cases_from_collection' %}" hx-post="{% url 'atlas:remove_cases_from_collection' %}"
hx-include="[name='selection']:checked, #collection-select" hx-include="[name='selection']:checked, #collection-select"
hx-target="#action-result" hx-target="#action-result"
hx-swap="innerHTML" hx-swap="innerHTML"
> >
Remove selected cases from collection Remove selected cases from collection
</button> </button>
<br/> <br/>
<button id="set-open-access-btn" <button id="set-open-access-btn"
class="btn btn-sm btn-outline-success ms-2" class="btn btn-sm btn-outline-success ms-2"
hx-post="{% url 'atlas:set_open_access' %}" hx-post="{% url 'atlas:set_open_access' %}"
hx-include="[name='selection']:checked" hx-include="[name='selection']:checked"
hx-target="#action-result" hx-target="#action-result"
hx-swap="innerHTML" hx-swap="innerHTML"
> >
Set Open Access Set Open Access
</button> </button>
<button id="remove-open-access-btn" <button id="remove-open-access-btn"
class="btn btn-sm btn-outline-warning ms-2" class="btn btn-sm btn-outline-warning ms-2"
hx-post="{% url 'atlas:remove_open_access' %}" hx-post="{% url 'atlas:remove_open_access' %}"
hx-include="[name='selection']:checked" hx-include="[name='selection']:checked"
hx-target="#action-result" hx-target="#action-result"
hx-swap="innerHTML" hx-swap="innerHTML"
> >
Remove Open Access Remove Open Access
</button> </button>
<span id="action-result"></span> <span id="action-result"></span>
</div> </div>
</div> </div>
</details> </details>
{% render_table table %} {% render_table table %}
</form> </form>
{% include "generic/partials/page_size_form.html" %} {% include "generic/partials/page_size_form.html" %}
<div id="exam-options"></div> <div id="exam-options"></div>
{% endblock %} {% endblock %}
+1
View File
@@ -40,6 +40,7 @@ class QuestionTable(tables.Table):
"author", "author",
) )
sequence = ("view", "stem", "answers")#, "exams") sequence = ("view", "stem", "answers")#, "exams")
attrs = {"class": "table row-selector"}
def __init__(self, data=None, *args, **kwargs): def __init__(self, data=None, *args, **kwargs):
super().__init__( super().__init__(