Enhance bulk delete functionality by adding user confirmation before submission and removing debug information from the response when no items are deleted.

This commit is contained in:
Ross
2025-10-20 12:41:33 +01:00
parent 264270ce00
commit 452143f1ef
3 changed files with 14 additions and 16 deletions
+13
View File
@@ -81,6 +81,19 @@
const uniq = Array.from(new Set(selected.map(String)));
console.log('Bulk delete selected ids:', uniq);
document.getElementById('bulk-selected-input').value = uniq.join(',');
// Confirm with the user before submitting
const count = uniq.length;
if(count === 0){
// nothing selected: prevent submit and show alert
e.preventDefault();
alert('No items selected for deletion.');
return;
}
const ok = confirm(`Delete ${count} selected question${count === 1 ? '' : 's'}? This cannot be undone.`);
if(!ok){
e.preventDefault();
return;
}
// allow HTMX to submit
});
</script>