moviewyrm/bookwyrm/templates/snippets/shelve_button.html

71 lines
3.5 KiB
HTML
Raw Normal View History

2020-12-13 02:25:04 +00:00
{% load bookwyrm_tags %}
{% if request.user.is_authenticated %}
{% with book.id|uuid as uuid %}
{% active_shelf book as active_shelf %}
2021-01-17 18:40:40 +00:00
<div class="field has-addons">
<div class="control">
{% if switch_mode and active_shelf.book != book %}
{% include 'snippets/switch_edition_button.html' with edition=book size='is-small' %}
{% else %}
2020-12-16 22:45:35 +00:00
2021-01-17 18:40:40 +00:00
{% if active_shelf.shelf.identifier == 'read' %}
<button class="button is-small" disabled>
<span>Read</span> <span class="icon icon-check"></span>
</button>
{% elif active_shelf.shelf.identifier == 'reading' %}
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="I'm done!" controls_text="finish-reading" controls_uid=uuid %}
{% elif active_shelf.shelf.identifier == 'to-read' %}
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Start reading" controls_text="start-reading" controls_uid=uuid %}
{% else %}
<form name="shelve" action="/shelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
<input type="hidden" name="shelf" value="to-read">
<button class="button is-small" type="submit">Want to read</button>
</form>
{% endif %}
</div>
2020-11-06 00:48:15 +00:00
<div class="dropdown control is-hoverable">
<div class="dropdown-trigger">
<label for="shelf-select-dropdown-{{ uuid }}-toggle" role="button" aria-expanded="false" class="pulldown-menu" tabindex="0" aria-haspopup="true" aria-controls="shelf-select-{{ uuid }}">
<div class="button is-small">
<span class="icon icon-arrow-down"><span class="is-sr-only">More shelves</span></span>
</div>
</label>
2020-11-06 00:48:15 +00:00
</div>
<div class="dropdown-menu" id="shelf-select-{{ uuid }}" role="menu">
2020-11-06 00:48:15 +00:00
<ul class="dropdown-content">
2020-11-06 16:51:50 +00:00
{% for shelf in request.user.shelf_set.all %}
<li role="menuitem">
{% if active_shelf.shelf.identifier != 'reading' and shelf.identifier == 'reading' %}
<div class="dropdown-item pt-0 pb-0">
2021-01-17 18:10:59 +00:00
{% include 'snippets/toggle/toggle_button.html' with class="is-small" text="Start reading" controls_text="start-reading" controls_uid=uuid %}
</div>
{% else %}
<form class="dropdown-item pt-0 pb-0" name="shelve" action="/shelve/" method="post">
2020-11-06 16:51:50 +00:00
{% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
<button class="button is-small" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>
<span>{{ shelf.name }}</span>
{% if shelf in book.shelf_set.all %}<span class="icon icon-check"></span>{% endif %}
</button>
2020-11-06 16:51:50 +00:00
</form>
{% endif %}
2020-11-06 16:51:50 +00:00
</li>
{% endfor %}
2020-11-06 00:48:15 +00:00
</ul>
</div>
2020-09-28 22:57:31 +00:00
</div>
2020-12-16 22:45:35 +00:00
{% endif %}
2020-11-06 00:48:15 +00:00
</div>
2021-01-17 18:10:59 +00:00
{% include 'snippets/start_reading_modal.html' with book=active_shelf.book controls_text="start-reading" controls_uid=uuid %}
{% latest_read_through book request.user as readthrough %}
{% include 'snippets/finish_reading_modal.html' with book=active_shelf.book controls_text="finish-reading" controls_uid=uuid readthrough=readthrough %}
{% endwith %}
{% endif %}