From e5746d611783c2410c6e33dadd157798a9e322ad Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 30 Jan 2021 11:43:40 -0800 Subject: [PATCH] Menu list for shelf button options --- bookwyrm/static/css/format.css | 7 +++++++ .../templates/snippets/shelve_button.html | 17 +--------------- .../snippets/shelve_button_dropdown.html | 20 +------------------ .../snippets/toggle/toggle_button.html | 3 ++- bookwyrm/templatetags/bookwyrm_tags.py | 13 ++++++++++++ 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index f10549ed..50ce101e 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -13,6 +13,13 @@ overflow: hidden; } +/* --- SHELVING --- */ +.shelf-option:disabled > *::after { + font-family: "icomoon"; + content: "\e918"; + margin-left: 0.5em; +} + /* --- TOGGLES --- */ .toggle-button[aria-pressed=true], .toggle-button[aria-pressed=true]:hover { background-color: hsl(171, 100%, 41%); diff --git a/bookwyrm/templates/snippets/shelve_button.html b/bookwyrm/templates/snippets/shelve_button.html index f69ab525..946368c2 100644 --- a/bookwyrm/templates/snippets/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button.html @@ -10,22 +10,7 @@ {% else %}
- {% if active_shelf.shelf.identifier == 'read' %} - - {% 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 focus="modal-title-finish-reading" %} - {% 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 focus="modal-title-start-reading" %} - {% else %} -
- {% csrf_token %} - - - -
- {% endif %} + {% include 'snippets/shelve_button_options.html' with class="shelf-option is-small" shelves=request.user.shelf_set.all active_shelf=active_shelf %}
{% include 'snippets/shelve_button_dropdown.html' with class="is-small" button_uuid=uuid%} {% endif %} diff --git a/bookwyrm/templates/snippets/shelve_button_dropdown.html b/bookwyrm/templates/snippets/shelve_button_dropdown.html index 50140e3f..d70765a3 100644 --- a/bookwyrm/templates/snippets/shelve_button_dropdown.html +++ b/bookwyrm/templates/snippets/shelve_button_dropdown.html @@ -6,23 +6,5 @@ {% endblock %} {% block dropdown-list %} -{% for shelf in request.user.shelf_set.all %} -
  • - {% if active_shelf.shelf.identifier != 'reading' and shelf.identifier == 'reading' %} - - {% else %} - - {% endif %} -
  • -{% endfor %} +{% include 'snippets/shelve_button_options.html' with active_shelf=active_shelf shelves=request.user.shelf_set.all dropdown=True class="shelf-option is-fullwidth is-small" %} {% endblock %} - diff --git a/bookwyrm/templates/snippets/toggle/toggle_button.html b/bookwyrm/templates/snippets/toggle/toggle_button.html index d6fd0a36..fe1823f1 100644 --- a/bookwyrm/templates/snippets/toggle/toggle_button.html +++ b/bookwyrm/templates/snippets/toggle/toggle_button.html @@ -6,6 +6,7 @@ {% if checkbox %}data-controls-checkbox="{{ checkbox }}{% if controls_uid %}-{{ controls_uid }}{% endif %}"{% endif %} {% if label %}aria-label="{{ label }}"{% endif %} aria-pressed="{% if pressed %}true{% else %}false{% endif %}" + {% if disabled %}disabled{% endif %} > {% if icon %} @@ -13,6 +14,6 @@ {{ text }} {% else %} - {{ text }} + {{ text }} {% endif %} diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 08bbcafe..c1a2d14e 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -159,6 +159,14 @@ def get_status_preview_name(obj): return '%s from %s' % (name, obj.book.title) return name +@register.filter(name='next_shelf') +def get_next_shelf(current_shelf): + if current_shelf == 'to-read': + return 'reading' + if current_shelf == 'reading': + return 'read' + return 'to-read' + @register.simple_tag(takes_context=False) def related_status(notification): ''' for notifications ''' @@ -199,3 +207,8 @@ def active_read_through(book, user): book=book, finish_date__isnull=True ).order_by('-start_date').first() + + +@register.simple_tag(takes_context=False) +def comparison_bool(str1, str2): + return str1 == str2