Show correct book when url param is provided

This commit is contained in:
Mouse Reeve 2021-04-03 13:53:04 -07:00
parent 029913de32
commit dae31459e4

View file

@ -12,6 +12,7 @@
{% if not suggested_books %} {% if not suggested_books %}
<p>{% trans "There are no books here right now! Try searching for a book to get started" %}</p> <p>{% trans "There are no books here right now! Try searching for a book to get started" %}</p>
{% else %} {% else %}
{% with active_book=request.GET.book %}
<div class="tab-group"> <div class="tab-group">
<div class="tabs is-small"> <div class="tabs is-small">
<ul role="tablist"> <ul role="tablist">
@ -28,8 +29,14 @@
<div class="tabs is-small is-toggle"> <div class="tabs is-small is-toggle">
<ul> <ul>
{% for book in shelf.books %} {% for book in shelf.books %}
<li{% if shelf_counter == 1 and forloop.first %} class="is-active"{% endif %}> <li class="{% if active_book == book.id|stringformat:'d' %}is-active{% elif not active_book and shelf_counter == 1 and forloop.first %}is-active{% endif %}">
<a href="#book-{{ book.id }}" id="tab-book-{{ book.id }}" role="tab" aria-label="{{ book.title }}" aria-selected="{% if shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}" aria-controls="book-{{ book.id }}"> <a
href="{{ request.path }}?book={{ book.id }}"
id="tab-book-{{ book.id }}"
role="tab"
aria-label="{{ book.title }}"
aria-selected="{% if active_book == book.id|stringformat:'d' %}true{% elif shelf_counter == 1 and forloop.first %}true{% else %}false{% endif %}"
aria-controls="book-{{ book.id }}">
{% include 'snippets/book_cover.html' with book=book size="medium" %} {% include 'snippets/book_cover.html' with book=book size="medium" %}
</a> </a>
</li> </li>
@ -45,7 +52,13 @@
{% for shelf in suggested_books %} {% for shelf in suggested_books %}
{% with shelf_counter=forloop.counter %} {% with shelf_counter=forloop.counter %}
{% for book in shelf.books %} {% for book in shelf.books %}
<div class="suggested-tabs card" role="tabpanel" id="book-{{ book.id }}"{% if shelf_counter != 1 or not forloop.first %} hidden{% endif %} aria-labelledby="tab-book-{{ book.id }}"> <div
class="suggested-tabs card"
role="tabpanel"
id="book-{{ book.id }}"
{% if active_book and active_book == book.id|stringformat:'d' %}{% elif not active_book and shelf_counter == 1 and forloop.first %}{% else %} hidden{% endif %}
aria-labelledby="tab-book-{{ book.id }}">
<div class="card-header"> <div class="card-header">
<div class="card-header-title"> <div class="card-header-title">
<div> <div>
@ -66,6 +79,7 @@
{% endwith %} {% endwith %}
{% endfor %} {% endfor %}
</div> </div>
{% endwith %}
{% endif %} {% endif %}
{% if goal %} {% if goal %}