Skip to content

Commit

Permalink
Wrap bulk action buttons with .bulk-action-buttons for replacement vi…
Browse files Browse the repository at this point in the history
…a HTMX
  • Loading branch information
jeremystretch committed Aug 27, 2024
1 parent 5feb0a2 commit 1416888
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
36 changes: 17 additions & 19 deletions netbox/templates/generic/object_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,7 @@
{% if table.paginator.num_pages > 1 %}
<div id="select-all-box" class="d-none card d-print-none">
<div class="form col-md-12">
<div class="card-body">
<div class="float-end">
{% if 'bulk_edit' in actions %}
<span class="bulk-edit-button">
{% bulk_edit_button model query_params=request.GET %}
</span>
{% endif %}
{% if 'bulk_delete' in actions %}
<span class="bulk-delete-button">
{% bulk_delete_button model query_params=request.GET %}
</span>
{% endif %}
</div>
<div class="card-body d-flex justify-content-between">
<div class="form-check">
<input type="checkbox" id="select-all" name="_all" class="form-check-input" />
<label for="select-all" class="form-check-label">
Expand All @@ -102,6 +90,14 @@
{% endblocktrans %}
</label>
</div>
<div class="bulk-action-buttons">
{% if 'bulk_edit' in actions %}
{% bulk_edit_button model query_params=request.GET %}
{% endif %}
{% if 'bulk_delete' in actions %}
{% bulk_delete_button model query_params=request.GET %}
{% endif %}
</div>
</div>
</div>
</div>
Expand All @@ -127,12 +123,14 @@
{# Form buttons #}
<div class="btn-list d-print-none mt-2">
{% block bulk_buttons %}
{% if 'bulk_edit' in actions %}
{% bulk_edit_button model query_params=request.GET %}
{% endif %}
{% if 'bulk_delete' in actions %}
{% bulk_delete_button model query_params=request.GET %}
{% endif %}
<div class="bulk-action-buttons">
{% if 'bulk_edit' in actions %}
{% bulk_edit_button model query_params=request.GET %}
{% endif %}
{% if 'bulk_delete' in actions %}
{% bulk_delete_button model query_params=request.GET %}
{% endif %}
</div>
{% endblock %}
</div>
{# /Form buttons #}
Expand Down
27 changes: 15 additions & 12 deletions netbox/templates/htmx/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
{% endwith %}
</div>

{# Include the updated object count for display elsewhere on the page #}
<div class="d-none" hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
{% if 'bulk_edit' in actions %}
<div class="d-none" hx-swap-oob="innerHTML:.bulk-edit-button">
{% bulk_edit_button model query_params=request.GET %}
</div>
{% endif %}
{% if 'bulk_delete' in actions %}
<div class="d-none" hx-swap-oob="innerHTML:.bulk-delete-button">
{% bulk_delete_button model query_params=request.GET %}
</div>
{% endif %}
{% if request.htmx %}
{# Include the updated object count for display elsewhere on the page #}
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>

{# Update the bulk action buttons with new query parameters #}
{% if actions %}
<div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
{% if 'bulk_edit' in actions %}
{% bulk_edit_button model query_params=request.GET %}
{% endif %}
{% if 'bulk_delete' in actions %}
{% bulk_delete_button model query_params=request.GET %}
{% endif %}
</div>
{% endif %}
{% endif %}

0 comments on commit 1416888

Please sign in to comment.