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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user