mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Shows message if empty and renames "search" to "filter"
This commit is contained in:
parent
7cca199a11
commit
4a4046a704
5 changed files with 21 additions and 16 deletions
|
@ -1,9 +0,0 @@
|
|||
{% extends 'snippets/filters_panel/filter_field.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block filter %}
|
||||
<div class="control">
|
||||
<label class="label" for="search_query">{% trans 'Search by keyword' %}</label>
|
||||
<input aria-label="Search by keyword" id="my-books-search" class="input" type="text" name="shelves_q" placeholder="Enter text here" value="{{ shelves_search_query|default:'' }}" spellcheck="false" />
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -101,18 +101,20 @@
|
|||
{% plural %}
|
||||
{{ formatted_count }} books
|
||||
{% endblocktrans %}
|
||||
|
||||
{% if books.has_other_pages %}
|
||||
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
|
||||
(showing {{ start }}-{{ end }})
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% if shelves_filter_msg %}
|
||||
- {{ shelves_filter_msg }} "{{ shelves_filter_query }}"
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</h2>
|
||||
{% if books|length > 0 %}
|
||||
{% include 'shelf/search_filters.html' with user=user query=query %}
|
||||
{% include 'shelf/shelves_filters.html' with user=user query=query %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
|
9
bookwyrm/templates/shelf/shelves_filter_field.html
Normal file
9
bookwyrm/templates/shelf/shelves_filter_field.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends 'snippets/filters_panel/filter_field.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block filter %}
|
||||
<div class="control">
|
||||
<label class="label" for="filter_query">{% trans 'Filter by keyword' %}</label>
|
||||
<input aria-label="Filter by keyword" id="my-books-filter" class="input" type="text" name="filter" placeholder="{% trans 'Enter text here' %}" value="{{ shelves_filter_query|default:'' }}" spellcheck="false" />
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,5 +1,5 @@
|
|||
{% extends 'snippets/filters_panel/filters_panel.html' %}
|
||||
|
||||
{% block filter_fields %}
|
||||
{% include 'shelf/search_filter_field.html' %}
|
||||
{% include 'shelf/shelves_filter_field.html' %}
|
||||
{% endblock %}
|
|
@ -34,7 +34,8 @@ class Shelf(View):
|
|||
else:
|
||||
shelves = models.Shelf.privacy_filter(request.user).filter(user=user).all()
|
||||
|
||||
shelves_search_query = request.GET.get("shelves_q")
|
||||
shelves_filter_query = request.GET.get("filter")
|
||||
shelves_filter_msg = ""
|
||||
|
||||
# get the shelf and make sure the logged in user should be able to see it
|
||||
if shelf_identifier:
|
||||
|
@ -92,8 +93,9 @@ class Shelf(View):
|
|||
|
||||
books = sort_books(books, request.GET.get("sort"))
|
||||
|
||||
if shelves_search_query:
|
||||
books = search(shelves_search_query, books=books)
|
||||
if shelves_filter_query:
|
||||
books = search(shelves_filter_query, books=books) or books
|
||||
shelves_filter_msg = "We couldn't find any books that matched"
|
||||
|
||||
paginated = Paginator(
|
||||
books,
|
||||
|
@ -112,7 +114,8 @@ class Shelf(View):
|
|||
"page_range": paginated.get_elided_page_range(
|
||||
page.number, on_each_side=2, on_ends=1
|
||||
),
|
||||
"shelves_search_query": shelves_search_query,
|
||||
"shelves_filter_query": shelves_filter_query,
|
||||
"shelves_filter_msg": shelves_filter_msg,
|
||||
}
|
||||
|
||||
return TemplateResponse(request, "shelf/shelf.html", data)
|
||||
|
|
Loading…
Reference in a new issue