feat(modals): implement duplicate delete confirmation modal and enhance deletion workflow

This commit is contained in:
Will Miao
2025-05-08 16:17:52 +08:00
parent 23fa2995c8
commit 92fdc16fe6
5 changed files with 51 additions and 5 deletions

View File

@@ -335,13 +335,28 @@ export class DuplicatesManager {
}
try {
// Show confirmation dialog
if (!confirm(`Are you sure you want to delete ${this.selectedForDeletion.size} selected recipes?`)) {
return;
// Show the delete confirmation modal instead of a simple confirm
const duplicateDeleteCount = document.getElementById('duplicateDeleteCount');
if (duplicateDeleteCount) {
duplicateDeleteCount.textContent = this.selectedForDeletion.size;
}
// Use the modal manager to show the confirmation modal
modalManager.showModal('duplicateDeleteModal');
} catch (error) {
console.error('Error preparing delete:', error);
showToast('Error: ' + error.message, 'error');
}
}
// Add new method to execute deletion after confirmation
async confirmDeleteDuplicates() {
try {
document.body.classList.add('loading');
// Close the modal
modalManager.closeModal('duplicateDeleteModal');
// Prepare recipe IDs for deletion
const recipeIds = Array.from(this.selectedForDeletion);