From 257c9854c205224463ba0f518e06613a3896cc9b Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 16 Aug 2021 11:30:11 -0700 Subject: [PATCH 01/17] Move reading modal templates to their own dir --- .../templates/reading_progress/finish.html | 2 +- .../templates/reading_progress/start.html | 2 +- bookwyrm/templates/reading_progress/want.html | 2 +- .../reading_modals/finish_reading_modal.html | 34 +++++++++++++ .../snippets/reading_modals/form.html | 9 ++++ .../snippets/reading_modals/layout.html | 26 ++++++++++ .../progress_update_modal.html | 0 .../reading_modals/start_reading_modal.html | 22 +++++++++ .../reading_modals/want_to_read_modal.html | 13 +++++ .../shelve_button/finish_reading_modal.html | 48 ------------------- .../snippets/shelve_button/shelve_button.html | 8 ++-- .../shelve_button/start_reading_modal.html | 42 ---------------- .../shelve_button/want_to_read_modal.html | 33 ------------- 13 files changed, 111 insertions(+), 130 deletions(-) create mode 100644 bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html create mode 100644 bookwyrm/templates/snippets/reading_modals/form.html create mode 100644 bookwyrm/templates/snippets/reading_modals/layout.html rename bookwyrm/templates/snippets/{shelve_button => reading_modals}/progress_update_modal.html (100%) create mode 100644 bookwyrm/templates/snippets/reading_modals/start_reading_modal.html create mode 100644 bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html delete mode 100644 bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html delete mode 100644 bookwyrm/templates/snippets/shelve_button/start_reading_modal.html delete mode 100644 bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html diff --git a/bookwyrm/templates/reading_progress/finish.html b/bookwyrm/templates/reading_progress/finish.html index a9f60f04..ca69128e 100644 --- a/bookwyrm/templates/reading_progress/finish.html +++ b/bookwyrm/templates/reading_progress/finish.html @@ -9,6 +9,6 @@ Finish "{{ book_title }}" {% block content %} -{% include "snippets/shelve_button/finish_reading_modal.html" with book=book active=True %} +{% include "snippets/reading_modals/finish_reading_modal.html" with book=book active=True %} {% endblock %} diff --git a/bookwyrm/templates/reading_progress/start.html b/bookwyrm/templates/reading_progress/start.html index 9c457947..e24a0e05 100644 --- a/bookwyrm/templates/reading_progress/start.html +++ b/bookwyrm/templates/reading_progress/start.html @@ -9,6 +9,6 @@ Start "{{ book_title }}" {% block content %} -{% include "snippets/shelve_button/start_reading_modal.html" with book=book active=True %} +{% include "snippets/reading_modals/start_reading_modal.html" with book=book active=True %} {% endblock %} diff --git a/bookwyrm/templates/reading_progress/want.html b/bookwyrm/templates/reading_progress/want.html index e0353193..6122ade3 100644 --- a/bookwyrm/templates/reading_progress/want.html +++ b/bookwyrm/templates/reading_progress/want.html @@ -9,6 +9,6 @@ Want to Read "{{ book_title }}" {% block content %} -{% include "snippets/shelve_button/want_to_read_modal.html" with book=book active=True %} +{% include "snippets/reading_modals/want_to_read_modal.html" with book=book active=True %} {% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html new file mode 100644 index 00000000..fdb5d7bb --- /dev/null +++ b/bookwyrm/templates/snippets/reading_modals/finish_reading_modal.html @@ -0,0 +1,34 @@ +{% extends 'snippets/reading_modals/layout.html' %} +{% load i18n %} +{% load utilities %} + +{% block modal-title %} +{% blocktrans trimmed with book_title=book|book_title %} +Finish "{{ book_title }}" +{% endblocktrans %} +{% endblock %} + +{% block modal-form-open %} +
+{% endblock %} + +{% block reading-dates %} +
+
+
+ + +
+
+
+
+ + +
+
+
+{% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/form.html b/bookwyrm/templates/snippets/reading_modals/form.html new file mode 100644 index 00000000..da2aad93 --- /dev/null +++ b/bookwyrm/templates/snippets/reading_modals/form.html @@ -0,0 +1,9 @@ +{% extends "snippets/create_status/layout.html" %} +{% load i18n %} + +{% block form_open %}{% endblock %} + +{% block initial_fields %} + + +{% endblock %} diff --git a/bookwyrm/templates/snippets/reading_modals/layout.html b/bookwyrm/templates/snippets/reading_modals/layout.html new file mode 100644 index 00000000..877f14ef --- /dev/null +++ b/bookwyrm/templates/snippets/reading_modals/layout.html @@ -0,0 +1,26 @@ +{% extends 'components/modal.html' %} +{% load i18n %} +{% load utilities %} + +{% block modal-body %} + +{% block reading-dates %}{% endblock %} + +{% with 0|uuid as local_uuid %} +
+ + +
+ +
+ + {% include "snippets/reading_modals/form.html" %} +
+{% endwith %} + +{% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/progress_update_modal.html b/bookwyrm/templates/snippets/reading_modals/progress_update_modal.html similarity index 100% rename from bookwyrm/templates/snippets/shelve_button/progress_update_modal.html rename to bookwyrm/templates/snippets/reading_modals/progress_update_modal.html diff --git a/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html new file mode 100644 index 00000000..08191c79 --- /dev/null +++ b/bookwyrm/templates/snippets/reading_modals/start_reading_modal.html @@ -0,0 +1,22 @@ +{% extends 'snippets/reading_modals/layout.html' %} +{% load i18n %} +{% load utilities %} + +{% block modal-title %} +{% blocktrans trimmed with book_title=book|book_title %} +Start "{{ book_title }}" +{% endblocktrans %} +{% endblock %} + +{% block modal-form-open %} + +{% endblock %} + +{% block reading-dates %} +
+ + +
+{% 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 new file mode 100644 index 00000000..5669610c --- /dev/null +++ b/bookwyrm/templates/snippets/reading_modals/want_to_read_modal.html @@ -0,0 +1,13 @@ +{% extends 'snippets/reading_modals/layout.html' %} +{% load i18n %} +{% load utilities %} + +{% block modal-title %} +{% blocktrans trimmed with book_title=book|book_title %} +Want to Read "{{ book_title }}" +{% endblocktrans %} +{% endblock %} + +{% block modal-form-open %} + +{% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html b/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html deleted file mode 100644 index 36addc7b..00000000 --- a/bookwyrm/templates/snippets/shelve_button/finish_reading_modal.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'components/modal.html' %} -{% load i18n %} - -{% block modal-title %} -{% blocktrans with book_title=book.title %}Finish "{{ book_title }}"{% endblocktrans %} -{% endblock %} - - -{% block modal-form-open %} - -{% endblock %} - -{% block modal-body %} - -{% endblock %} - -{% block modal-footer %} -
-
- - {% include 'snippets/privacy_select.html' %} -
-
- - {% trans "Cancel" as button_text %} - {% include 'snippets/toggle/close_button.html' with text=button_text controls_text="finish-reading" controls_uid=uuid %} -
-
-{% endblock %} -{% block modal-form-close %}
{% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/shelve_button.html b/bookwyrm/templates/snippets/shelve_button/shelve_button.html index 40a9f6e7..18941812 100644 --- a/bookwyrm/templates/snippets/shelve_button/shelve_button.html +++ b/bookwyrm/templates/snippets/shelve_button/shelve_button.html @@ -19,13 +19,13 @@ {% endif %} -{% include 'snippets/shelve_button/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid %} +{% include 'snippets/reading_modals/want_to_read_modal.html' with book=active_shelf.book controls_text="want_to_read" controls_uid=uuid %} -{% include 'snippets/shelve_button/start_reading_modal.html' with book=active_shelf.book controls_text="start_reading" controls_uid=uuid %} +{% include 'snippets/reading_modals/start_reading_modal.html' with book=active_shelf.book controls_text="start_reading" controls_uid=uuid %} -{% include 'snippets/shelve_button/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid readthrough=readthrough %} +{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book controls_text="finish_reading" controls_uid=uuid readthrough=readthrough %} -{% include 'snippets/shelve_button/progress_update_modal.html' with book=active_shelf_book.book controls_text="progress_update" controls_uid=uuid readthrough=readthrough %} +{% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf_book.book controls_text="progress_update" controls_uid=uuid readthrough=readthrough %} {% endwith %} {% endif %} diff --git a/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html b/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html deleted file mode 100644 index 1858313b..00000000 --- a/bookwyrm/templates/snippets/shelve_button/start_reading_modal.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends 'components/modal.html' %} -{% load i18n %} - -{% block modal-title %} -{% blocktrans trimmed with book_title=book.title %} -Start "{{ book_title }}" -{% endblocktrans %} -{% endblock %} - -{% block modal-form-open %} -
-{% endblock %} - -{% block modal-body %} - -{% endblock %} - -{% block modal-footer %} -
-
- - {% include 'snippets/privacy_select.html' %} -
-
- - {% trans "Cancel" as button_text %} - {% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="start-reading" controls_uid=uuid %} -
-
-{% endblock %} -{% block modal-form-close %}
{% endblock %} diff --git a/bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html b/bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html deleted file mode 100644 index 643e4a20..00000000 --- a/bookwyrm/templates/snippets/shelve_button/want_to_read_modal.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends 'components/modal.html' %} -{% load i18n %} - -{% block modal-title %} -{% blocktrans with book_title=book.title %}Want to Read "{{ book_title }}"{% endblocktrans %} -{% endblock %} - -{% block modal-form-open %} -
- {% csrf_token %} - - -{% endblock %} - -{% block modal-footer %} -
-
- - {% include 'snippets/privacy_select.html' %} -
-
- - {% trans "Cancel" as button_text %} - {% include 'snippets/toggle/toggle_button.html' with text=button_text controls_text="want-to-read" controls_uid=uuid %} -
-
-{% endblock %} -{% block modal-form-close %}
{% endblock %} From e6b785d731a7eb72b72a36259c4b1dea2b5bb21e Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 16 Aug 2021 12:28:04 -0700 Subject: [PATCH 02/17] No-update mode for "want to read" --- bookwyrm/static/js/bookwyrm.js | 17 +++++++++++++++++ .../snippets/reading_modals/layout.html | 8 +++++--- .../reading_modals/want_to_read_modal.html | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/bookwyrm/static/js/bookwyrm.js b/bookwyrm/static/js/bookwyrm.js index a4002c2d..45044b03 100644 --- a/bookwyrm/static/js/bookwyrm.js +++ b/bookwyrm/static/js/bookwyrm.js @@ -177,6 +177,12 @@ let BookWyrm = new class { this.toggleCheckbox(checkbox, pressed); } + // Toggle form disabled, if appropriate + let disable = trigger.dataset.disables; + if (disable) { + this.toggleDisabled(disable, !pressed); + } + // Set focus, if appropriate. let focus = trigger.dataset.focusTarget; @@ -227,6 +233,17 @@ let BookWyrm = new class { document.getElementById(checkbox).checked = !!pressed; } + /** + * Enable or disable a form element or fieldset + * + * @param {string} form_element - id of the element + * @param {boolean} pressed - Is the trigger pressed? + * @return {undefined} + */ + toggleDisabled(form_element, pressed) { + document.getElementById(form_element).disabled = !!pressed; + } + /** * Give the focus to an element. * Only move the focus based on user interactions. diff --git a/bookwyrm/templates/snippets/reading_modals/layout.html b/bookwyrm/templates/snippets/reading_modals/layout.html index 877f14ef..5190ada4 100644 --- a/bookwyrm/templates/snippets/reading_modals/layout.html +++ b/bookwyrm/templates/snippets/reading_modals/layout.html @@ -8,8 +8,8 @@ {% with 0|uuid as local_uuid %}
-