From 9ba066ad6d14ad89804b418079a232cffe98d41f Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 9 Sep 2021 17:03:31 -0700 Subject: [PATCH] Cleanup after submitting modal --- bookwyrm/static/js/status_cache.js | 15 +++++++- .../shelve_button_dropdown_options.html | 37 +++++++++---------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index e8cda295e..1554bf116 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -127,12 +127,25 @@ let StatusCache = new class { button.querySelectorAll("[data-shelf-dropdown-identifier] button") .forEach(item => item.disabled = false); + next_identifier = next_identifier == 'complete' ? 'read' : next_identifier; // disable the current state button.querySelector("[data-shelf-dropdown-identifier=" + identifier + "] button").disabled = true; - // hide the option that's shown as the main button + let main_button = button.querySelector("[data-shelf-dropdown-identifier=" + next_identifier + "]"); + + // hide the option that's shown as the main button BookWyrm.addRemoveClass(main_button, "is-hidden", true); + // just hide the other two menu options, idk what to do with them + button.querySelectorAll("[data-extra-options]") + .forEach(item => BookWyrm.addRemoveClass(item, "is-hidden", true)); + + // close menu + let menu = button.querySelector(".dropdown-trigger[aria-expanded=true]"); + + if (menu) { + menu.click(); + } } }(); diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html index 2162a596a..32319f863 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button_dropdown_options.html @@ -45,27 +45,24 @@ {% endfor %} +{% if readthrough and active_shelf.shelf.identifier != 'read' %} + +{% endif %} -{% if dropdown %} - {% if readthrough and active_shelf.shelf.identifier != 'read' %} - - {% endif %} - - {% if active_shelf.shelf %} - - {% endif %} +{% if active_shelf.shelf %} + {% endif %} {% endwith %}