mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
Adds filters ui to editions page
This commit is contained in:
parent
b13e8d75cd
commit
769ba6466c
5 changed files with 41 additions and 2 deletions
6
bookwyrm/templates/book/edition_filters.html
Normal file
6
bookwyrm/templates/book/edition_filters.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{% extends 'snippets/filters_panel/filters_panel.html' %}
|
||||
|
||||
{% block filter_fields %}
|
||||
{% include 'book/language_filter.html' %}
|
||||
{% include 'book/format_filter.html' %}
|
||||
{% endblock %}
|
|
@ -7,7 +7,11 @@
|
|||
{% block content %}
|
||||
<div class="block">
|
||||
<h1 class="title">{% blocktrans with work_path=work.local_path work_title=work.title %}Editions of <a href="{{ work_path }}">"{{ work_title }}"</a>{% endblocktrans %}</h1>
|
||||
</div>
|
||||
|
||||
{% include 'book/edition_filters.html' %}
|
||||
|
||||
<div class="block">
|
||||
{% for book in editions %}
|
||||
<div class="columns">
|
||||
<div class="column is-2">
|
||||
|
@ -30,4 +34,3 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
13
bookwyrm/templates/book/format_filter.html
Normal file
13
bookwyrm/templates/book/format_filter.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends 'snippets/filters_panel/filter_field.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block filter %}
|
||||
<label class="label is-block" for="id_format">{% trans "Format:" %}</label>
|
||||
<div class="select">
|
||||
<select id="format" name="format">
|
||||
{% for format in formats %}{% if format %}
|
||||
<option value="{{ format }}">{{ format|title }}</option>
|
||||
{% endif %}{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% endblock %}
|
13
bookwyrm/templates/book/language_filter.html
Normal file
13
bookwyrm/templates/book/language_filter.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends 'snippets/filters_panel/filter_field.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block filter %}
|
||||
<label class="label is-block" for="id_language">{% trans "Language:" %}</label>
|
||||
<div class="select">
|
||||
<select id="language" name="language">
|
||||
{% for language in languages %}
|
||||
<option value="{{ language }}">{{ language }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -252,10 +252,14 @@ class Editions(View):
|
|||
|
||||
if is_api_request(request):
|
||||
return ActivitypubResponse(work.to_edition_list(**request.GET))
|
||||
editions = work.editions.order_by("-edition_rank").all()
|
||||
languages = set(sum([e.languages for e in editions], []))
|
||||
|
||||
data = {
|
||||
"editions": work.editions.order_by("-edition_rank").all(),
|
||||
"editions": editions,
|
||||
"work": work,
|
||||
"languages": languages,
|
||||
"formats": set(e.physical_format.lower() for e in editions),
|
||||
}
|
||||
return TemplateResponse(request, "book/editions.html", data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue