From 49f1226f3a62871f087ff77b0d7bda64c60033f1 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 9 Sep 2021 08:06:36 -0700 Subject: [PATCH] Close modals after submit --- bookwyrm/static/js/status_cache.js | 6 ++++++ .../snippets/reading_modals/finish_reading_modal.html | 2 +- .../snippets/reading_modals/progress_update_modal.html | 2 +- .../snippets/reading_modals/start_reading_modal.html | 2 +- .../snippets/reading_modals/want_to_read_modal.html | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bookwyrm/static/js/status_cache.js b/bookwyrm/static/js/status_cache.js index 10ab18f9..ee563a15 100644 --- a/bookwyrm/static/js/status_cache.js +++ b/bookwyrm/static/js/status_cache.js @@ -74,6 +74,12 @@ let StatusCache = new class { .forEach(node => window.localStorage.removeItem(node.dataset.cacheDraft)); // Close modals + let modal = form.closest(".modal.is-active"); + if (!!modal) { + modal.getElementsByClassName("modal-close")[0].click(); + } + + // Update buttons } }(); diff --git a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html index 3a034693..b041b70a 100644 --- a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html @@ -9,7 +9,7 @@ Finish "{{ book_title }}" {% endblock %} {% block modal-form-open %} -
+ {% csrf_token %} {% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html b/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html index c766153a..b4ed8e0c 100644 --- a/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html @@ -6,7 +6,7 @@ {% endblock %} {% block modal-form-open %} - + {% endblock %} {% block modal-body %} diff --git a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html index 099fd915..827c0a86 100644 --- a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html @@ -9,7 +9,7 @@ Start "{{ book_title }}" {% endblock %} {% block modal-form-open %} - + {% csrf_token %} {% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html index 1213b18e..5dec637b 100644 --- a/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html +++ b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html @@ -9,7 +9,7 @@ Want to Read "{{ book_title }}" {% endblock %} {% block modal-form-open %} - + {% csrf_token %} {% endblock %}