Fix partial swaps on table

This commit is contained in:
Mark Veidemanis 2022-12-02 07:20:37 +00:00
parent 32aa93a28e
commit 78b28b3994
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
4 changed files with 13 additions and 9 deletions

View File

@ -77,6 +77,7 @@ urlpatterns = [
path("__debug__/", include("debug_toolbar.urls")), path("__debug__/", include("debug_toolbar.urls")),
path("", DrilldownTableView.as_view(), name="home"), path("", DrilldownTableView.as_view(), name="home"),
path("search/", DrilldownTableView.as_view(), name="search"), path("search/", DrilldownTableView.as_view(), name="search"),
path("search/partial/", DrilldownTableView.as_view(), name="search_partial"),
path("about/", About.as_view(), name="about"), path("about/", About.as_view(), name="about"),
path("callback", Callback.as_view(), name="callback"), path("callback", Callback.as_view(), name="callback"),
path("billing/", Billing.as_view(), name="billing"), path("billing/", Billing.as_view(), name="billing"),

View File

@ -4,6 +4,7 @@
{% load joinsep %} {% load joinsep %}
{% load urlsafe %} {% load urlsafe %}
{% block table-wrapper %} {% block table-wrapper %}
<script src="{% static 'js/column-shifter.js' %}"></script>
<div id="drilldown-table" class="column-shifter-container" style="position:relative; z-index:1;"> <div id="drilldown-table" class="column-shifter-container" style="position:relative; z-index:1;">
{% block table %} {% block table %}
<div class="nowrap-parent"> <div class="nowrap-parent">
@ -80,11 +81,11 @@
</div> </div>
<div class="nowrap-child"> <div class="nowrap-child">
<a <a
hx-get="search/{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}&{{ uri }}" hx-get="search/partial/{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}&{{ uri }}"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click" hx-trigger="click"
hx-target="#drilldown-table" hx-target="#drilldown-table"
hx-swap="innerHTML" hx-swap="outerHTML"
hx-indicator="#spinner" hx-indicator="#spinner"
style="cursor: pointer;"> style="cursor: pointer;">
{{ column.header }} {{ column.header }}
@ -421,11 +422,11 @@
<a <a
class="pagination-previous is-flex-grow-0 {% if not table.page.has_previous %}is-hidden-mobile{% endif %}" class="pagination-previous is-flex-grow-0 {% if not table.page.has_previous %}is-hidden-mobile{% endif %}"
{% if table.page.has_previous %} {% if table.page.has_previous %}
hx-get="search/{% querystring table.prefixed_page_field=table.page.previous_page_number %}&{{ uri }}" hx-get="search/partial/{% querystring table.prefixed_page_field=table.page.previous_page_number %}&{{ uri }}"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click" hx-trigger="click"
hx-target="#drilldown-table" hx-target="#drilldown-table"
hx-swap="innerHTML" hx-swap="outerHTML"
hx-indicator="#spinner" hx-indicator="#spinner"
{% else %} {% else %}
href="#" href="#"
@ -441,11 +442,11 @@
<a <a
class="pagination-next is-flex-grow-0 {% if not table.page.has_next %}is-hidden-mobile{% endif %}" class="pagination-next is-flex-grow-0 {% if not table.page.has_next %}is-hidden-mobile{% endif %}"
{% if table.page.has_next %} {% if table.page.has_next %}
hx-get="search/{% querystring table.prefixed_page_field=table.page.next_page_number %}&{{ uri }}" hx-get="search/partial/{% querystring table.prefixed_page_field=table.page.next_page_number %}&{{ uri }}"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click" hx-trigger="click"
hx-target="#drilldown-table" hx-target="#drilldown-table"
hx-swap="innerHTML" hx-swap="outerHTML"
hx-indicator="#spinner" hx-indicator="#spinner"
{% else %} {% else %}
href="#" href="#"
@ -470,11 +471,11 @@
{% if p == table.page.number %} {% if p == table.page.number %}
href="#" href="#"
{% else %} {% else %}
hx-get="search/{% querystring table.prefixed_page_field=p %}&{{ uri }}" hx-get="search/partial/{% querystring table.prefixed_page_field=p %}&{{ uri }}"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click" hx-trigger="click"
hx-target="#drilldown-table" hx-target="#drilldown-table"
hx-swap="innerHTML" hx-swap="outerHTML"
hx-indicator="#spinner" hx-indicator="#spinner"
{% endif %} {% endif %}
> >

View File

@ -1,7 +1,6 @@
{% load static %} {% load static %}
{% include 'partials/notify.html' %} {% include 'partials/notify.html' %}
<script src="{% static 'js/column-shifter.js' %}"></script>
{% if cache is not None %} {% if cache is not None %}
<span class="icon has-tooltip-bottom" data-tooltip="Cached"> <span class="icon has-tooltip-bottom" data-tooltip="Cached">
<i class="fa-solid fa-database"></i> <i class="fa-solid fa-database"></i>

View File

@ -115,6 +115,9 @@ class DrilldownTableView(SingleTableView):
self.template_name = "index.html" self.template_name = "index.html"
# GET arguments in URL like ?query=xyz # GET arguments in URL like ?query=xyz
query_params = request.GET.dict() query_params = request.GET.dict()
if request.htmx:
if request.resolver_match.url_name == "search_partial":
self.template_name = "partials/results_table.html"
elif request.POST: elif request.POST:
query_params = request.POST.dict() query_params = request.POST.dict()
else: else: