add select all|none links for [un]block version checkboxes (#20912)
This commit is contained in:
Родитель
8fce06e757
Коммит
7bd1883f6f
|
@ -22,6 +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>]
|
||||
<ul>
|
||||
{% for version in block_obj.addon_versions %}
|
||||
<li data-version-id="{{ version.id }}">
|
||||
|
|
|
@ -1,6 +1,21 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
'use strict';
|
||||
|
||||
const checkAllCheckboxes = (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'));
|
||||
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));
|
||||
|
||||
const enableIfChecked = (isChecked, fieldId) => {
|
||||
const field = document.querySelector(`#${fieldId}`);
|
||||
if (isChecked) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче