Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #15637: Fix rendering of links from within embedded tables w/HTMX enabled #15642

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion netbox/netbox/views/generic/object_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def get(self, request, *args, **kwargs):
return self._handle_protected_objects(obj, e.restricted_objects, request, e)

# If this is an HTMX request, return only the rendered deletion form as modal content
if request.htmx:
if htmx_partial(request):
viewname = get_viewname(self.queryset.model, action='delete')
form_url = reverse(viewname, kwargs={'pk': obj.pk})
return render(request, 'htmx/delete_form.html', {
Expand Down
2 changes: 1 addition & 1 deletion netbox/templates/generic/object_delete.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
{% block content %}
<div class="modal" tabindex="-1" style="display: block; position: static">
<div class="modal-dialog">
<div class="modal-content" >
<div class="modal-content border-1 border-danger">
{% include 'htmx/delete_form.html' %}
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions netbox/templates/inc/table_htmx.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{% load django_tables2 %}
<table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
<table{% if table.attrs %} {{ table.attrs.as_html }}{% endif %} hx-disinherit="hx-target hx-select hx-swap">
{% if table.show_header %}
<thead
hx-target="closest .htmx-container"
hx-disinherit="hx-select hx-swap"
{% if not table.embedded %} hx-push-url="true"{% endif %}
>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion netbox/utilities/htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def htmx_partial(request):
Determines whether to render partial (versus complete) HTML content
in response to an HTMX request, based on the target element.
"""
return request.htmx and request.htmx.target != PAGE_CONTAINER_ID
return request.htmx and request.htmx.target and request.htmx.target != PAGE_CONTAINER_ID
2 changes: 1 addition & 1 deletion netbox/utilities/templates/builtins/htmx_table.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="card-body htmx-container table-responsive p-0"
<div class="htmx-container table-responsive"
hx-get="{% url viewname %}{% if url_params %}?{{ url_params.urlencode }}{% endif %}"
hx-target="this"
hx-trigger="load" hx-select="table" hx-swap="innerHTML"
Expand Down
1 change: 1 addition & 0 deletions netbox/utilities/templatetags/builtins/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'checkmark',
'copy_content',
'customfield_value',
'htmx_table',
'formaction',
'tag',
)
Expand Down
Loading