Skip to content

Commit

Permalink
sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Jul 15, 2024
1 parent c5a42e5 commit 0751fbd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
86 changes: 44 additions & 42 deletions peachjam/templates/peachjam/faceted_doc_table.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% load i18n %}
<div class="row" id="faceted-table">
<div class="col-lg-3 d-none d-lg-block">
<div>
{% block desktop-taxonomy-list %}{% endblock %}
</div>
<div class="pocketlaw-hidden">
<form method="get" id="filter-form" hx-include="#filter-form">
<form method="get" id="filter-form" hx-include="#filter-form">
<div class="row" id="faceted-table">
<div class="col-lg-3 d-none d-lg-block">
<div>
{% block desktop-taxonomy-list %}{% endblock %}
</div>
<div class="pocketlaw-hidden">
<ul class="list-group">
<li class="position-relative list-group-item bg-light d-flex justify-content-between align-items-center">
<strong>{% trans 'Filters' %}</strong>
Expand Down Expand Up @@ -67,42 +67,44 @@
{% endif %}
{% endfor %}
</ul>
</form>
</div>
</div>
</div>
<div class="col-lg-9">
<div class="position-relative">
{% block content %}
{% if documents %}
{% block filter-documents %}
<div class="row">
<div class="col">
<input id="filter-input"
form="filter-form"
aria-label="Filter"
placeholder="Filter documents"
class="form-control"
type="text"
name="q"/>
</div>
<div class="col-auto ms-0 ps-0">
<button hx-get="{{ request.path }}"
hx-target="#doc-table"
hx-push-url="true"
hx-include="#facetd-table"
class="btn btn-primary"
type="submit"
value="Filter">
Filter
</button>
<div class="col-lg-9">
<div class="position-relative">
{% block content %}
{% if documents %}
{% block filter-documents %}
<div class="mb-2 d-flex" hx-target="#doc-table" hx-push-url="true">
<div class="flex-grow-1 me-3">
<input id="filter-input"
hx-get="{{ request.path }}"
hx-trigger="keyup changed delay:300ms"
aria-label="{% trans "Filter documents" %}"
placeholder="{% trans "Filter documents" %}"
class="form-control"
type="text"
name="q"/>
</div>
<div class="me-2 d-flex align-items-center">
<div class="d-none d-md-block me-2 text-nowrap">{% trans "Sort by" %}:</div>
<select class="form-control" hx-get="{{ request.path }}" name="sort">
{% for opt in form.sort %}{{ opt }}{% endfor %}
</select>
</div>
<div>
<button class="btn btn-primary"
hx-get="{{ request.path }}"
type="submit"
value="Filter">Filter</button>
</div>
</div>
</div>
{% endblock %}
{% include 'peachjam/_document_table.html' %}
{% else %}
<p>{% trans 'No documents found.' %}</p>
{% endif %}
{% endblock %}
{% endblock %}
{% include 'peachjam/_document_table.html' %}
{% else %}
<p>{% trans 'No documents found.' %}</p>
{% endif %}
{% endblock %}
</div>
</div>
</div>
</div>
</form>
4 changes: 2 additions & 2 deletions peachjam/views/generic_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def __init__(self, title):

def get_template_names(self):
if self.request.htmx:
# TODO render all filters
if self.request.htmx.target == "doc-table":
return ["peachjam/_document_table.html"]
return ["peachjam/faceted_doc_table.html"]
return ["peachjam/_document_table.html"]
return super().get_template_names()


Expand Down

0 comments on commit 0751fbd

Please sign in to comment.