Cleanup after submitting modal

This commit is contained in:
Mouse Reeve 2021-09-09 17:03:31 -07:00
parent 06b0325c1b
commit 9ba066ad6d
2 changed files with 31 additions and 21 deletions

View file

@ -127,12 +127,25 @@ let StatusCache = new class {
button.querySelectorAll("[data-shelf-dropdown-identifier] button") button.querySelectorAll("[data-shelf-dropdown-identifier] button")
.forEach(item => item.disabled = false); .forEach(item => item.disabled = false);
next_identifier = next_identifier == 'complete' ? 'read' : next_identifier;
// disable the current state // disable the current state
button.querySelector("[data-shelf-dropdown-identifier=" + identifier + "] button").disabled = true; 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 + "]"); 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); 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();
}
} }
}(); }();

View file

@ -45,17 +45,15 @@
</li> </li>
{% endfor %} {% endfor %}
{% if readthrough and active_shelf.shelf.identifier != 'read' %}
{% if dropdown %} <li role="menuitem" class="dropdown-item p-0" data-extra-options>
{% if readthrough and active_shelf.shelf.identifier != 'read' %}
<li role="menuitem" class="dropdown-item p-0">
{% trans "Update progress" as button_text %} {% 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" %} {% 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> </li>
{% endif %} {% endif %}
{% if active_shelf.shelf %} {% if active_shelf.shelf %}
<li role="menuitem" class="dropdown-item p-0"> <li role="menuitem" class="dropdown-item p-0" data-extra-options>
<form name="shelve" action="/unshelve/" method="post"> <form name="shelve" action="/unshelve/" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="book" value="{{ active_shelf.book.id }}"> <input type="hidden" name="book" value="{{ active_shelf.book.id }}">
@ -64,8 +62,7 @@
{% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %} {% blocktrans with name=active_shelf.shelf.name %}Remove from {{ name }}{% endblocktrans %}
</button> </button>
</form> </form>
</li> </li>
{% endif %}
{% endif %} {% endif %}
{% endwith %} {% endwith %}