Files
xamxam/app/public/assets/js/app/admin-cleanup-bulk.js
T
Pontoporeia 3e93150c76 justfile: standardise test recipes to lint-php/lint-css/lint-js/test + add fix recipe
- Removed ambiguous aliases: phpstan, cs-check, syntax
- Split lint-biome into lint-css and lint-js with correct paths
- Added lint meta-recipe and fix recipe (biome --unsafe + php-cs-fixer)
- Fixed FormBootstrap dead null check, CSS shorthand override bug
- Updated phpstan baseline, suppressed noDescendingSpecificity/noInnerDeclarations
- Applied ~74 biome auto-fixes across CSS/JS
2026-07-05 11:07:41 +02:00

77 lines
2.2 KiB
JavaScript

/**
* admin-cleanup-bulk.js — Bulk selection and deletion for the temp files cleanup dialog.
*
* Provides: cleanupToggleAll, cleanupUpdateBulk, cleanupBulkDelete.
* All functions are attached to `window` for onclick handlers in PHP templates.
*/
(() => {
function cleanupToggleAll(src, group) {
const selector =
group === "filepond"
? 'input[name="filepond_dirs[]"]'
: 'input[name="trash_files[]"]';
document.querySelectorAll(selector).forEach((cb) => {
cb.checked = src.checked;
});
cleanupUpdateBulk();
}
function cleanupUpdateBulk() {
const bar = document.getElementById("cleanup-bulk-actions");
const countEl = document.getElementById("cleanup-selected-count");
if (!bar || !countEl) return;
const n = document.querySelectorAll(
'input[name="filepond_dirs[]"]:checked, input[name="trash_files[]"]:checked',
).length;
countEl.textContent = n;
bar.style.display = n > 0 ? "flex" : "none";
}
function cleanupBulkDelete() {
const form = document.getElementById("cleanup-bulk-form");
const container = document.getElementById("cleanup-bulk-checkboxes");
if (!form || !container) return;
// Populate hidden inputs from checked checkboxes
container.innerHTML = "";
document
.querySelectorAll(
'input[name="filepond_dirs[]"]:checked, input[name="trash_files[]"]:checked',
)
.forEach((cb) => {
const inp = document.createElement("input");
inp.type = "hidden";
inp.name = cb.name; // "filepond_dirs[]" or "trash_files[]"
inp.value = cb.value;
container.appendChild(inp);
});
// Submit via HTMX
htmx.trigger(form, "submit");
}
function reattachListeners() {
document
.querySelectorAll(
'input[name="filepond_dirs[]"], input[name="trash_files[]"]',
)
.forEach((cb) => {
cb.addEventListener("change", cleanupUpdateBulk);
});
cleanupUpdateBulk();
}
document.addEventListener("htmx:afterSwap", (evt) => {
// Only reattach if the swap target is our cleanup wrapper
if (evt.detail.target.id === "tmp-cleanup-stats-wrapper") {
reattachListeners();
}
});
// Export to global scope for onclick handlers in HTML
window.cleanupToggleAll = cleanupToggleAll;
window.cleanupUpdateBulk = cleanupUpdateBulk;
window.cleanupBulkDelete = cleanupBulkDelete;
})();