blob: 20112c0147b1f0bb7a988effefd2ae3e6dc7783a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
function initDataQuality(): void {
const form = document.getElementById("data-quality-form") as HTMLFormElement | null;
const selectAll = document.getElementById("data-quality-select-all") as HTMLInputElement | null;
const counter = document.getElementById("data-quality-selected");
if (!form || !selectAll) return;
const selectAllInput: HTMLInputElement = selectAll;
const checkboxes = Array.from(form.querySelectorAll<HTMLInputElement>("input.data-quality-checkbox"));
function updateCount(): void {
const selected = checkboxes.filter((c) => c.checked).length;
if (counter) counter.textContent = `${selected} selected`;
const allChecked = selected === checkboxes.length && checkboxes.length > 0;
const noneChecked = selected === 0;
selectAllInput.checked = allChecked;
selectAllInput.indeterminate = !allChecked && !noneChecked;
}
selectAllInput.addEventListener("change", () => {
for (const cb of checkboxes) cb.checked = selectAllInput.checked;
updateCount();
});
for (const cb of checkboxes) cb.addEventListener("change", updateCount);
updateCount();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initDataQuality);
} else {
initDataQuality();
}
|