No-update mode for "want to read"

This commit is contained in:
Mouse Reeve 2021-08-16 12:28:04 -07:00
parent 257c9854c2
commit e6b785d731
3 changed files with 23 additions and 3 deletions

View file

@ -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.

View file

@ -8,8 +8,8 @@
{% with 0|uuid as local_uuid %}
<div class="is-flex is-justify-content-space-between">
<label for="post_status_start_{{ uuid }}" data-controls="reading_content_{{ local_uuid }}_{{ uuid }}" data-controls-checkbox="post_status_start_{{ local_uuid }}_{{ uuid }}" aria-pressed="true">
<input type="checkbox" name="post-status" class="checkbox" id="post_status_start_{{ local_uuid }}_{{ uuid }}" checked>
<label for="post_status_{{ local_uuid }}_{{ uuid }}" data-controls="reading_content_{{ local_uuid }}_{{ uuid }}" data-controls-checkbox="post_status_{{ local_uuid }}_{{ uuid }}" data-disables="reading_content_fieldset_{{ local_uuid }}_{{ uuid }}" aria-pressed="true">
<input type="checkbox" name="post-status" class="checkbox" id="post_status_{{ local_uuid }}_{{ uuid }}" checked>
{% trans "Post to feed" %}
</label>
<div class="is-hidden" id="hide_reading_content_{{ local_uuid }}_{{ uuid }}">
@ -19,7 +19,9 @@
<div id="reading_content_{{ local_uuid }}_{{ uuid }}">
<hr aria-hidden="true">
{% include "snippets/reading_modals/form.html" %}
<fieldset id="reading_content_fieldset_{{ local_uuid }}_{{ uuid }}">
{% include "snippets/reading_modals/form.html" %}
</fieldset>
</div>
{% endwith %}

View file

@ -10,4 +10,5 @@ Want to Read "<em>{{ book_title }}</em>"
{% block modal-form-open %}
<form name="shelve" action="{% url 'reading-status' 'want' book.id %}" method="post">
{% csrf_token %}
{% endblock %}