mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +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 %}
|
{% plural %}
|
||||||
{{ formatted_count }} books
|
{{ formatted_count }} books
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
|
||||||
{% if books.has_other_pages %}
|
{% if books.has_other_pages %}
|
||||||
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
|
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
|
||||||
(showing {{ start }}-{{ end }})
|
(showing {{ start }}-{{ end }})
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if shelves_filter_msg %}
|
||||||
|
- {{ shelves_filter_msg }} "{{ shelves_filter_query }}"
|
||||||
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
</h2>
|
</h2>
|
||||||
{% if books|length > 0 %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</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' %}
|
{% extends 'snippets/filters_panel/filters_panel.html' %}
|
||||||
|
|
||||||
{% block filter_fields %}
|
{% block filter_fields %}
|
||||||
{% include 'shelf/search_filter_field.html' %}
|
{% include 'shelf/shelves_filter_field.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -34,7 +34,8 @@ class Shelf(View):
|
||||||
else:
|
else:
|
||||||
shelves = models.Shelf.privacy_filter(request.user).filter(user=user).all()
|
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
|
# get the shelf and make sure the logged in user should be able to see it
|
||||||
if shelf_identifier:
|
if shelf_identifier:
|
||||||
|
@ -92,8 +93,9 @@ class Shelf(View):
|
||||||
|
|
||||||
books = sort_books(books, request.GET.get("sort"))
|
books = sort_books(books, request.GET.get("sort"))
|
||||||
|
|
||||||
if shelves_search_query:
|
if shelves_filter_query:
|
||||||
books = search(shelves_search_query, books=books)
|
books = search(shelves_filter_query, books=books) or books
|
||||||
|
shelves_filter_msg = "We couldn't find any books that matched"
|
||||||
|
|
||||||
paginated = Paginator(
|
paginated = Paginator(
|
||||||
books,
|
books,
|
||||||
|
@ -112,7 +114,8 @@ class Shelf(View):
|
||||||
"page_range": paginated.get_elided_page_range(
|
"page_range": paginated.get_elided_page_range(
|
||||||
page.number, on_each_side=2, on_ends=1
|
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)
|
return TemplateResponse(request, "shelf/shelf.html", data)
|
||||||
|
|
Loading…
Reference in a new issue