forked from mirrors/bookwyrm
Separate out shelve button options lists
This commit is contained in:
parent
9ee1a110a9
commit
79602f69d7
4 changed files with 99 additions and 63 deletions
|
@ -7,5 +7,5 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block dropdown-list %}
|
||||
{% include 'snippets/shelve_button/shelve_button_options.html' with active_shelf=active_shelf shelves=user_shelves dropdown=True class="shelf-option is-fullwidth is-small is-radiusless is-white" %}
|
||||
{% include 'snippets/shelve_button/shelve_button_dropdown_options.html' with active_shelf=active_shelf shelves=user_shelves dropdown=True class="shelf-option is-fullwidth is-small is-radiusless is-white" %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
{% load bookwyrm_tags %}
|
||||
{% load utilities %}
|
||||
{% load i18n %}
|
||||
|
||||
{% with next_shelf_identifier=active_shelf.shelf.identifier|next_shelf %}
|
||||
|
||||
{% for shelf in shelves %}
|
||||
{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %}
|
||||
<li role="menuitem" class="dropdown-item p-0">
|
||||
<div
|
||||
class="{% if next_shelf_identifier == shelf.identifier %}is-hidden{% endif %}"
|
||||
data-shelf-dropdown-identifier="{{ shelf.identifier }}"
|
||||
data-shelf-next="{{ shelf.identifier|next_shelf }}"
|
||||
>
|
||||
{% if shelf.identifier == 'reading' %}
|
||||
|
||||
{% trans "Start reading" as button_text %}
|
||||
{% url 'reading-status' 'start' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start_reading" controls_uid=button_uuid focus="modal_title_start_reading" disabled=is_current fallback_url=fallback_url %}
|
||||
|
||||
{% elif shelf.identifier == 'read' %}
|
||||
|
||||
{% trans "Read" as button_text %}
|
||||
{% url 'reading-status' 'finish' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="finish_reading" controls_uid=button_uuid focus="modal_title_finish_reading" disabled=is_current fallback_url=fallback_url %}
|
||||
|
||||
{% elif shelf.identifier == 'to-read' %}
|
||||
|
||||
{% trans "Want to read" as button_text %}
|
||||
{% url 'reading-status' 'want' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="want_to_read" controls_uid=button_uuid focus="modal_title_want_to_read" disabled=is_current fallback_url=fallback_url %}
|
||||
|
||||
{% elif shelf.editable %}
|
||||
|
||||
<form name="shelve" action="/shelve/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
||||
<button class="button {{ class }}" name="shelf" type="submit" value="{{ shelf.identifier }}" {% if shelf in book.shelf_set.all %} disabled {% endif %}>
|
||||
<span>{{ shelf.name }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% if dropdown %}
|
||||
{% if readthrough and active_shelf.shelf.identifier != 'read' %}
|
||||
<li role="menuitem" class="dropdown-item p-0">
|
||||
{% trans "Update progress" as button_text %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="progress_update" controls_uid=button_uuid focus="modal_title_progress_update" %}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if active_shelf.shelf %}
|
||||
<li role="menuitem" class="dropdown-item p-0">
|
||||
<form name="shelve" action="/unshelve/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
||||
<input type="hidden" name="shelf" value="{{ active_shelf.shelf.id }}">
|
||||
<button class="button is-fullwidth is-small{% if dropdown %} is-radiusless{% endif %} is-danger is-light" type="submit">
|
||||
{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endwith %}
|
||||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
{% with next_shelf_identifier=active_shelf.shelf.identifier|next_shelf %}
|
||||
|
||||
{% if not dropdown %}
|
||||
<div
|
||||
class="{% if next_shelf_identifier != 'complete' %}is-hidden{% endif %}"
|
||||
data-shelf-identifier="complete"
|
||||
|
@ -13,42 +12,31 @@
|
|||
<span>{% trans "Read" %}</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% for shelf in shelves %}
|
||||
{% comparison_bool shelf.identifier active_shelf.shelf.identifier boolean=dropdown as is_current %}
|
||||
|
||||
{% if dropdown %}<li role="menuitem" class="dropdown-item p-0">{% endif %}
|
||||
|
||||
<div
|
||||
class="{% if not dropdown and next_shelf_identifier != shelf.identifier %}is-hidden{% endif %}"
|
||||
class="{% if next_shelf_identifier != shelf.identifier %}is-hidden{% endif %}"
|
||||
data-shelf-identifier="{{ shelf.identifier }}"
|
||||
data-shelf-next="{{ shelf.identifier|next_shelf }}"
|
||||
>
|
||||
{% if shelf.identifier == 'reading' %}
|
||||
{% if not dropdown or next_shelf_identifier != shelf.identifier %}
|
||||
|
||||
{% trans "Start reading" as button_text %}
|
||||
{% url 'reading-status' 'start' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start_reading" controls_uid=button_uuid focus="modal_title_start_reading" disabled=is_current fallback_url=fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="start_reading" controls_uid=button_uuid focus="modal_title_start_reading" fallback_url=fallback_url %}
|
||||
|
||||
{% endif %}
|
||||
{% elif shelf.identifier == 'read' %}
|
||||
{% if not dropdown or next_shelf_identifier != shelf.identifier %}
|
||||
|
||||
{% trans "Finish reading" as button_text %}
|
||||
{% url 'reading-status' 'finish' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="finish_reading" controls_uid=button_uuid focus="modal_title_finish_reading" disabled=is_current fallback_url=fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="finish_reading" controls_uid=button_uuid focus="modal_title_finish_reading" fallback_url=fallback_url %}
|
||||
|
||||
{% endif %}
|
||||
{% elif shelf.identifier == 'to-read' %}
|
||||
{% if not dropdown or next_shelf_identifier != shelf.identifier %}
|
||||
|
||||
{% trans "Want to read" as button_text %}
|
||||
{% url 'reading-status' 'want' book.id as fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="want_to_read" controls_uid=button_uuid focus="modal_title_want_to_read" disabled=is_current fallback_url=fallback_url %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="want_to_read" controls_uid=button_uuid focus="modal_title_want_to_read" fallback_url=fallback_url %}
|
||||
|
||||
{% endif %}
|
||||
{% elif shelf.editable %}
|
||||
|
||||
<form name="shelve" action="/shelve/" method="post">
|
||||
|
@ -61,30 +49,6 @@
|
|||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if dropdown %}</li>{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% if dropdown %}
|
||||
{% if readthrough and active_shelf.shelf.identifier != 'read' %}
|
||||
<li role="menuitem" class="dropdown-item p-0">
|
||||
{% trans "Update progress" as button_text %}
|
||||
{% include 'snippets/toggle/toggle_button.html' with class=class text=button_text controls_text="progress_update" controls_uid=button_uuid focus="modal_title_progress_update" %}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% if active_shelf.shelf %}
|
||||
<li role="menuitem" class="dropdown-item p-0">
|
||||
<form name="shelve" action="/unshelve/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="book" value="{{ active_shelf.book.id }}">
|
||||
<input type="hidden" name="shelf" value="{{ active_shelf.shelf.id }}">
|
||||
<button class="button is-fullwidth is-small{% if dropdown %} is-radiusless{% endif %} is-danger is-light" type="submit">
|
||||
{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endwith %}
|
||||
|
|
|
@ -36,9 +36,9 @@ def get_title(book, too_short=5):
|
|||
|
||||
|
||||
@register.simple_tag(takes_context=False)
|
||||
def comparison_bool(str1, str2, boolean=True):
|
||||
def comparison_bool(str1, str2):
|
||||
"""idk why I need to write a tag for this, it returns a bool"""
|
||||
return boolean and str1 == str2
|
||||
return str1 == str2
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
|
|
Loading…
Reference in a new issue