chore: bump version to 0.8.96 and enhance legal document features
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / playwright-tests (push) Successful in 59s

- Updated app version to 0.8.96 with a new build date of 2026-05-12.
- Improved legal documents functionality with a live preview feature alongside the editor.
- Added modal for full document preview and updated CSS styles for better layout.
- Enhanced the AdminLegalDocumentsPage to support rendering previews of legal documents.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 4.6 committed 2026-05-12 11:22:01 +02:00
1 parent 81b9e8f601
commit 98edb282ed
4 files changed
+302 -18

No files matched your search

+106 -16
View File
@@ -1,7 +1,9 @@
import { useState, useEffect, useCallback } from 'react'
import { FileText, Plus, Edit2, Archive, CheckCircle, Clock, Copy, Download, ChevronUp, ChevronDown } from 'lucide-react'
import { FileText, Plus, Edit2, Archive, CheckCircle, Clock, Copy, Download, ChevronUp, ChevronDown, Eye } from 'lucide-react'
import api from '../utils/api'
import { generateLegalPdf } from '../utils/legalPdfExport'
import { generateLegalPdf, legalSectionNumber } from '../utils/legalPdfExport'
import LegalDocumentBody from '../components/LegalDocumentBody'
import { LegalPreviewModal } from '../components/LegalDocumentPreview'
const PDF_STATUS_META = { published: 'Gültig seit', draft: 'Entwurf — Stand', archived: 'Archiviert — Stand' }
@@ -109,18 +111,35 @@ function SectionEditor({ sections, onChange }) {
placeholder="Abschnittsüberschrift"
/>
</div>
<div className="form-row">
<label className="form-label">
Inhalt
<span className="form-sub">
Einfache Markdown-Formatierung: **fett**, *kursiv*, Listen (- oder 1.), [Link](https://…), Zeilenumbruch mit Leerzeile.
<div className="legal-section-split">
<div className="legal-section-split__editor">
<label className="form-label">
Inhalt
<span className="form-sub">
Einfache Markdown-Formatierung: **fett**, *kursiv*, Listen (- oder 1.), [Link](https://…), Zeilenumbruch mit Leerzeile.
</span>
</label>
<textarea
className="form-input" rows={6} value={sec.content}
onChange={e => update(i, 'content', e.target.value)}
placeholder="Textinhalt des Abschnitts"
/>
</div>
<div className="legal-section-split__preview">
<span className="form-label" style={{ fontSize: '0.8rem', display: 'block', marginBottom: '6px' }}>
Live-Vorschau
</span>
</label>
<textarea
className="form-input" rows={4} value={sec.content}
onChange={e => update(i, 'content', e.target.value)}
placeholder="Textinhalt des Abschnitts"
/>
<div className="legal-section-preview-box" style={{ marginBottom: 0 }}>
<h4>
{sec.heading?.trim()
? `${legalSectionNumber(i)} ${sec.heading}`
: legalSectionNumber(i)}
</h4>
{sec.content
? <LegalDocumentBody content={sec.content} />
: <span style={{ color: 'var(--text3)', fontSize: '0.85rem' }}>(noch kein Text)</span>}
</div>
</div>
</div>
</div>
<InsertButton afterIndex={i} />
@@ -135,7 +154,7 @@ function SectionEditor({ sections, onChange }) {
)
}
function DocumentRow({ doc, onPublish, onArchive, onEdit, onCopy, onDownload, onViewAudit }) {
function DocumentRow({ doc, onPublish, onArchive, onEdit, onCopy, onDownload, onViewAudit, onRenderedPreview }) {
const [downloading, setDownloading] = useState(false)
const handleDownload = async () => {
@@ -183,6 +202,10 @@ function DocumentRow({ doc, onPublish, onArchive, onEdit, onCopy, onDownload, on
<Archive size={13} />
</button>
)}
<button className="btn btn-secondary" style={{ padding: '4px 10px', fontSize: '0.78rem' }}
onClick={() => onRenderedPreview(doc)} title="Gerenderte Vorschau">
<Eye size={13} />
</button>
<button className="btn btn-secondary" style={{ padding: '4px 10px', fontSize: '0.78rem' }}
onClick={() => onCopy(doc)} title="Als neuen Entwurf kopieren">
<Copy size={13} />
@@ -200,7 +223,7 @@ function DocumentRow({ doc, onPublish, onArchive, onEdit, onCopy, onDownload, on
)
}
function EditForm({ docType, editDoc, onSaved, onCancel }) {
function EditForm({ docType, editDoc, onSaved, onCancel, onShowRenderedPreview }) {
const [title, setTitle] = useState(editDoc ? editDoc.title : docType.defaultTitle)
const [sections, setSections] = useState([])
const [changeNote, setChangeNote] = useState('')
@@ -266,10 +289,23 @@ function EditForm({ docType, editDoc, onSaved, onCancel }) {
onChange={e => setChangeNote(e.target.value)}
placeholder="z. B. Erste Version nach juristischer Prüfung" />
</div>
<div style={{ display: 'flex', gap: '0.75rem', marginTop: '0.5rem' }}>
<div style={{ display: 'flex', gap: '0.75rem', marginTop: '0.5rem', flexWrap: 'wrap' }}>
<button className="btn btn-primary" onClick={handleSave} disabled={saving || !title.trim()}>
{saving ? 'Speichern…' : 'Entwurf speichern'}
</button>
<button
type="button"
className="btn btn-secondary"
onClick={() =>
onShowRenderedPreview?.({
title,
sections,
metaLine: 'Aktueller Editorstand (nicht automatisch gespeichert)',
})}
style={{ display: 'flex', alignItems: 'center', gap: '0.35rem' }}
>
<Eye size={15} /> Vollständige Vorschau
</button>
<button className="btn btn-secondary" onClick={onCancel}>Abbrechen</button>
</div>
</div>
@@ -329,6 +365,13 @@ export default function AdminLegalDocumentsPage() {
const [editDoc, setEditDoc] = useState(null)
const [auditDocId, setAuditDocId] = useState(null)
const [confirmPublish, setConfirmPublish] = useState(null)
const [legalPreview, setLegalPreview] = useState({
open: false,
loading: false,
title: '',
sections: [],
metaLine: '',
})
const activeDocType = DOC_TYPES.find(d => d.key === activeType)
@@ -376,6 +419,42 @@ export default function AdminLegalDocumentsPage() {
catch (e) { alert('Fehler: ' + e.message) }
}
const closeLegalPreview = () =>
setLegalPreview({ open: false, loading: false, title: '', sections: [], metaLine: '' })
const openLegalPreviewFromEditor = (payload) => {
setLegalPreview({
open: true,
loading: false,
title: payload.title,
sections: payload.sections,
metaLine: payload.metaLine || '',
})
}
const openLegalPreviewFromList = async (doc) => {
setLegalPreview({
open: true,
loading: true,
title: '',
sections: [],
metaLine: 'Laden…',
})
try {
const full = await api.getLegalDocument(doc.id)
setLegalPreview({
open: true,
loading: false,
title: full.title,
sections: full.content_sections || [],
metaLine: `Version ${full.version} · ${STATUS_LABELS[full.status]?.label || full.status}`,
})
} catch (e) {
closeLegalPreview()
alert('Fehler: ' + e.message)
}
}
const handleDownload = async (doc) => {
const full = await api.getLegalDocument(doc.id)
const dateStr = full.published_at
@@ -473,6 +552,7 @@ export default function AdminLegalDocumentsPage() {
onCopy={handleCopy}
onDownload={handleDownload}
onViewAudit={handleViewAudit}
onRenderedPreview={openLegalPreviewFromList}
/>
))
)}
@@ -483,9 +563,19 @@ export default function AdminLegalDocumentsPage() {
editDoc={editDoc}
onSaved={handleSaved}
onCancel={() => { setShowForm(false); setEditDoc(null) }}
onShowRenderedPreview={openLegalPreviewFromEditor}
/>
)}
<LegalPreviewModal
open={legalPreview.open}
onClose={closeLegalPreview}
title={legalPreview.title}
sections={legalPreview.sections}
metaLine={legalPreview.metaLine}
loading={legalPreview.loading}
/>
{auditDocId && (
<AuditLog docId={auditDocId} onClose={() => setAuditDocId(null)} />
)}