diff --git a/CLAUDE.md b/CLAUDE.md index 44e87f2..1c8d04e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -68,5 +68,5 @@ ## Verwaltungsoberfläche - Formatierte Texte (ADR-50): gespeichert wird bereinigtes HTML aus fester Auswahl, bearbeitet mit dem einen Editor `App\Filament\Support\RichField`, in den Arbeitsplätzen über `ManagesRichFields` (`richFelder()`, `kind => 'rich'`). Ausgabe nur über `App\Domain\Catalog\FormattedText` (`html()`, `display()`, `plain()`, `blocks()` fürs PDF), nie ungeprüft; verglichen wird nur `FormattedText::same()`/`canonical()`. Klartext des Altbestands bleibt in der Datenbank, bis jemand ihn ändert. Keine eigenen Textfelder mit `textarea` für Texte, die formatiert sein sollen. - Filter mit Mehrfachauswahl in Bestandslisten (z. B. Medienmanager): Baustein `verwaltung/bestand-filterdialog` über den Eintrag `filterdialog` in `bestand()` (Filterknopf neben der Suche, Pillen je wirksamem Feld, Dialog mit Entwurf der Auswahl: „Anwenden“ übernimmt, „Abbrechen“ verwirft). Mehrere Werte eines Felds gelten als ODER, verschiedene Felder als UND. Die Häkchen sind per `wire:model` an eine Liste im Entwurf gebunden (nie `wire:click` mit `@checked`: nach einer Serverantwort stimmt sonst die Anzeige nicht). Persönliche Standardfilter je Konto liegen in `user_view_defaults` (`UserViewDefault`). Texte, die für eine Übung angelegt werden, erhalten über `ExerciseSections::mark` die Materialart „Übungsabschnitt“ und den Verweis auf ihre Übung. - Die Redaktion ist ein Arbeitsstand: nur „Redaktion speichern“ schreibt Texte, Einordnung, Präsentationsmedien und Abweichungen. Kein verdecktes Mitspeichern aus anderen Dialogen, offene Eingaben bleiben beim Wechsel erhalten. -- Dokumente (ADR-51): Kapitel sind Texte, die Dokumentfassung ist eine Komposition (`CompositionKind::Document`); bearbeitet wird im Aufbaueditor über den Kapitelarbeitsplatz (`ManagesDocumentChapters`, `verwaltung/dokument`), ausgegeben über `DocumentGuide` (Seite) und `DocumentPdf`. Formatierte Texte mit Tabellen und Bildern laufen nur über `FormattedText`, `RichField` und `EmbeddedImages` (ein Bild ist ein Verweis auf eine Bildfassung, nie eine Adresse); PDF-Satz nur über `PdfFlow`. Änderungen an `PdfDocument` müssen die Prüfsummen in `tests/Unit/PdfDocumentTest.php` einhalten (Belege byte-gleich). +- Dokumente (ADR-51): Kapitel sind Texte, die Dokumentfassung ist eine Komposition (`CompositionKind::Document`); bearbeitet wird im Aufbaueditor über den Kapitelarbeitsplatz (`ManagesDocumentChapters`, `verwaltung/dokument`), ausgegeben über `DocumentGuide` (Seite) und `DocumentPdf`. Formatierte Texte mit Tabellen und Bildern laufen nur über `FormattedText`, `RichField` und `EmbeddedImages` (ein Bild ist ein Verweis auf eine Bildfassung, nie eine Adresse); PDF-Satz nur über `PdfFlow`. Änderungen an `PdfDocument` müssen die Prüfsummen in `tests/Unit/PdfDocumentTest.php` einhalten (Belege byte-gleich). Das Aussehen des Dokument-PDF (Titelseite, Kopf, Fuß) kommt aus der `PdfTemplate` (Seite `PdfVorlagen`); Inhalt wie Ausgabe, Datum und Vermerk gehört in `document_meta` der Dokumentfassung, nicht in die Vorlage. - Jede UI-Änderung in der echten Anwendung prüfen (luf-test, breite und schmale Fenster, Tastatur) und mit Screenshots in `docs/ux/verwaltung/abnahme/` belegen. Stand der Abnahme: `abnahme/teil-a.md`, `abnahme/teil-b.md`, `abnahme/teil-c.md`, `abnahme/stammdaten.md`. diff --git a/app/Domain/Catalog/Composition.php b/app/Domain/Catalog/Composition.php index 4bd54c1..2d7e351 100644 --- a/app/Domain/Catalog/Composition.php +++ b/app/Domain/Catalog/Composition.php @@ -25,6 +25,7 @@ class Composition extends Model 'editorial_content_kind_id', 'archived_at', 'working_draft', + 'pdf_template_id', ]; protected function casts(): array @@ -46,6 +47,12 @@ public function editorialContentKind(): BelongsTo return $this->belongsTo(EditorialContentKind::class); } + /** Die PDF-Vorlage eines Dokuments; leer = bisheriges Layout (ADR-51). */ + public function pdfTemplate(): BelongsTo + { + return $this->belongsTo(PdfTemplate::class); + } + public function versions(): HasMany { return $this->hasMany(CompositionVersion::class); diff --git a/app/Domain/Catalog/CompositionRelease.php b/app/Domain/Catalog/CompositionRelease.php index 2edc9c0..b24fc7e 100644 --- a/app/Domain/Catalog/CompositionRelease.php +++ b/app/Domain/Catalog/CompositionRelease.php @@ -367,6 +367,7 @@ private function materialize( 'duration_max' => $didactic['duration_max'] ?? null, 'material_note' => $didactic['material_note'] ?? null, 'prerequisites' => $didactic['prerequisites'] ?? null, + 'document_meta' => $didactic['document_meta'] ?? null, ], $variants, ); @@ -432,6 +433,7 @@ private function resolveTarget(string $target, ?User $actor, array $stack): Cont 'duration_max' => $draft['duration_max'] ?? null, 'material_note' => $draft['material_note'] ?? null, 'prerequisites' => $draft['prerequisites'] ?? null, + 'document_meta' => $draft['document_meta'] ?? null, ], $actor, is_string($draft['revision_note'] ?? null) ? $draft['revision_note'] : null, diff --git a/app/Domain/Catalog/CompositionVersion.php b/app/Domain/Catalog/CompositionVersion.php index 6675c5c..2dd3deb 100644 --- a/app/Domain/Catalog/CompositionVersion.php +++ b/app/Domain/Catalog/CompositionVersion.php @@ -21,12 +21,14 @@ class CompositionVersion extends Model 'prerequisites', 'structure_hash', 'source_snapshot_id', + 'document_meta', ]; protected function casts(): array { return [ 'status' => ContentVersionStatus::class, + 'document_meta' => 'array', ]; } diff --git a/app/Domain/Catalog/ContentService.php b/app/Domain/Catalog/ContentService.php index 38545c5..e81f3aa 100644 --- a/app/Domain/Catalog/ContentService.php +++ b/app/Domain/Catalog/ContentService.php @@ -335,6 +335,7 @@ public function publishComposition( 'duration_max' => isset($didactic['duration_max']) ? (int) $didactic['duration_max'] : null, 'material_note' => $this->optionalText($didactic['material_note'] ?? null), 'prerequisites' => $this->optionalText($didactic['prerequisites'] ?? null), + 'document_meta' => DocumentMeta::normalize($didactic['document_meta'] ?? null), 'source_snapshot_id' => isset($didactic['source_snapshot_id']) ? (int) $didactic['source_snapshot_id'] : null, ]); @@ -394,6 +395,8 @@ public function structureHash(CompositionVersion $version): string { $version->loadMissing('members.variant', 'variants'); + $meta = DocumentMeta::normalize($version->document_meta); + return hash('sha256', json_encode([ 'fields' => [ $version->learning_goal, @@ -402,6 +405,8 @@ public function structureHash(CompositionVersion $version): string $version->material_note, $version->prerequisites, ], + // Nur wenn gesetzt: Der Nachweis älterer Fassungen ohne Dokumentangaben bleibt unverändert. + ...($meta === null ? [] : ['document' => $meta]), 'variants' => $version->variants->map(fn (CompositionVersionVariant $variant): array => [ $variant->key, $variant->position, $variant->name, $variant->description, $variant->origin, ])->all(), diff --git a/app/Domain/Catalog/DocumentGuide.php b/app/Domain/Catalog/DocumentGuide.php index 9eff4d0..18dbfa5 100644 --- a/app/Domain/Catalog/DocumentGuide.php +++ b/app/Domain/Catalog/DocumentGuide.php @@ -56,6 +56,8 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea 'document' => $document, 'title' => $text['title'], 'summary_html' => $text['summary_html'], + 'pdf_template' => $document->composition->pdfTemplate, + 'meta' => DocumentMeta::normalize($document->document_meta), 'chapters' => $chapters, ]; } diff --git a/app/Domain/Catalog/DocumentMeta.php b/app/Domain/Catalog/DocumentMeta.php new file mode 100644 index 0000000..55a8f0a --- /dev/null +++ b/app/Domain/Catalog/DocumentMeta.php @@ -0,0 +1,51 @@ +|null + */ + public static function normalize(mixed $value): ?array + { + if (! is_array($value)) { + return null; + } + + $clean = []; + + foreach (self::FIELDS as $field) { + $text = trim((string) ($value[$field] ?? '')); + + if ($field === 'published_on') { + $text = preg_match('/^\d{4}-\d{2}-\d{2}$/', $text) === 1 ? $text : ''; + } + + if ($text !== '') { + $clean[$field] = mb_substr($text, 0, $field === 'copyright' ? 600 : 200); + } + } + + return $clean === [] ? null : $clean; + } + + /** Das Veröffentlichungsdatum in deutscher Schreibweise, oder leer. */ + public static function publishedLabel(?array $meta): string + { + $date = $meta['published_on'] ?? ''; + + return $date === '' ? '' : CarbonImmutable::parse($date)->format('d.m.Y'); + } +} diff --git a/app/Domain/Catalog/DocumentPdf.php b/app/Domain/Catalog/DocumentPdf.php index ddb3a5a..4027e3e 100644 --- a/app/Domain/Catalog/DocumentPdf.php +++ b/app/Domain/Catalog/DocumentPdf.php @@ -3,14 +3,21 @@ namespace App\Domain\Catalog; use App\Domain\Commerce\Receipt\PdfDocument; +use App\Domain\Media\PdfImage; use Closure; +use Illuminate\Support\Facades\Storage; use Transliterator; /** - * Druckbare Ausgabe eines Dokuments (DIN A4) aus demselben Ergebnis wie die Ansicht ({@see DocumentGuide}): Titelseite mit - * anklickbarem Inhaltsverzeichnis samt Seitenzahlen, jedes Kapitel der ersten Ebene beginnt auf einer neuen Seite, - * Lesezeichen für die Gliederung des PDF-Betrachters. Fußzeile mit Lizenznehmer, Lizenzkopie und „Seite n von m“ auf jeder - * Seite (K2), die Kennung in den Metadaten (K1). Die Datei wird bei jedem Abruf neu erzeugt und nie abgelegt. + * Druckbare Ausgabe eines Dokuments (DIN A4) aus demselben Ergebnis wie die Ansicht ({@see DocumentGuide}): anklickbares + * Inhaltsverzeichnis samt Seitenzahlen, jedes Kapitel der ersten Ebene beginnt auf einer neuen Seite, Lesezeichen für die + * Gliederung des PDF-Betrachters. Fußzeile mit Lizenznehmer, Lizenzkopie und „Seite n von m“ auf jeder Seite (K2), die Kennung + * in den Metadaten (K1). Die Datei wird bei jedem Abruf neu erzeugt und nie abgelegt. + * + * Vorlage (ADR-51, Nachtrag): Ist dem Dokument eine {@see PdfTemplate} zugeordnet, steht der Titel allein auf einer eigenen + * Titelseite (mit Untertitel, Ausgabe, Veröffentlichungsdatum, Herausgeber und Copyright-Vermerk), und Kopf und Fuß aller + * weiteren Seiten tragen die gewählten Grafiken. Die Angaben kommen aus der Dokumentfassung ({@see DocumentMeta}). Ohne Vorlage + * beginnt das Inhaltsverzeichnis wie bisher unter dem Titel auf der ersten Seite. * * Seitenzahlen stehen erst nach dem Satz fest. Der Satz läuft deshalb so oft, bis Inhaltsverzeichnis, Kapitelanfänge und * Seitenzahl sich nicht mehr ändern (in der Regel zweimal). @@ -21,9 +28,7 @@ class DocumentPdf private const RIGHT = 539.0; - private const TOP = 790.0; - - private const BOTTOM = 72.0; + private const PAGE_HEIGHT = 842.0; private PdfDocument $pdf; @@ -35,20 +40,35 @@ class DocumentPdf private int $total = 0; + private bool $onCover = false; + + /** Obere und untere Grenze des Textes, abhängig von den Grafiken der Vorlage. */ + private float $top = 790.0; + + private float $bottom = 72.0; + + /** Höhe der Fußlinie über dem Seitenrand. */ + private float $footerLine = 54.0; + + /** @var array{header: ?array, footer: ?array, cover: ?array} */ + private array $bands = ['header' => null, 'footer' => null, 'cover' => null]; + /** @var array */ private array $starts = []; /** - * @param array $guide Ergebnis von {@see DocumentGuide::build} + * @param array $guide Ergebnis von {@see DocumentGuide::build}; `pdf_template` und `meta` sind optional */ public function render(array $guide, string $licensee, string $copyId, ?PdfImages $images = null): string { + $template = ($guide['pdf_template'] ?? null) instanceof PdfTemplate ? $guide['pdf_template'] : null; + $this->prepareLayout($template); $starts = []; $total = 0; $bytes = ''; for ($pass = 0; $pass < 5; $pass++) { - $bytes = $this->pass($guide, $licensee, $copyId, $images, $starts, $total); + $bytes = $this->pass($guide, $template, $licensee, $copyId, $images, $starts, $total); if ($this->starts === $starts && $this->total === $total) { break; @@ -61,30 +81,83 @@ public function render(array $guide, string $licensee, string $copyId, ?PdfImage return $bytes; } + /** + * Bereitet die Grafiken der Vorlage auf und legt Ränder fest: Kopf und Fuß in voller Seitenbreite (höchstens 140 Punkt hoch), + * der Text beginnt unter dem Kopf und endet über dem Fuß. + */ + private function prepareLayout(?PdfTemplate $template): void + { + $this->bands = [ + 'header' => $this->band($template?->headerVersion, 140.0), + 'footer' => $this->band($template?->footerVersion, 140.0), + 'cover' => $template !== null && $template->show_cover ? $this->band($template->coverVersion, self::PAGE_HEIGHT * 0.4) : null, + ]; + $header = (float) ($this->bands['header']['height'] ?? 0); + $footer = (float) ($this->bands['footer']['height'] ?? 0); + $this->top = $header > 0 ? min(790.0, self::PAGE_HEIGHT - $header - 26.0) : 790.0; + $this->footerLine = max(54.0, $footer + 24.0); + $this->bottom = $this->footerLine + 18.0; + } + + /** + * Eine Grafik in Seitenbreite, bei zu großer Höhe verkleinert und zentriert. + * + * @return array{jpeg: string, pixelWidth: int, pixelHeight: int, width: float, height: float, x: float}|null + */ + private function band(?ContentElementVersion $version, float $maxHeight): ?array + { + $file = $version === null ? null : EmbeddedImages::file($version); + $image = $file === null ? null : PdfImage::fromBytes((string) Storage::disk('media_derived')->get($file)); + + if ($image === null) { + return null; + } + + $width = (float) PdfDocument::WIDTH; + $height = $width * $image['height'] / max(1, $image['width']); + + if ($height > $maxHeight) { + $height = $maxHeight; + $width = $height * $image['width'] / max(1, $image['height']); + } + + return ['jpeg' => $image['jpeg'], 'pixelWidth' => $image['width'], 'pixelHeight' => $image['height'], 'width' => $width, 'height' => $height, 'x' => (PdfDocument::WIDTH - $width) / 2]; + } + /** * @param array $guide * @param array $known Kapitelanfänge aus dem vorigen Durchgang */ - private function pass(array $guide, string $licensee, string $copyId, ?PdfImages $images, array $known, int $total): string + private function pass(array $guide, ?PdfTemplate $template, string $licensee, string $copyId, ?PdfImages $images, array $known, int $total): string { $this->pdf = new PdfDocument; $this->page = 0; - $this->total = 0; $this->starts = []; + $this->onCover = false; $this->footer = PdfFlow::printable('Lizenziert für '.$licensee.' · Lizenzkopie '.$copyId); - $this->flow = new PdfFlow($this->pdf, self::LEFT, self::RIGHT, self::TOP, self::BOTTOM, function (): void { + $this->flow = new PdfFlow($this->pdf, self::LEFT, self::RIGHT, $this->top, $this->bottom, function (): void { $this->closePage(); $this->newPage(); }, $images === null ? null : Closure::fromCallable($images)); - $knownTotal = $total; - $this->total = $knownTotal; - $this->newPage(); + $this->total = $total; + $withCover = $template !== null && $template->show_cover; + + if ($withCover) { + $this->onCover = true; + $this->newPage(); + $this->cover($guide, $template); + $this->closePage(); + $this->onCover = false; + $this->newPage(); + } else { + $this->newPage(); + $this->flow->write(PdfFlow::printable((string) $guide['title']), 24, true, 10); + } - $this->flow->write(PdfFlow::printable((string) $guide['title']), 24, true, 10); $this->flow->write('Inhaltsverzeichnis', 14, true, 8, keep: 40); foreach ($guide['chapters'] as $chapter) { - $this->contentsLine($chapter, $known[$chapter['anchor']] ?? ['page' => 1, 'top' => self::TOP]); + $this->contentsLine($chapter, $known[$chapter['anchor']] ?? ['page' => 1, 'top' => $this->top]); } foreach ($guide['chapters'] as $chapter) { @@ -101,6 +174,63 @@ private function pass(array $guide, string $licensee, string $copyId, ?PdfImages return $bytes; } + /** + * Titelseite: Bild (falls gewählt), Titel allein, Untertitel, dann Ausgabe, Veröffentlichung und Herausgeber, unten der + * Copyright-Vermerk. Die Vermerke der Fassung gehen dem Standard der Vorlage vor. + * + * @param array $guide + */ + private function cover(array $guide, PdfTemplate $template): void + { + $meta = is_array($guide['meta'] ?? null) ? $guide['meta'] : []; + $y = self::PAGE_HEIGHT - 150.0; + + if ($this->bands['cover'] !== null) { + $cover = $this->bands['cover']; + $this->pdf->image($cover['x'], self::PAGE_HEIGHT - $cover['height'], $cover['width'], $cover['height'], $cover['jpeg'], $cover['pixelWidth'], $cover['pixelHeight']); + $y = self::PAGE_HEIGHT - $cover['height'] - 90.0; + } + + $this->coverText(PdfFlow::printable((string) $guide['title']), 30.0, true, $y, 12.0); + + if (filled($meta['subtitle'] ?? null)) { + $this->coverText(PdfFlow::printable((string) $meta['subtitle']), 15.0, false, $y, 8.0); + } + + $y -= 26.0; + $facts = array_filter([ + filled($meta['edition'] ?? null) ? $meta['edition'] : null, + DocumentMeta::publishedLabel($meta) !== '' ? 'Veröffentlicht am '.DocumentMeta::publishedLabel($meta) : null, + filled($template->publisher) ? 'Herausgeber: '.$template->publisher : null, + ]); + + foreach ($facts as $fact) { + $this->coverText(PdfFlow::printable((string) $fact), 11.0, false, $y, 4.0); + } + + $copyright = trim((string) ($meta['copyright'] ?? '')) !== '' ? (string) $meta['copyright'] : (string) $template->copyright; + + if (trim($copyright) !== '') { + $lines = PdfDocument::wrap(PdfFlow::printable($copyright), self::RIGHT - self::LEFT, 8.5, false); + $at = $this->footerLine + 24.0 + (count($lines) - 1) * 12.0; + + foreach ($lines as $line) { + $this->pdf->text(self::LEFT, $at, $line, 8.5); + $at -= 12.0; + } + } + } + + private function coverText(string $text, float $size, bool $bold, float &$y, float $after): void + { + foreach (PdfDocument::wrap($text, self::RIGHT - self::LEFT, $size, $bold) as $line) { + $this->pdf->text(self::LEFT, $y, $line, $size, $bold); + $y -= $size + 6.0; + } + + $y -= $after; + } + /** * Eine Zeile des Inhaltsverzeichnisses: Nummer und Titel, Punktlinie, Seitenzahl; die ganze Zeile springt zum Kapitel. * @@ -178,13 +308,23 @@ private function newPage(): void $this->pdf->addPage(); $this->page++; $this->flow->restart(); + + if (! $this->onCover && $this->bands['header'] !== null) { + $band = $this->bands['header']; + $this->pdf->image($band['x'], self::PAGE_HEIGHT - $band['height'], $band['width'], $band['height'], $band['jpeg'], $band['pixelWidth'], $band['pixelHeight']); + } } private function closePage(): void { - $this->pdf->line(self::LEFT, 54, self::RIGHT, 54, 0.4); - $this->pdf->text(self::LEFT, 40, $this->footer, 8); - $this->pdf->textRight(self::RIGHT, 40, 'Seite '.$this->page.($this->total > 0 ? ' von '.$this->total : ''), 8); + if (! $this->onCover && $this->bands['footer'] !== null) { + $band = $this->bands['footer']; + $this->pdf->image($band['x'], 0, $band['width'], $band['height'], $band['jpeg'], $band['pixelWidth'], $band['pixelHeight']); + } + + $this->pdf->line(self::LEFT, $this->footerLine, self::RIGHT, $this->footerLine, 0.4); + $this->pdf->text(self::LEFT, $this->footerLine - 14.0, $this->footer, 8); + $this->pdf->textRight(self::RIGHT, $this->footerLine - 14.0, 'Seite '.$this->page.($this->total > 0 ? ' von '.$this->total : ''), 8); } private function asciiTitle(string $title): string diff --git a/app/Domain/Catalog/PdfTemplate.php b/app/Domain/Catalog/PdfTemplate.php new file mode 100644 index 0000000..e677d69 --- /dev/null +++ b/app/Domain/Catalog/PdfTemplate.php @@ -0,0 +1,53 @@ + 'boolean']; + } + + public function headerVersion(): BelongsTo + { + return $this->belongsTo(ContentElementVersion::class, 'header_version_id'); + } + + public function footerVersion(): BelongsTo + { + return $this->belongsTo(ContentElementVersion::class, 'footer_version_id'); + } + + public function coverVersion(): BelongsTo + { + return $this->belongsTo(ContentElementVersion::class, 'cover_version_id'); + } + + public function compositions(): HasMany + { + return $this->hasMany(Composition::class); + } +} diff --git a/app/Filament/Pages/PdfVorlagen.php b/app/Filament/Pages/PdfVorlagen.php new file mode 100644 index 0000000..fe9079a --- /dev/null +++ b/app/Filament/Pages/PdfVorlagen.php @@ -0,0 +1,352 @@ +where('kind', PdfTemplate::KIND_DOCUMENT)->orderBy('name')->first(); + $first instanceof PdfTemplate ? $this->loadTemplate($first) : $this->clearForm(); + } + + public function getHeading(): string|Htmlable|null + { + return null; + } + + public function getMaxContentWidth(): Width|string|null + { + return Width::Full; + } + + /** + * @return list + */ + public function templates(): array + { + return PdfTemplate::query()->where('kind', PdfTemplate::KIND_DOCUMENT)->withCount('compositions')->orderBy('name')->get() + ->map(fn (PdfTemplate $template): array => ['id' => $template->id, 'name' => $template->name, 'documents' => (int) $template->compositions_count])->all(); + } + + public function select(int $id): void + { + $template = PdfTemplate::query()->where('kind', PdfTemplate::KIND_DOCUMENT)->find($id); + + if ($template instanceof PdfTemplate) { + $this->loadTemplate($template); + } + } + + public function newTemplate(): void + { + $this->clearForm(); + } + + /** Ob die Eingaben vom gespeicherten Stand abweichen. */ + public function changed(): bool + { + $template = $this->templateId > 0 ? PdfTemplate::query()->find($this->templateId) : null; + + if (! $template instanceof PdfTemplate) { + return $this->name !== '' || $this->publisher !== '' || $this->copyright !== '' || $this->headerId !== null || $this->footerId !== null || $this->coverId !== null; + } + + return $this->name !== $template->name + || $this->publisher !== (string) $template->publisher + || $this->copyright !== (string) $template->copyright + || $this->showCover !== (bool) $template->show_cover + || $this->headerId !== $template->header_version_id + || $this->footerId !== $template->footer_version_id + || $this->coverId !== $template->cover_version_id; + } + + public function save(): void + { + abort_unless(ContentElementResource::editor(), 403); + + if (trim($this->name) === '') { + Notification::make()->danger()->title('Der Name fehlt.')->body('Er bezeichnet die Vorlage bei der Auswahl am Dokument.')->send(); + + return; + } + + foreach (['header' => $this->headerId, 'footer' => $this->footerId, 'cover' => $this->coverId] as $slot => $id) { + if ($id !== null && $this->imageProblem($id) !== null) { + Notification::make()->danger()->title('Das Bild für '.$this->slotLabel($slot).' lässt sich nicht verwenden.')->body((string) $this->imageProblem($id))->send(); + + return; + } + } + + $values = [ + 'name' => trim($this->name), + 'kind' => PdfTemplate::KIND_DOCUMENT, + 'show_cover' => $this->showCover, + 'header_version_id' => $this->headerId, + 'footer_version_id' => $this->footerId, + 'cover_version_id' => $this->coverId, + 'publisher' => trim($this->publisher) === '' ? null : trim($this->publisher), + 'copyright' => trim($this->copyright) === '' ? null : trim($this->copyright), + ]; + $template = $this->templateId > 0 ? PdfTemplate::query()->find($this->templateId) : null; + $template instanceof PdfTemplate ? $template->update($values) : $template = PdfTemplate::query()->create($values); + $this->loadTemplate($template); + Notification::make()->success()->title('Vorlage gespeichert')->body('Sie gilt sofort für jedes Dokument, das sie verwendet, auch für ältere Fassungen.')->send(); + } + + public function askConfirmation(string $aktion): void + { + if ($aktion === 'delete' && $this->templateId > 0) { + $uses = PdfTemplate::query()->withCount('compositions')->find($this->templateId)?->compositions_count ?? 0; + $this->bestaetigung = [ + 'aktion' => 'delete', + 'argument' => null, + 'titel' => '„'.$this->name.'“ löschen?', + 'text' => $uses > 0 + ? $uses.' '.($uses === 1 ? 'Dokument verwendet' : 'Dokumente verwenden').' diese Vorlage und '.($uses === 1 ? 'erzeugt' : 'erzeugen').' danach wieder das einfache PDF ohne Titelseite. Die Bilder bleiben im Medienbestand.' + : 'Die Vorlage wird entfernt. Die Bilder bleiben im Medienbestand.', + 'label' => 'Vorlage löschen', + 'gefahr' => true, + ]; + } + } + + public function confirmConfirmation(): void + { + $frage = $this->bestaetigung; + $this->bestaetigung = null; + + if (($frage['aktion'] ?? null) === 'delete' && $this->templateId > 0) { + abort_unless(ContentElementResource::editor(), 403); + PdfTemplate::query()->whereKey($this->templateId)->delete(); + $this->mount(); + Notification::make()->success()->title('Vorlage gelöscht')->send(); + } + } + + public function cancelConfirmation(): void + { + $this->bestaetigung = null; + } + + public function openImagePicker(string $slot): void + { + if (! in_array($slot, ['header', 'footer', 'cover'], true)) { + return; + } + + $this->bildFeld = $slot; + $this->resetPicker('vorlagenbild'); + $this->pickerKind = 'bild'; + } + + public function clearImage(string $slot): void + { + match ($slot) { + 'header' => $this->headerId = null, + 'footer' => $this->footerId = null, + 'cover' => $this->coverId = null, + default => null, + }; + } + + public function pickerAllowsMany(): bool + { + return false; + } + + public function closePicker(): void + { + $this->pickerOpen = false; + $this->pickerSelected = ''; + $this->pickerInspected = ''; + $this->pickerMarked = []; + $this->bildFeld = null; + } + + public function confirmPicker(): void + { + $target = array_key_first($this->pickerMarked); + $slot = $this->bildFeld; + + if ($target === null || $slot === null || preg_match('/^element:(\d+)$/', (string) $target, $match) !== 1) { + return; + } + + $problem = $this->imageProblem((int) $match[1]); + + if ($problem !== null) { + Notification::make()->danger()->title('Dieses Bild lässt sich nicht verwenden.')->body($problem)->send(); + + return; + } + + match ($slot) { + 'header' => $this->headerId = (int) $match[1], + 'footer' => $this->footerId = (int) $match[1], + 'cover' => $this->coverId = (int) $match[1], + default => null, + }; + $this->closePicker(); + } + + /** @return array */ + public function pickerKinds(): array + { + return ['bild' => 'Bilder']; + } + + public function pickerTitle(): string + { + return 'Bild für '.$this->slotLabel((string) $this->bildFeld); + } + + public function pickerConfirmLabel(): string + { + return 'Bild übernehmen'; + } + + /** @return array{art: string, titel: string} */ + public function pickerKontext(): array + { + return ['art' => 'die PDF-Vorlage', 'titel' => trim($this->name) !== '' ? $this->name : 'neue Vorlage']; + } + + /** @return array */ + public function presentationRoleOptions(): array + { + return []; + } + + /** @return array|null */ + public function pickerReplacing(): ?array + { + return null; + } + + public function imageUrl(?int $versionId): ?string + { + return $versionId === null ? null : EmbeddedImages::staffSource($versionId); + } + + public function imageTitle(?int $versionId): string + { + $version = $versionId === null ? null : ContentElementVersion::query()->with('element')->find($versionId); + + return $version?->element === null ? '' : (string) ($version->element->display_title ?: $version->element->working_title); + } + + public function slotLabel(string $slot): string + { + return match ($slot) { + 'header' => 'den Kopf der Seiten', + 'footer' => 'den Fuß der Seiten', + 'cover' => 'die Titelseite', + default => 'die Vorlage', + }; + } + + private function imageProblem(int $versionId): ?string + { + $version = ContentElementVersion::query()->with('element')->find($versionId); + + if (! $version instanceof ContentElementVersion || $version->element === null || $version->element->output_class !== 'bild') { + return 'Das ist kein Bild des Medienbestands.'; + } + + if ($version->status !== ContentVersionStatus::Bereit) { + return 'Die Bildfassung ist noch nicht freigegeben.'; + } + + return EmbeddedImages::file($version) === null ? 'Die Bilddatei liegt nicht vor.' : null; + } + + private function loadTemplate(PdfTemplate $template): void + { + $this->templateId = $template->id; + $this->name = $template->name; + $this->publisher = (string) $template->publisher; + $this->copyright = (string) $template->copyright; + $this->showCover = (bool) $template->show_cover; + $this->headerId = $template->header_version_id; + $this->footerId = $template->footer_version_id; + $this->coverId = $template->cover_version_id; + } + + private function clearForm(): void + { + $this->templateId = 0; + $this->name = ''; + $this->publisher = ''; + $this->copyright = ''; + $this->showCover = true; + $this->headerId = null; + $this->footerId = null; + $this->coverId = null; + } + + protected function pickerExceptId(): int + { + return 0; + } +} diff --git a/app/Filament/Resources/Compositions/Pages/EditComposition.php b/app/Filament/Resources/Compositions/Pages/EditComposition.php index 6b6d016..48a050f 100644 --- a/app/Filament/Resources/Compositions/Pages/EditComposition.php +++ b/app/Filament/Resources/Compositions/Pages/EditComposition.php @@ -12,6 +12,7 @@ use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentVersionStatus; +use App\Domain\Catalog\DocumentMeta; use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\EditorialVocabulary; use App\Domain\Catalog\EditorialWorkingDraft; @@ -21,6 +22,7 @@ use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityProfile; +use App\Domain\Catalog\PdfTemplate; use App\Domain\Catalog\StructureNode; use App\Domain\Cms\Catalog\PublicCatalogReader; use App\Domain\Cms\Widgets\RenderContext; @@ -81,6 +83,18 @@ abstract class EditComposition extends EditRecord public string $durationMax = ''; + /** Dokumentfassung (ADR-51): Angaben für Titelseite und Impressum des PDF. Sie gehören zur Fassung. */ + public string $docSubtitle = ''; + + public string $docEdition = ''; + + public string $docPublished = ''; + + public string $docCopyright = ''; + + /** Die PDF-Vorlage des Dokuments („“ = bisheriges Layout). Wirkt sofort, ohne Fassung. */ + public string $pdfTemplateId = ''; + public string $prerequisites = ''; public string $newVariantName = ''; @@ -1856,6 +1870,7 @@ public function publishRevision(): bool 'duration_max' => $this->blank($this->durationMax), 'material_note' => $this->richBlank('materialNote'), 'prerequisites' => $this->blank($this->prerequisites), + 'document_meta' => $this->documentMetaNow(), ], $this->releaseConsent, $this->normalizeVariants($this->variants), @@ -1975,6 +1990,7 @@ protected function loadAufbau(): void $this->thumbnailError = $composition->thumbnail_error; $this->thumbnailSource = $composition->thumbnail_source; $this->imageCaptionText = $this->captionFor($composition->thumbnail_source); + $this->pdfTemplateId = $composition->pdf_template_id === null ? '' : (string) $composition->pdf_template_id; $this->catalogScope = match ($this->hostKind()) { CompositionKind::Kurs => 'module', CompositionKind::Uebung => 'uebungen', @@ -1998,6 +2014,7 @@ protected function loadAufbau(): void $this->learningGoal = ''; $this->durationMinutes = ''; $this->materialNote = ''; + $this->fillDocumentMeta(null); return; } @@ -2040,6 +2057,7 @@ protected function applyDraft(array $draft): void $this->learningGoal = (string) ($draft['learning_goal'] ?? ''); $this->durationMinutes = ($draft['duration_minutes'] ?? null) === null ? '' : (string) $draft['duration_minutes']; $this->materialNote = (string) ($draft['material_note'] ?? ''); + $this->fillDocumentMeta($draft['document_meta'] ?? null); $this->revisionNote = (string) ($draft['revision_note'] ?? ''); $this->selected = null; $this->roleDraft = ''; @@ -2063,6 +2081,7 @@ protected function applyVersion(CompositionVersion $version): void $this->learningGoal = (string) ($version->learning_goal ?? ''); $this->durationMinutes = $version->duration_minutes === null ? '' : (string) $version->duration_minutes; $this->materialNote = (string) ($version->material_note ?? ''); + $this->fillDocumentMeta($version->document_meta); $this->selected = null; $this->roleDraft = ''; $this->noteDraft = ''; @@ -2179,6 +2198,66 @@ protected function sameMembers(CompositionVersion $version): bool return $current === $next; } + /** + * Die Angaben der Dokumentfassung im Arbeitsstand; nur bei einem Dokument, sonst null. + * + * @return array|null + */ + protected function documentMetaNow(): ?array + { + if (! $this->isDocument()) { + return null; + } + + return DocumentMeta::normalize([ + 'subtitle' => $this->docSubtitle, + 'edition' => $this->docEdition, + 'published_on' => $this->docPublished, + 'copyright' => $this->docCopyright, + ]); + } + + protected function fillDocumentMeta(mixed $meta): void + { + $meta = DocumentMeta::normalize($meta) ?? []; + $this->docSubtitle = $meta['subtitle'] ?? ''; + $this->docEdition = $meta['edition'] ?? ''; + $this->docPublished = $meta['published_on'] ?? ''; + $this->docCopyright = $meta['copyright'] ?? ''; + } + + /** + * Die wählbaren PDF-Vorlagen für Dokumente. + * + * @return array + */ + public function pdfTemplateOptions(): array + { + return PdfTemplate::query()->where('kind', PdfTemplate::KIND_DOCUMENT)->orderBy('name')->pluck('name', 'id') + ->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all(); + } + + /** Ordnet dem Dokument eine PDF-Vorlage zu. Das gilt sofort für jedes PDF dieses Dokuments, auch für ältere Fassungen. */ + public function savePdfTemplate(): void + { + $this->guardEditorial(); + $id = ctype_digit($this->pdfTemplateId) ? (int) $this->pdfTemplateId : null; + + if ($id !== null && ! PdfTemplate::query()->where('kind', PdfTemplate::KIND_DOCUMENT)->whereKey($id)->exists()) { + $this->feedback = 'Diese PDF-Vorlage gibt es nicht mehr.'; + + return; + } + + /** @var Composition $composition */ + $composition = $this->getRecord(); + $composition->pdf_template_id = $id; + $composition->save(); + $this->feedback = $id === null + ? 'Das Dokument verwendet wieder das einfache PDF-Layout ohne Titelseite.' + : 'Die PDF-Vorlage ist zugeordnet. Sie gilt sofort für jedes PDF dieses Dokuments, auch für ältere Fassungen; Ausgabe, Datum und Vermerk bleiben je Fassung.'; + } + protected function didacticChanged(CompositionVersion $version): bool { $minutes = $this->minutes($this->durationMinutes); @@ -2198,6 +2277,7 @@ protected function didacticChanged(CompositionVersion $version): bool || $version->prerequisites !== $this->blank($this->prerequisites) || ($version->duration_max === null ? null : (string) $version->duration_max) !== $this->blank($this->durationMax) || $storedVariants !== $this->normalizeVariants($this->variants) + || DocumentMeta::normalize($version->document_meta) !== $this->documentMetaNow() || $storedMinutes !== $minutes; } @@ -2420,6 +2500,7 @@ protected function payload(): array 'prerequisites' => $this->blank($this->prerequisites), 'variants' => $this->normalizeVariants($this->variants), 'revision_note' => $this->blank($this->revisionNote), + 'document_meta' => $this->documentMetaNow(), // Ungespeicherte Texte der Kapitel gelten als Änderung des Entwurfs; nach dem Speichern sind sie leer. 'chapters' => $this->chapterEditsNow(), 'members' => array_values(array_map( @@ -2466,6 +2547,7 @@ protected function readyPayload(): array 'prerequisites' => null, 'variants' => [], 'revision_note' => null, + 'document_meta' => null, 'members' => [], ]; } @@ -2482,6 +2564,7 @@ protected function readyPayload(): array 'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'origin' => $variant->origin, ])->all()), 'revision_note' => null, + 'document_meta' => DocumentMeta::normalize($version->document_meta), 'members' => array_values(array_map( fn (array $row): array => [ 'role' => trim((string) ($row['role'] ?? '')), @@ -2524,6 +2607,7 @@ protected function normalizePayload(array $payload): array 'prerequisites' => $payload['prerequisites'] ?? null, 'variants' => $this->normalizeVariants($payload['variants'] ?? []), 'revision_note' => $payload['revision_note'] ?? null, + 'document_meta' => DocumentMeta::normalize($payload['document_meta'] ?? null), 'chapters' => is_array($payload['chapters'] ?? null) ? $payload['chapters'] : [], 'members' => $members, ]; diff --git a/app/Filament/Support/ChoosesMedia.php b/app/Filament/Support/ChoosesMedia.php index f3f5daf..dde2e34 100644 --- a/app/Filament/Support/ChoosesMedia.php +++ b/app/Filament/Support/ChoosesMedia.php @@ -106,8 +106,8 @@ public function pickerResult(): array return ['items' => [], 'more' => false]; } - if (in_array($this->pickerPurpose, ['aufbau', 'textbild'], true)) { - $image = $this->pickerPurpose === 'textbild'; + if (in_array($this->pickerPurpose, ['aufbau', 'textbild', 'vorlagenbild'], true)) { + $image = in_array($this->pickerPurpose, ['textbild', 'vorlagenbild'], true); return $this->filterByMaterialart(app(EditorialCatalog::class)->browse( $this->pickerQuery, diff --git a/app/Http/Controllers/DocumentPreviewController.php b/app/Http/Controllers/DocumentPreviewController.php index fc8fbdb..a1b07bd 100644 --- a/app/Http/Controllers/DocumentPreviewController.php +++ b/app/Http/Controllers/DocumentPreviewController.php @@ -4,11 +4,15 @@ use App\Domain\Catalog\Composition; use App\Domain\Catalog\CompositionKind; +use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\DocumentGuide; +use App\Domain\Catalog\DocumentMeta; use App\Domain\Catalog\DocumentPdf; use App\Domain\Catalog\DocumentReader; +use App\Domain\Catalog\EditorialWorkingDraft; use App\Domain\Catalog\EmbeddedImages; use App\Domain\Catalog\FormattedText; +use App\Domain\Catalog\PdfTemplate; use App\Domain\Identity\StaffRole; use App\Filament\Support\EditorialCatalog; use App\Models\User; @@ -67,20 +71,66 @@ private function guide(Composition $composition): array ]; } + $draft = app(EditorialWorkingDraft::class)->read($composition); + $ready = $composition->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->first(); + return [ 'title' => app(EditorialCatalog::class)->compositionTitle($composition), 'summary_html' => FormattedText::html($composition->summary), + 'pdf_template' => $composition->pdfTemplate, + 'meta' => DocumentMeta::normalize($draft !== null ? ($draft['document_meta'] ?? null) : $ready?->document_meta), 'chapters' => $chapters, ]; } - private function authorizeStaff(Composition $composition): void + /** + * Muster-PDF einer Vorlage: ein kurzes Handbuch mit Beispielangaben, damit Titelseite, Kopf, Fuß und Seitenzahlen zu sehen + * sind, ohne ein Dokument zu brauchen. + */ + public function template(PdfTemplate $template): Response + { + $this->authorizeUser(); + $table = '

Zeit

Inhalt

10 Min.

Begrüßung

'; + $chapters = []; + + foreach (['Grundlagen' => 1, 'Haltung und Abstand' => 1, 'Vertiefung' => 2] as $title => $level) { + $number = count($chapters) + 1; + $chapters[] = [ + 'number' => (string) ($level === 1 ? count(array_filter($chapters, fn (array $c): bool => $c['level'] === 1)) + 1 : '2.1'), + 'level' => $level, + 'anchor' => 'muster-'.$number, + 'title' => $title, + 'allowed' => true, + 'blocks' => FormattedText::blocks('

'.str_repeat('Mustertext für die Vorschau der Vorlage. ', 30).'

Zwischenüberschrift

'.$table), + ]; + } + + $guide = [ + 'title' => 'Musterhandbuch', + 'pdf_template' => $template, + 'meta' => ['subtitle' => 'Beispiel für eine Titelseite', 'edition' => 'Ausgabe 1.0 · Muster', 'published_on' => now()->format('Y-m-d')], + 'chapters' => $chapters, + ]; + + return response(app(DocumentPdf::class)->render($guide, 'Vorschau der Redaktion', 'vorschau'), 200, [ + 'Content-Type' => 'application/pdf', + 'Content-Disposition' => 'inline; filename="muster.pdf"', + 'Cache-Control' => 'private, no-store', + ]); + } + + private function authorizeUser(): void { $user = auth('staff')->user(); abort_unless( $user instanceof User && ($user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)), 403, ); + } + + private function authorizeStaff(Composition $composition): void + { + $this->authorizeUser(); abort_unless($composition->kind === CompositionKind::Document, 404); } } diff --git a/database/migrations/2026_11_29_100000_add_pdf_templates.php b/database/migrations/2026_11_29_100000_add_pdf_templates.php new file mode 100644 index 0000000..3646fec --- /dev/null +++ b/database/migrations/2026_11_29_100000_add_pdf_templates.php @@ -0,0 +1,55 @@ +id(); + $table->string('name'); + $table->string('kind')->default('dokument'); + $table->boolean('show_cover')->default(true); + $table->foreignId('header_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete(); + $table->foreignId('footer_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete(); + $table->foreignId('cover_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete(); + $table->string('publisher')->nullable(); + $table->text('copyright')->nullable(); + $table->timestamps(); + }); + + Schema::table('compositions', function (Blueprint $table) { + $table->foreignId('pdf_template_id')->nullable()->constrained('pdf_templates')->nullOnDelete(); + }); + + Schema::table('composition_versions', function (Blueprint $table) { + $table->json('document_meta')->nullable(); + }); + } + + public function down(): void + { + Schema::table('composition_versions', function (Blueprint $table) { + $table->dropColumn('document_meta'); + }); + Schema::table('compositions', function (Blueprint $table) { + $table->dropConstrainedForeignId('pdf_template_id'); + }); + Schema::dropIfExists('pdf_templates'); + } +}; diff --git a/docs/architektur/12_Entscheidungsprotokoll_ADR.md b/docs/architektur/12_Entscheidungsprotokoll_ADR.md index c6afb9e..fa8183e 100644 --- a/docs/architektur/12_Entscheidungsprotokoll_ADR.md +++ b/docs/architektur/12_Entscheidungsprotokoll_ADR.md @@ -750,3 +750,5 @@ ## ADR-51 – Dokumente: Kapitel als Texte, Dokumentfassung als Komposition, Tab **Folgen.** Eine Migration, additiv. **Rückfall:** Der vorherige Stand kennt die Art `document` nicht und blendet Dokumente über den Bereichsfilter aus (`SupportedKindScope`); Kapiteltexte bleiben als Texte erhalten. Die Rückfallsperre (ADR-49) muss auf `main` sein, bevor in Prod das erste Dokument entsteht. Nach einem Rückfall zeigt der vorherige Stand Tabellen und Bilder in Texten nicht mehr (sie fallen in der Bereinigung weg) und ein Modul, das eine Dokumentfassung bindet, zeigt das Dokument nicht. Einen Stand, der ein Dokument bindet, ändert der Rückfall nicht in der Datenbank. Offen: Abnahme auf luf-test (Browser, schmale Fenster, Tastatur), Schrift und Layout des Handbuch-PDF nach Marke (nur Helvetica), Silbentrennung im PDF (lange Wörter in schmalen Tabellenspalten werden hart getrennt). **Quelle.** Auftrag „Dokumente“ von Lars vom 24.11.2026. + +**Nachtrag (24.11.2026): PDF-Vorlagen für Dokumente.** Ein Dokument kann eine PDF-Vorlage verwenden (`pdf_templates`, Zuordnung `compositions.pdf_template_id`, Verwaltung unter Inhalte → PDF-Vorlagen). Die Vorlage ist reines Layout und legt fest: eine Titelseite, auf der der Titel allein steht (mit Untertitel, Ausgabe, Veröffentlichungsdatum, Herausgeber, Copyright-Vermerk und optional einem Titelbild), und eine Kopf- und eine Fußgrafik in voller Seitenbreite auf allen weiteren Seiten. Die Bilder wählt der gemeinsame Picker aus dem Medienbestand (freigegebene Bildfassungen). Untertitel, Ausgabe, Datum und Copyright-Vermerk sind Inhalt und gehören zur Dokumentfassung (`composition_versions.document_meta`, `DocumentMeta`); der Vermerk der Vorlage gilt nur, wenn die Fassung keinen hat. Eine Vorlage wirkt sofort auf jedes PDF der Dokumente, die sie verwenden, auch auf ältere Fassungen: Layout ist nicht Teil der Bindung. Die Angaben ändern den Änderungsnachweis (`structure_hash`) nur, wenn sie gesetzt sind; ältere Fassungen behalten ihren Nachweis. Ohne Vorlage bleibt das bisherige Layout unverändert. Die Kennzeichnung (Lizenzzeile und „Seite n von m“) steht auch auf der Titelseite. Das Muster-PDF einer Vorlage gibt es ohne Dokument. **Grenzen:** nur Helvetica (bewusst, siehe Lizenzfrage von Schriften im Druck), Grafiken als JPEG oder PNG ohne Transparenz, feste Anordnung der Titelseite. **Folgen:** eine additive Migration; der Rückfall zeigt Dokumente im vorherigen Stand nicht (SupportedKindScope) und kennt die Vorlagen nicht. Eine PDF-Bibliothek mit eigenen Schriften bleibt Option B, sobald eine Marke etabliert ist. Die gleiche Vorlagenverwaltung kann später für Übungs-PDFs und Belege genutzt werden; die Rechnung bleibt an OPEN-06 gebunden. diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen.md b/docs/ux/verwaltung/abnahme/pdf-vorlagen.md new file mode 100644 index 0000000..9ce29fa --- /dev/null +++ b/docs/ux/verwaltung/abnahme/pdf-vorlagen.md @@ -0,0 +1,32 @@ +# Abnahme PDF-Vorlagen für Dokumente (Stand 24.11.2026) + +Entscheidung: ADR-51, Nachtrag. Dieser Stand belegt die **lokale** Abnahme in der laufenden Anwendung (Arbeitsbaum `feature/pdf-vorlagen`, +lokaler Server, SQLite, Demo-Konten aus `ShopDemoSeeder`) und die automatisierten Prüfungen. Auf `luf-test` ist nichts geprüft. Die +Grafiken der Abnahme (Kopf, Fuß, Titelbild) sind Platzhalter, keine Gestaltung der Marke. + +## Geprüft in der Anwendung + +| Schritt | Ergebnis | Beleg | +|---|---|---| +| Inhalte → PDF-Vorlagen (leer) | Hinweis, wie man die erste Vorlage anlegt | `pdf-vorlagen/01-vorlagen-leer.png` | +| Vorlage „Handbuch“ anlegen: Herausgeber, Standard-Vermerk, Kopf-, Fuß- und Titelbild über den gemeinsamen Picker | Bilder erscheinen als Vorschau; „Vorlage speichern“ erst nach Änderung aktiv | `02-bildauswahl.png`, `03-vorlage-ausgefuellt.png`, `04-vorlage-gespeichert.png` | +| Schmales Fenster (390 px) | Kein waagerechtes Scrollen | `06-schmales-fenster.png` | +| Dokument → „PDF und Katalogbild“: Untertitel, Ausgabe, Veröffentlichungsdatum, Vorlage wählen und übernehmen | Hinweis, dass die Vorlage sofort für jedes PDF gilt, die Angaben aber je Fassung | `05-dokument-pdf-angaben.png` | +| Entwurf speichern, Dokumentfassung 2 bereitstellen, im Modul auf Fassung 2 umstellen, Modulfassung freigeben, Stand veröffentlichen | Fassung 2 trägt die Angaben | im Lauf geprüft | +| Mitglied lädt das PDF (6 Seiten, 4 Lesezeichen) | Seite 1: Titelbild, Titel allein, Untertitel, Ausgabe, Veröffentlichungsdatum, Herausgeber, Vermerk unten, Lizenzzeile; Seite 2: Inhaltsverzeichnis; ab Seite 2 Kopf- und Fußgrafik | `07-pdf-titelseite.png`, `08-pdf-inhaltsverzeichnis.png`, `09-pdf-kapitelseite.png` | +| Muster-PDF der Vorlage | PDF ohne Dokument | im Lauf geprüft (HTTP 200, PDF) | + +## Automatisierte Prüfungen (`DokumentVorlageTest`, `DokumentAusgabeTest`, `PdfDocumentTest`) + +Titelseite mit allen Angaben und ohne Kapitel; Verzeichnis ab Seite 2 mit stimmenden Seitenzahlen; Titelbild nur auf Seite 1, Kopf und Fuß auf allen +weiteren; Lizenzzeile auch auf der Titelseite; ohne Vorlage das bisherige Layout; Titelseite abschaltbar; Standard-Vermerk der Vorlage; +Angaben je Fassung und Änderungsnachweis; Editor speichert Angaben im Entwurf und bindet sie mit der Fassung; Vorlagenseite (anlegen, ändern, Bilder +über den Picker, nicht freigegebenes Bild abgelehnt, löschen); Löschen gibt Dokumente an das einfache Layout zurück; Redaktionsvorschau nutzt Vorlage und Entwurfsangaben. + +## Abweichungen und offene Punkte + +- **Nicht auf luf-test geprüft.** Verkauf und Berechtigung der Abnahme wurden lokal per Skript angelegt. +- **Nur Helvetica.** Eine Markenschrift braucht eine PDF-Bibliothek (Option B im ADR); die Schriftlizenz für gedruckte Werke bleibt zu klären. +- **Grafiken** als JPEG oder PNG ohne Transparenz (Transparenz wird auf Weiß gesetzt). Kopf und Fuß höchstens 140 Punkt hoch, das Titelbild höchstens 40 % der Seite. +- **Übungs-PDF und Beleg** nutzen noch keine Vorlage. Die Verwaltung ist so angelegt, dass weitere Arten folgen können (Spalte `kind`). +- **Im Bild der Dokumentseite** bleibt das Feld „Herausgeber“ der Vorlagenseite gegenüber dem Vermerkfeld leicht tiefer ausgerichtet (Darstellung der gemeinsamen Raster). diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/01-vorlagen-leer.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/01-vorlagen-leer.png new file mode 100644 index 0000000..74c908c Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/01-vorlagen-leer.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/02-bildauswahl.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/02-bildauswahl.png new file mode 100644 index 0000000..a74b58d Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/02-bildauswahl.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/03-vorlage-ausgefuellt.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/03-vorlage-ausgefuellt.png new file mode 100644 index 0000000..354380f Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/03-vorlage-ausgefuellt.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/04-vorlage-gespeichert.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/04-vorlage-gespeichert.png new file mode 100644 index 0000000..8ffcdc2 Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/04-vorlage-gespeichert.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/05-dokument-pdf-angaben.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/05-dokument-pdf-angaben.png new file mode 100644 index 0000000..f9718d9 Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/05-dokument-pdf-angaben.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/06-schmales-fenster.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/06-schmales-fenster.png new file mode 100644 index 0000000..b705dc9 Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/06-schmales-fenster.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/07-pdf-titelseite.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/07-pdf-titelseite.png new file mode 100644 index 0000000..ed5e61c Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/07-pdf-titelseite.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/08-pdf-inhaltsverzeichnis.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/08-pdf-inhaltsverzeichnis.png new file mode 100644 index 0000000..ea62715 Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/08-pdf-inhaltsverzeichnis.png differ diff --git a/docs/ux/verwaltung/abnahme/pdf-vorlagen/09-pdf-kapitelseite.png b/docs/ux/verwaltung/abnahme/pdf-vorlagen/09-pdf-kapitelseite.png new file mode 100644 index 0000000..e0a86af Binary files /dev/null and b/docs/ux/verwaltung/abnahme/pdf-vorlagen/09-pdf-kapitelseite.png differ diff --git a/resources/views/filament/editorial/editor.blade.php b/resources/views/filament/editorial/editor.blade.php index f1de4a4..6df4f13 100644 --- a/resources/views/filament/editorial/editor.blade.php +++ b/resources/views/filament/editorial/editor.blade.php @@ -65,7 +65,7 @@
- @foreach (['aufbau' => $dokument ? 'Kapitel' : 'Aufbau', 'angaben' => $dokument ? 'Katalogbild' : 'Didaktik und Katalogbild', 'verlauf' => 'Fassungen und Verwendung'] as $wert => $label) + @foreach (['aufbau' => $dokument ? 'Kapitel' : 'Aufbau', 'angaben' => $dokument ? 'PDF und Katalogbild' : 'Didaktik und Katalogbild', 'verlauf' => 'Fassungen und Verwendung'] as $wert => $label) +
+ @if ($liste === []) +
Noch keine Vorlage

Lege rechts die erste Vorlage an. Ein Dokument verwendet sie, wenn du sie im Dokument unter „PDF und Katalogbild“ zuordnest.

+ @else +
    + @foreach ($liste as $zeile) +
  • + +
  • + @endforeach +
+ @endif + + +
+
+ + +
+ + +
+ + @foreach ($felder as $slot => [$label, $hilfe, $id]) +
+

{{ $label }}

+

{{ $hilfe }}

+ @if ($id !== null) +
{{ $this->imageTitle($id) }}
+

{{ $this->imageTitle($id) }}

+ @else +

Kein Bild gewählt.

+ @endif +
+ + @if ($id !== null) + + @endif +
+
+ @endforeach +
+
+ + + @if ($this->pickerOpen) + @include('filament.verwaltung.picker') + @endif + +@include('filament.verwaltung.bestaetigung') + diff --git a/resources/views/filament/verwaltung/aufbau-angaben.blade.php b/resources/views/filament/verwaltung/aufbau-angaben.blade.php index cecc69c..e36e997 100644 --- a/resources/views/filament/verwaltung/aufbau-angaben.blade.php +++ b/resources/views/filament/verwaltung/aufbau-angaben.blade.php @@ -7,12 +7,43 @@
@if ($this->isDocument()) -

Dokument

-

Ein Dokument hat keine Didaktikangaben. Die Kapitel schreibst du im Register „Kapitel“. Name, Beschreibung und Einordnung des Dokuments bearbeitest du in der Redaktion. +

Titelseite und Impressum des PDF

+

Diese Angaben gehören zur Dokumentfassung. Sie werden mit „Entwurf speichern“ gesichert und erst mit „Dokumentfassung bereitstellen“ Teil einer neuen Fassung. Eine leere Angabe entfällt auf der Titelseite. Titel, Beschreibung und Einordnung des Dokuments bearbeitest du in der Redaktion.

-