fix: Review-Modal pro answer_type korrekt anzeigen
- word: 'Positiv-Wörter' / 'Negativ-Wörter' (statt irreführendem Satz-Feld) - yes_no: Ja/Nein-Antwort als Einzelwert statt leerem Satz - text/question: Sätze wie bisher Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -16,39 +16,45 @@ function strip(text) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Baut die Anzeigezeilen (Frage / Positiv / Negativ) aus dem content-Bündel.
|
// Baut die Anzeigezeilen je nach answer_type. Jede Zeile ist entweder
|
||||||
|
// - { kind: 'lang', label, color, cell(l) } → eine Zelle pro Sprache (übersetzbar)
|
||||||
|
// - { kind: 'single', label, color, value } → ein einzelner Wert (nicht sprachabhängig)
|
||||||
function buildRows(content) {
|
function buildRows(content) {
|
||||||
if (!content) return [];
|
if (!content) return [];
|
||||||
|
const type = content?.answer_type;
|
||||||
const rows = [];
|
const rows = [];
|
||||||
const isWord = content.answer_type === 'word';
|
const wordsCell = (stmt) => (l) =>
|
||||||
|
(stmt?.words || []).map(w => w[`titel_${l}`] || '—').join(', ');
|
||||||
|
const sentenceCell = (stmt, prefix) => (l) =>
|
||||||
|
strip(stmt?.sentence?.[`${prefix}_${l}`] || '');
|
||||||
|
|
||||||
|
// Frage (yes_no / question / word)
|
||||||
if (content.question) {
|
if (content.question) {
|
||||||
rows.push({
|
rows.push({ kind: 'lang', label: 'Frage', color: 'text-slate-700',
|
||||||
label: 'Frage', color: 'text-slate-700',
|
cell: l => strip(content.question[`sentence_${l}`] || '') });
|
||||||
cell: l => strip(content.question[`sentence_${l}`] || ''),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (content.positive) {
|
|
||||||
rows.push({
|
if (type === 'yes_no') {
|
||||||
label: 'Positiv', color: 'text-green-700',
|
// Ja/Nein-Antwort ist ein boolescher Wert, keine Übersetzung
|
||||||
cell: l => isWord
|
const a = content.positive?.answer;
|
||||||
? content.positive.words.map(w => w[`titel_${l}`] || '—').join(', ')
|
rows.push({ kind: 'single', label: 'Antwort', color: 'text-green-700',
|
||||||
: strip(content.positive.sentence[`positive_sentence_${l}`] || ''),
|
value: a === true ? '✓ Ja' : a === false ? '✗ Nein' : null });
|
||||||
});
|
} else if (type === 'word') {
|
||||||
}
|
rows.push({ kind: 'lang', label: 'Positiv-Wörter', color: 'text-green-700',
|
||||||
// Negativ nur zeigen, wenn überhaupt Inhalt vorhanden ist
|
cell: wordsCell(content.positive) });
|
||||||
const negHasContent = content.negative && (
|
if (content.negative?.words?.length)
|
||||||
content.answer_type === 'word'
|
rows.push({ kind: 'lang', label: 'Negativ-Wörter', color: 'text-red-600',
|
||||||
? content.negative.words.length > 0
|
cell: wordsCell(content.negative) });
|
||||||
: LANGS.some(l => (content.negative.sentence[`negative_sentence_${l}`] || '').trim())
|
} else {
|
||||||
);
|
// text / question → Sätze
|
||||||
if (negHasContent) {
|
if (content.positive)
|
||||||
rows.push({
|
rows.push({ kind: 'lang', label: 'Positiv', color: 'text-green-700',
|
||||||
label: 'Negativ', color: 'text-red-600',
|
cell: sentenceCell(content.positive, 'positive_sentence') });
|
||||||
cell: l => isWord
|
const negHasContent = content.negative &&
|
||||||
? content.negative.words.map(w => w[`titel_${l}`] || '—').join(', ')
|
LANGS.some(l => (content.negative.sentence?.[`negative_sentence_${l}`] || '').trim());
|
||||||
: strip(content.negative.sentence[`negative_sentence_${l}`] || ''),
|
if (negHasContent)
|
||||||
});
|
rows.push({ kind: 'lang', label: 'Negativ', color: 'text-red-600',
|
||||||
|
cell: sentenceCell(content.negative, 'negative_sentence') });
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
@@ -98,7 +104,7 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) {
|
|||||||
|
|
||||||
{/* Body — Übersetzungen zum Gegenprüfen */}
|
{/* Body — Übersetzungen zum Gegenprüfen */}
|
||||||
<div className="px-6 py-5 overflow-y-auto">
|
<div className="px-6 py-5 overflow-y-auto">
|
||||||
<div className="grid gap-3" style={{ gridTemplateColumns: '5rem repeat(3, 1fr)' }}>
|
<div className="grid gap-3 items-center" style={{ gridTemplateColumns: '7rem repeat(3, 1fr)' }}>
|
||||||
<div />
|
<div />
|
||||||
{LANGS.map(l => (
|
{LANGS.map(l => (
|
||||||
<div key={l.code} className="text-center text-sm font-medium text-slate-500">{l.flag} {l.code.toUpperCase()}</div>
|
<div key={l.code} className="text-center text-sm font-medium text-slate-500">{l.flag} {l.code.toUpperCase()}</div>
|
||||||
@@ -108,7 +114,7 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{rows.length === 0 && (
|
{rows.length === 0 && (
|
||||||
<p className="text-sm text-slate-400 text-center py-6">Kein übersetzbarer Inhalt gefunden.</p>
|
<p className="text-sm text-slate-400 text-center py-6">Kein Inhalt gefunden.</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -141,9 +147,19 @@ export default function PairReviewModal({ pair, content, onClose, onDone }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Row({ row }) {
|
function Row({ row }) {
|
||||||
|
if (row.kind === 'single') {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="text-xs font-semibold text-slate-400">{row.label}</div>
|
||||||
|
<div className={`col-span-3 text-sm rounded-lg border px-2.5 py-1.5 ${row.value ? `bg-slate-50 border-slate-200 ${row.color}` : 'bg-red-50 border-red-200 text-red-400 italic'}`}>
|
||||||
|
{row.value || 'fehlt'}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="text-xs font-semibold text-slate-400 self-center">{row.label}</div>
|
<div className="text-xs font-semibold text-slate-400">{row.label}</div>
|
||||||
{LANGS.map(l => {
|
{LANGS.map(l => {
|
||||||
const val = row.cell(l.code);
|
const val = row.cell(l.code);
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user