mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 15:21:22 +02:00
- 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
77 lines
2.2 KiB
JavaScript
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;
|
|
})();
|