Merge pull request #696 from arkhi/fix-js
Fix toggling all checkboxes of failed imports
This commit is contained in:
commit
5c9a3a5667
|
@ -1,3 +1,8 @@
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
scroll-padding-top: 20%;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- --- */
|
/* --- --- */
|
||||||
.image {
|
.image {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
|
@ -8,9 +8,12 @@ window.onload = function() {
|
||||||
Array.from(document.getElementsByClassName('interaction'))
|
Array.from(document.getElementsByClassName('interaction'))
|
||||||
.forEach(t => t.onsubmit = interact);
|
.forEach(t => t.onsubmit = interact);
|
||||||
|
|
||||||
// select all
|
// Toggle all checkboxes.
|
||||||
Array.from(document.getElementsByClassName('select-all'))
|
document
|
||||||
.forEach(t => t.onclick = selectAll);
|
.querySelectorAll('[data-action="toggle-all"]')
|
||||||
|
.forEach(input => {
|
||||||
|
input.addEventListener('change', toggleAllCheckboxes);
|
||||||
|
});
|
||||||
|
|
||||||
// tab groups
|
// tab groups
|
||||||
Array.from(document.getElementsByClassName('tab-group'))
|
Array.from(document.getElementsByClassName('tab-group'))
|
||||||
|
@ -136,9 +139,20 @@ function interact(e) {
|
||||||
.forEach(t => addRemoveClass(t, 'hidden', t.className.indexOf('hidden') == -1));
|
.forEach(t => addRemoveClass(t, 'hidden', t.className.indexOf('hidden') == -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAll(e) {
|
/**
|
||||||
e.target.parentElement.parentElement.querySelectorAll('[type="checkbox"]')
|
* Toggle all descendant checkboxes of a target.
|
||||||
.forEach(t => t.checked=true);
|
*
|
||||||
|
* Use `data-target="ID_OF_TARGET"` on the node being listened to.
|
||||||
|
*
|
||||||
|
* @param {Event} event - change Event
|
||||||
|
* @return {undefined}
|
||||||
|
*/
|
||||||
|
function toggleAllCheckboxes(event) {
|
||||||
|
const mainCheckbox = event.target;
|
||||||
|
|
||||||
|
document
|
||||||
|
.querySelectorAll(`#${mainCheckbox.dataset.target} [type="checkbox"]`)
|
||||||
|
.forEach(checkbox => {checkbox.checked = mainCheckbox.checked;});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMenu(e) {
|
function toggleMenu(e) {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
{% block title %}{% trans "Import Status" %}{% endblock %}
|
{% block title %}{% trans "Import Status" %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}{% spaceless %}
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<h1 class="title">{% trans "Import Status" %}</h1>
|
<h1 class="title">{% trans "Import Status" %}</h1>
|
||||||
|
|
||||||
|
@ -36,8 +36,19 @@
|
||||||
{% if not job.retry %}
|
{% if not job.retry %}
|
||||||
<form name="retry" action="/import/{{ job.id }}" method="post">
|
<form name="retry" action="/import/{{ job.id }}" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% with failed_count=failed_items|length %}
|
||||||
|
{% if failed_count > 10 %}
|
||||||
|
<p class="block">
|
||||||
|
<a href="#select-all-failed-imports">
|
||||||
|
{% blocktrans %}Jump to the bottom of the list to select the {{ failed_count }} items which failed to import.{% endblocktrans %}
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
<fieldset id="failed-imports">
|
||||||
<ul>
|
<ul>
|
||||||
<fieldset>
|
|
||||||
{% for item in failed_items %}
|
{% for item in failed_items %}
|
||||||
<li class="pb-1">
|
<li class="pb-1">
|
||||||
<input class="checkbox" type="checkbox" name="import_item" value="{{ item.id }}" id="import-item-{{ item.id }}">
|
<input class="checkbox" type="checkbox" name="import_item" value="{{ item.id }}" id="import-item-{{ item.id }}">
|
||||||
|
@ -51,15 +62,28 @@
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
|
||||||
</ul>
|
</ul>
|
||||||
<div class="block pt-1 select-all">
|
</fieldset>
|
||||||
<label class="label">
|
|
||||||
<input type="checkbox" class="checkbox">
|
<fieldset class="mt-3">
|
||||||
|
<a name="select-all-failed-imports"></a>
|
||||||
|
|
||||||
|
<label class="label is-inline">
|
||||||
|
<input
|
||||||
|
id="toggle-all-checkboxes-failed-imports"
|
||||||
|
class="checkbox"
|
||||||
|
type="checkbox"
|
||||||
|
data-action="toggle-all"
|
||||||
|
data-target="failed-imports"
|
||||||
|
/>
|
||||||
{% trans "Select all" %}
|
{% trans "Select all" %}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
|
||||||
<button class="button" type="submit">{% trans "Retry items" %}</button>
|
<button class="button is-block mt-3" type="submit">{% trans "Retry items" %}</button>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for item in failed_items %}
|
{% for item in failed_items %}
|
||||||
|
@ -123,4 +147,4 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endspaceless %}{% endblock %}
|
||||||
|
|
Binary file not shown.
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: 0.1.1\n"
|
"Project-Id-Version: 0.1.1\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-03-04 22:24+0000\n"
|
"POT-Creation-Date: 2021-03-05 14:10+0000\n"
|
||||||
"PO-Revision-Date: 2021-03-02 12:37+0100\n"
|
"PO-Revision-Date: 2021-03-02 12:37+0100\n"
|
||||||
"Last-Translator: Fabien Basmaison <contact@arkhi.org>\n"
|
"Last-Translator: Fabien Basmaison <contact@arkhi.org>\n"
|
||||||
"Language-Team: Mouse Reeve <LL@li.org>\n"
|
"Language-Team: Mouse Reeve <LL@li.org>\n"
|
||||||
|
@ -613,37 +613,42 @@ msgstr "(Rechargez la page pour mettre à jour !"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:35
|
#: bookwyrm/templates/import_status.html:35
|
||||||
msgid "Failed to load"
|
msgid "Failed to load"
|
||||||
msgstr "Le chargement a échoué"
|
msgstr "Items non importés"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:59
|
#: bookwyrm/templates/import_status.html:42
|
||||||
|
#, python-format
|
||||||
|
msgid "Jump to the bottom of the list to select the %(failed_count)s items which failed to import."
|
||||||
|
msgstr "Sauter en bas de liste pour sélectionner les %(failed_count)s items n’ayant pu être importés."
|
||||||
|
|
||||||
|
#: bookwyrm/templates/import_status.html:74
|
||||||
msgid "Select all"
|
msgid "Select all"
|
||||||
msgstr "Tout sélectionner"
|
msgstr "Tout sélectionner"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:62
|
#: bookwyrm/templates/import_status.html:79
|
||||||
msgid "Retry items"
|
msgid "Retry items"
|
||||||
msgstr "Essayer d’importer les objets sélectionnés de nouveau"
|
msgstr "Essayer d’importer les items sélectionnés de nouveau"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:84
|
#: bookwyrm/templates/import_status.html:101
|
||||||
msgid "Successfully imported"
|
msgid "Successfully imported"
|
||||||
msgstr "Importation réussie"
|
msgstr "Importation réussie"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:88
|
#: bookwyrm/templates/import_status.html:105
|
||||||
#: bookwyrm/templates/lists/curate.html:14
|
#: bookwyrm/templates/lists/curate.html:14
|
||||||
msgid "Book"
|
msgid "Book"
|
||||||
msgstr "Livre"
|
msgstr "Livre"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:91
|
#: bookwyrm/templates/import_status.html:108
|
||||||
#: bookwyrm/templates/snippets/create_status_form.html:10
|
#: bookwyrm/templates/snippets/create_status_form.html:10
|
||||||
#: bookwyrm/templates/snippets/shelf.html:10
|
#: bookwyrm/templates/snippets/shelf.html:10
|
||||||
msgid "Title"
|
msgid "Title"
|
||||||
msgstr "Titre"
|
msgstr "Titre"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:94
|
#: bookwyrm/templates/import_status.html:111
|
||||||
#: bookwyrm/templates/snippets/shelf.html:11
|
#: bookwyrm/templates/snippets/shelf.html:11
|
||||||
msgid "Author"
|
msgid "Author"
|
||||||
msgstr "Auteur ou autrice"
|
msgstr "Auteur ou autrice"
|
||||||
|
|
||||||
#: bookwyrm/templates/import_status.html:117
|
#: bookwyrm/templates/import_status.html:134
|
||||||
msgid "Imported"
|
msgid "Imported"
|
||||||
msgstr "Importé"
|
msgstr "Importé"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue