fix blocklistsubmission all|none links (#20929)
This commit is contained in:
Родитель
15b476a76f
Коммит
bec51655da
|
@ -22,8 +22,8 @@
|
|||
{% if block_obj.id %}
|
||||
<span class="existing_block">[<a href="{% url 'admin:blocklist_block_change' block_obj.id %}">Edit Block</a>]</span>
|
||||
{% endif %}
|
||||
[<a href='#' class="select-all-versions">select all</a>]
|
||||
[<a href='#' class="select-none-versions">select none</a>]
|
||||
[<a href='#' class="select-versions-all-none all-versions">select all</a>]
|
||||
[<a href='#' class="select-versions-all-none">select none</a>]
|
||||
<ul>
|
||||
{% for version in block_obj.addon_versions %}
|
||||
<li data-version-id="{{ version.id }}">
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
'use strict';
|
||||
|
||||
const checkAllCheckboxes = (event) =>
|
||||
const checkOrClearAllCheckboxes = (event) => {
|
||||
event.target.parentElement
|
||||
.querySelectorAll(`input[name="changed_version_ids"]`)
|
||||
.forEach((checkbox) => checkbox.setAttribute('checked', true));
|
||||
const clearAllCheckboxes = (event) =>
|
||||
event.target.parentElement
|
||||
.querySelectorAll(`input[name="changed_version_ids"]`)
|
||||
.forEach((checkbox) => checkbox.removeAttribute('checked'));
|
||||
.forEach(
|
||||
(checkbox) =>
|
||||
(checkbox.checked = event.target.classList.contains('all-versions')),
|
||||
);
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
document
|
||||
.querySelectorAll('a.select-all-versions')
|
||||
.forEach((a) => a.addEventListener('click', checkAllCheckboxes, true));
|
||||
document
|
||||
.querySelectorAll('a.select-none-versions')
|
||||
.forEach((a) => a.addEventListener('click', clearAllCheckboxes, true));
|
||||
.querySelectorAll('a.select-versions-all-none')
|
||||
.forEach((a) =>
|
||||
a.addEventListener('click', checkOrClearAllCheckboxes, true),
|
||||
);
|
||||
|
||||
const enableIfChecked = (isChecked, fieldId) => {
|
||||
const field = document.querySelector(`#${fieldId}`);
|
||||
|
|
Загрузка…
Ссылка в новой задаче