Add Postfach page to manually assign unlinked e-mails

Incoming e-mails that IMAP matching could not link to an application
(bewerbung_id IS NULL) were invisible. Add a dedicated page listing
them with a dropdown of existing applications to assign each one by
hand. A header badge on every page shows the count of unlinked e-mails
via a small /api/emails/unassigned-count endpoint.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-03 19:07:54 +02:00
co-authored by Claude
parent 931bb85c6a
commit 4418c15553
3 changed files with 226 additions and 0 deletions
+20
View File
@@ -9,6 +9,17 @@
</a>
<div class="flex items-center space-x-4">
<!-- Postfach (unlinked incoming e-mails) link -->
<a href="/postfach"
class="relative flex items-center gap-1.5 px-3 py-2 rounded-md bg-white/20 hover:bg-white/30 transition-colors text-white text-sm font-medium"
title="E-Mails im Postfach, die noch keiner Bewerbung zugeordnet sind">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
</svg>
<span class="hidden sm:inline">Postfach</span>
<span id="unassignedBadge" class="hidden absolute -top-1 -right-1 min-w-[18px] h-[18px] px-1 flex items-center justify-center rounded-full bg-red-500 text-white text-[10px] font-bold ring-2 ring-blue-800 dark:ring-gray-900">0</span>
</a>
<!-- Vorlagen (base documents) link -->
<a href="/vorlagen"
class="flex items-center gap-1.5 px-3 py-2 rounded-md bg-white/20 hover:bg-white/30 transition-colors text-white text-sm font-medium"
@@ -49,4 +60,13 @@
</div>
</div>
</div>
<script>
// Populate the Postfach badge with the count of unlinked incoming e-mails.
(function () {
fetch('/api/emails/unassigned-count').then(function (r) { return r.json(); }).then(function (d) {
var b = document.getElementById('unassignedBadge');
if (b && d && d.count > 0) { b.textContent = d.count; b.classList.remove('hidden'); }
}).catch(function () { /* ignore — badge stays hidden */ });
})();
</script>
</header>