Einstellungen: Vorauswahl für KI-Generierung (Dokumente + Anlagen)

Zwei neue, pro Benutzer gespeicherte Konfigurationswerte:
GEN_DOKUMENTE_DEFAULT (Standard: Anschreiben + Lebenslauf) und
GEN_ANLAGEN_DEFAULT (Standard: keine). Sie belegen die Häkchen auf der
Bewerbungsseite vor; eine bereits getroffene Dokumentenauswahl der
Bewerbung gewinnt weiterhin. Die REST-API nutzt die Vorauswahl, wenn
dokumente/anlagen im Body fehlen.

Die Einstellungsseite kennt dafür jetzt Checkbox-Gruppen, deren Optionen
auch erst zur Renderzeit feststehen dürfen (die eigenen Anlagen).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 22:31:19 +02:00
co-authored by Claude Opus 4.8
parent d20a265ebc
commit 1dd4807ca6
7 changed files with 145 additions and 29 deletions
+10 -6
View File
@@ -12,7 +12,7 @@ const path = require('path');
const fs = require('fs');
const blacklist = require('./blacklist');
const { LABEL_OPTIONS, parseLabels, serializeLabels } = require('./labels');
const { normalizeDokumente } = require('./documents');
const { normalizeDokumente, standardDokumente } = require('./documents');
const { userContext, currentUserId } = require('./context');
const config = require('./config');
@@ -452,14 +452,18 @@ function createExternalApi(deps) {
[id, uid()]
);
// Optional: IDs of static attachments (basis_anhaenge) to enclose; none
// by default. Also reflected in the cover letter's "Anlagen" list.
// Optional: IDs of static attachments (basis_anhaenge) to enclose. Omitted
// means the user's preselection from the settings (GEN_ANLAGEN_DEFAULT,
// default: none); an empty array means explicitly none. Also reflected in
// the cover letter's "Anlagen" list.
const anlagenIds = Array.isArray((req.body || {}).anlagen)
? req.body.anlagen.map((v) => parseInt(v, 10)).filter((n) => !Number.isNaN(n))
: [];
: config.anlagenDefaultIds();
// Optional: which documents to produce (["anschreiben"], ["lebenslauf"] or
// both). Omitted / empty means both.
const dokumente = normalizeDokumente((req.body || {}).dokumente);
// both). Omitted / empty falls back to the user's preselection from the
// settings (GEN_DOKUMENTE_DEFAULT, default: both).
const gewuenscht = (req.body || {}).dokumente;
const dokumente = gewuenscht == null ? standardDokumente() : normalizeDokumente(gewuenscht);
await dbRun('UPDATE bewerbungen SET generierung_dokumente = ? WHERE id = ? AND user_id = ?', [dokumente.join(','), id, uid()]);
runGeneration(id, { anlagenIds, dokumente });
res.status(202).json({ success: true, dokumente });