Fix Delete button not responding to clicks in gallery
All checks were successful
Build and Push Frontend Docker Image / build (push) Successful in 29s

Same issue as View Progress button - replace inline onclick handler
with proper addEventListener to fix silent failures from async
promise rejections.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-01-07 21:54:18 +00:00
parent a7cb20fb37
commit 95dd159e89

View File

@@ -428,23 +428,25 @@ function renderGallery(container, items) {
<span>${formatDate(item.createdAt)}</span> <span>${formatDate(item.createdAt)}</span>
<div class="gallery-item-actions"> <div class="gallery-item-actions">
${item.status === 'completed' ? `<a href="/api/content/${item.id}/download" class="btn btn-sm btn-secondary">Download</a>` : ''} ${item.status === 'completed' ? `<a href="/api/content/${item.id}/download" class="btn btn-sm btn-secondary">Download</a>` : ''}
<button class="btn btn-sm btn-danger" onclick="deleteContent(${item.id})">Delete</button> <button class="btn btn-sm btn-danger delete-content-btn" data-content-id="${item.id}">Delete</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
`).join(''); `).join('');
}
async function deleteContent(id) { container.querySelectorAll('.delete-content-btn').forEach(btn => {
if (!confirm('Are you sure you want to delete this content?')) return; btn.addEventListener('click', async function() {
const contentId = parseInt(this.dataset.contentId, 10);
try { if (!confirm('Are you sure you want to delete this content?')) return;
await api(`/content/${id}`, { method: 'DELETE' }); try {
loadGallery(currentPage); await api(`/content/${contentId}`, { method: 'DELETE' });
} catch (error) { loadGallery(currentPage);
alert(error.message); } catch (error) {
} alert(error.message);
}
});
});
} }
// Admin // Admin