Add delete button to category list view

This commit is contained in:
James 2026-02-25 14:09:05 -05:00
parent d962c9839d
commit 193d88afef
1 changed files with 18 additions and 0 deletions

View File

@ -82,6 +82,11 @@
</svg>
</a>
{{end}}
<button onclick="deleteDoc('{{.ID}}', this)" class="p-2 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors" title="Delete">
<svg class="w-4 h-4 text-gray-400 hover:text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
</svg>
</button>
</div>
</td>
</tr>
@ -100,4 +105,17 @@
</div>
{{end}}
</div>
<script>
async function deleteDoc(id, btn) {
if (!confirm('Delete this document?')) return;
const row = btn.closest('tr');
const res = await fetch('/api/document/' + id, { method: 'DELETE' });
if (res.ok) {
row.remove();
} else {
alert('Delete failed');
}
}
</script>
{{end}}