From d37a7093ddc5d30fcab593c517d1d2c49e4f10bf Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 18 Nov 2026 20:03:56 +0100 Subject: [PATCH] Pflege Anzeigedaten ohne neue Fassung und zeige sie in den echten Karten. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Medieneditor trennt Beschreibung, Inhalt, Fassungen und Verwendung. Der vorhandene Picker filtert nach Zusammenhang und lässt Entwürfe für die gemeinsame Freigabe sichtbar. Co-authored-by: Cursor --- .../Cms/Catalog/PublicMaterialReader.php | 38 ++- .../Compositions/Pages/EditComposition.php | 9 +- .../Pages/ViewContentElement.php | 319 +++++++++++++++--- app/Filament/Support/EditorialCatalog.php | 47 ++- app/Filament/Support/MediaLibrary.php | 21 ++ .../cms/widget-live-preview.blade.php | 6 +- .../views/filament/editorial/editor.blade.php | 18 +- .../views/filament/editorial/styles.blade.php | 3 + .../filament/media/editor-panels.blade.php | 190 +++++++++++ .../filament/media/library-styles.blade.php | 16 + .../filament/media/preview-frame.blade.php | 20 ++ .../views/filament/media/viewer.blade.php | 52 ++- tests/Feature/MediaEditorTest.php | 142 ++++++++ 13 files changed, 827 insertions(+), 54 deletions(-) create mode 100644 resources/views/filament/media/editor-panels.blade.php create mode 100644 resources/views/filament/media/preview-frame.blade.php create mode 100644 tests/Feature/MediaEditorTest.php diff --git a/app/Domain/Cms/Catalog/PublicMaterialReader.php b/app/Domain/Cms/Catalog/PublicMaterialReader.php index 8eca5b6..c5588aa 100644 --- a/app/Domain/Cms/Catalog/PublicMaterialReader.php +++ b/app/Domain/Cms/Catalog/PublicMaterialReader.php @@ -104,8 +104,10 @@ public function labelFor(mixed $id): ?string /** * Anzeigedaten für eine Karte. Öffentlich null, wenn das Element nicht öffentlich genannt wird. + * + * @param array $draft ungespeicherte Anzeigedaten, nur für die Redaktionsvorschau */ - public function subject(mixed $id, bool $includeNonPublic): ?CardSubject + public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?CardSubject { $element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null; @@ -119,11 +121,22 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject return null; } + $shown = clone $element; + + foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) { + if (! array_key_exists($field, $draft)) { + continue; + } + + $value = $draft[$field]; + $shown->setAttribute($field, is_string($value) && trim($value) === '' ? null : $value); + } + $program = $this->publicProgramFor($element); - $output = self::outputLabel((string) $element->output_class); - $film = $element->output_class === 'film'; + $output = self::outputLabel((string) $shown->output_class); + $film = $shown->output_class === 'film'; $editorialKind = $element->editorialContentKind?->label; - $summary = filled($element->summary) ? trim((string) $element->summary) : null; + $summary = filled($shown->summary) ? trim((string) $shown->summary) : null; $meta = [$output]; if ($program !== null) { @@ -137,14 +150,14 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject if ($summary === null) { $missing[] = 'Keine Kurzbeschreibung gepflegt (Medium bearbeiten → Kurzbeschreibung).'; } - if (! filled($element->display_title)) { + if (! filled($shown->display_title)) { $missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.'; } - $previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $element->thumbnail_path) : null; + $previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null; return new CardSubject( - title: (string) ($element->display_title ?: $element->working_title), + title: (string) ($shown->display_title ?: $shown->working_title), summary: $summary, kind: filled($editorialKind) ? (string) $editorialKind : $output, badge: $output, @@ -172,6 +185,17 @@ public static function outputLabel(string $outputClass): string }; } + public function visibilityNote(ContentElement $element): string + { + if ($this->isPublic($element)) { + $program = $this->publicProgramFor($element); + + return 'Öffentlich nur als Teil der Programmseite „'.($program['title'] ?? '').'“. Die Mediendatei wird dabei nicht ausgeliefert.'; + } + + return $this->notice($element, $this->publicProgramFor($element)); + } + /** * @param array{id: int, title: string}|null $program */ diff --git a/app/Filament/Resources/Compositions/Pages/EditComposition.php b/app/Filament/Resources/Compositions/Pages/EditComposition.php index 38b73c1..ca1f5a6 100644 --- a/app/Filament/Resources/Compositions/Pages/EditComposition.php +++ b/app/Filament/Resources/Compositions/Pages/EditComposition.php @@ -20,6 +20,7 @@ use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\StructureNode; +use App\Domain\Cms\Catalog\PublicMaterialReader; use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Support\EditorialCatalog; use App\Filament\Support\MediumForm; @@ -87,6 +88,8 @@ abstract class EditComposition extends EditRecord public string $pickerKind = 'alle'; + public string $pickerLayout = 'kacheln'; + public string $pickerDimension = ''; public string $pickerSelected = ''; @@ -351,6 +354,7 @@ public function pickerDetail(): ?array $row = app(EditorialCatalog::class)->rowForTarget( $this->pickerSelected, (int) $this->getRecord()->getKey(), + allowDraft: true, ); if ($row === null) { @@ -360,10 +364,13 @@ public function pickerDetail(): ?array $row['playback'] = null; if (preg_match('/^element:(\d+)$/', (string) $row['target'], $match) === 1) { - $version = ContentElementVersion::query()->with('element')->find($match[1]); + $version = ContentElementVersion::query()->with('element.editorialContentKind')->find($match[1]); $row['playback'] = $version instanceof ContentElementVersion ? app(ContentPreviewController::class)->playback($version) : null; + if ($version?->element !== null) { + $row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($version->element); + } } return $row; diff --git a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php index 33dcb35..c1246c2 100644 --- a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php +++ b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php @@ -6,20 +6,25 @@ use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentVersionStatus; +use App\Domain\Catalog\EditorialDimensionValue; +use App\Domain\Catalog\IdentityChange; +use App\Domain\Catalog\IdentityDimension; +use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityProfile; -use App\Domain\Catalog\Pillar; use App\Domain\Catalog\PillarService; +use App\Domain\Cms\Catalog\PublicMaterialReader; +use App\Domain\Cms\Widgets\RenderContext; use App\Domain\Media\ThumbnailRef; use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Support\CatalogReading; +use App\Filament\Support\EditorialCatalog; use App\Filament\Support\ElementRevision; +use App\Filament\Support\MediaLibrary; use App\Filament\Support\ReportsDomainRules; use App\Http\Controllers\ContentPreviewController; use App\Jobs\DeriveThumbnail; use Filament\Actions\Action; -use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\Textarea; -use Filament\Forms\Components\TextInput; use Filament\Resources\Pages\ViewRecord; use Filament\Schemas\Components\View; use Filament\Schemas\Schema; @@ -47,6 +52,42 @@ class ViewContentElement extends ViewRecord public mixed $previewUpload = null; + public string $bereich = 'inhalt'; + + public string $workingTitle = ''; + + public string $displayTitle = ''; + + public string $summary = ''; + + public string $descriptionText = ''; + + public string $usageNote = ''; + + public string $licenseNote = ''; + + public int|string|null $kindId = null; + + /** @var list */ + public array $pillarIds = []; + + /** @var list */ + public array $dimensionIds = []; + + public string $editorialFeedback = ''; + + public string $previewWidth = '640'; + + public string $previewSurface = 'website'; + + public string $pickerQuery = ''; + + public string $pickerContext = 'modul'; + + public string $pickerLayout = 'kacheln'; + + public string $pickerSelected = ''; + public function mount(int|string $record): void { parent::mount($record); @@ -57,13 +98,18 @@ public function mount(int|string $record): void $this->fassung = $requested; } + $bereich = (string) request()->query('bereich', 'inhalt'); + $this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'herkunft', 'verwendung', 'auswahl', 'vorschau'], true) + ? $bereich + : 'inhalt'; $this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? ''); + $this->fillEditorial(); $this->syncBodyDraft(); } public function getSubheading(): string|Htmlable|null { - return 'Jede Fassung hat eine eigene Nummer und bleibt einsehbar. Beschreibung, Arbeitstitel und Säulen gehören zum Medium und ändern keine Fassung. Eine deaktivierte Fassung wird nicht mehr ausgeliefert und lässt sich nicht neu einbauen.'; + return 'Beschreibung, Anzeigename, Kurzbeschreibung und Vorschaubild gehören zum Medium und ändern keine Fassung. Eine neue Film- oder Textdatei entsteht nur über eine neue Fassung. Die Website zeigt nur, was dafür freigegeben ist.'; } public function infolist(Schema $schema): Schema @@ -242,40 +288,6 @@ public function deactivateAction(): Action protected function getHeaderActions(): array { return [ - Action::make('describe') - ->label('Beschreibung ändern') - ->visible(fn (): bool => ContentElementResource::editor()) - ->fillForm(fn (): array => [ - 'working_title' => $this->getRecord()->working_title, - 'description' => $this->getRecord()->description, - 'usage_note' => $this->getRecord()->usage_note, - 'license_note' => $this->getRecord()->license_note, - 'pillars' => $this->getRecord()->pillars()->pluck('pillars.id')->all(), - ]) - ->schema([ - TextInput::make('working_title')->label('Arbeitstitel')->required(), - Textarea::make('description')->label('Beschreibung')->rows(4) - ->helperText('Gilt für das Medium. Speichern legt keine neue Fassung an.'), - Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4), - Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3) - ->helperText('Nur in der Verwaltung. Nicht in der Bibliothek und nicht auf der Website.'), - CheckboxList::make('pillars') - ->label('Fachliche Säulen') - ->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all()), - ]) - ->action(function (array $data): void { - $this->report(function () use ($data): void { - /** @var ContentElement $element */ - $element = $this->getRecord(); - app(ContentService::class)->describe($element, (string) $data['working_title'], $data['description'] ?? null); - app(IdentityProfile::class)->fill($element, [ - 'usage_note' => $data['usage_note'] ?? null, - 'license_note' => $data['license_note'] ?? null, - ], auth()->user()); - app(PillarService::class)->assign($element, array_map(intval(...), $data['pillars'] ?? [])); - }, 'Die Beschreibung ist gespeichert.'); - $this->getRecord()->refresh(); - }), Action::make('releaseVersion') ->label('Fassung freigeben') ->modalHeading('Fassung freigeben') @@ -395,6 +407,7 @@ private function pictureCaption(ContentElement $element): string return match ($source) { 'eigen' => 'Eigenes Vorschaubild.', 'datei' => 'Vorschaubild aus der Datei des Mediums.', + 'bestand' => 'Vorschaubild aus einem Bild im Bestand. Es ist damit nicht für die Website freigegeben.', default => '', }; } @@ -406,4 +419,234 @@ private function ownedVersion(int $id): ?ContentElementVersion return $element->versions()->whereKey($id)->first(); } + + public function saveEditorial(): void + { + abort_unless(ContentElementResource::editor(), 403); + + /** @var ContentElement $element */ + $element = $this->getRecord(); + $title = trim($this->workingTitle); + + if ($title === '') { + $this->editorialFeedback = 'Der Arbeitstitel fehlt.'; + + return; + } + + $versions = $element->versions()->count(); + app(IdentityProfile::class)->fill($element, [ + 'working_title' => $title, + 'display_title' => $this->displayTitle, + 'summary' => $this->summary, + 'description' => $this->descriptionText, + 'usage_note' => $this->usageNote, + 'license_note' => $this->licenseNote, + 'thumbnail_alt' => $this->thumbnailAlt, + 'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null, + ], auth()->user()); + app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds)); + $ids = array_map(intval(...), $this->dimensionIds); + IdentityDimensionValue::query() + ->where('subject_type', $element->getMorphClass()) + ->where('subject_id', $element->id) + ->where('origin', 'direkt') + ->whereNotIn('editorial_dimension_value_id', $ids === [] ? [0] : $ids) + ->delete(); + + foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) { + app(IdentityDimension::class)->assign($element, $value, 'direkt'); + } + + $element->refresh(); + $this->fillEditorial(); + $this->editorialFeedback = $element->versions()->count() === $versions + ? 'Gespeichert. Es gibt keine neue Fassung.' + : 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.'; + } + + public function adoptLibraryImage(): void + { + abort_unless(ContentElementResource::editor(), 403); + + /** @var ContentElement $element */ + $element = $this->getRecord(); + $detail = $this->selectionDetail(); + $sourceId = (int) ($detail['element_id'] ?? 0); + $source = $sourceId > 0 ? ContentElement::query()->find($sourceId) : null; + $path = $source?->thumbnail_path; + + if (! $source instanceof ContentElement || $source->output_class !== 'bild' || ! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) { + $this->pictureFeedback = 'Dieses Bild hat noch kein übernehmbares Vorschaubild.'; + + return; + } + + $versions = $element->versions()->count(); + app(IdentityProfile::class)->fill($element, [ + 'thumbnail_path' => $path, + 'thumbnail_alt' => filled($source->thumbnail_alt) ? $source->thumbnail_alt : $source->working_title, + 'thumbnail_source' => 'bestand', + 'thumbnail_error' => null, + ], auth()->user()); + $element->refresh(); + $this->thumbnailAlt = (string) ($element->thumbnail_alt ?? ''); + $this->pictureFeedback = $element->versions()->count() === $versions + ? 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.' + : 'Vorschaubild übernommen. Prüfe die Fassungen.'; + } + + /** + * @return array{items: list>, more: bool} + */ + public function selection(): array + { + return app(EditorialCatalog::class)->browse( + $this->pickerQuery, + $this->pickerContext === 'bild' ? 'bild' : 'alle', + '', + 0, + elementsOnly: $this->pickerContext !== 'modul', + ); + } + + /** + * @return array|null + */ + public function selectionDetail(): ?array + { + if ($this->pickerSelected === '') { + return null; + } + + $row = app(EditorialCatalog::class)->rowForTarget($this->pickerSelected, 0, allowDraft: true); + + if ($row === null || ! isset($row['element_id'])) { + return $row; + } + + $element = ContentElement::query()->with('editorialContentKind')->find((int) $row['element_id']); + + if ($element instanceof ContentElement) { + $row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($element); + } + + return $row; + } + + public function previewHtml(): string + { + /** @var ContentElement $element */ + $element = $this->getRecord(); + $draft = [ + 'working_title' => $this->workingTitle, + 'display_title' => $this->displayTitle, + 'summary' => $this->summary, + 'thumbnail_alt' => $this->thumbnailAlt, + ]; + + if ($this->previewSurface === 'bibliothek') { + $title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle); + + return view('member.partials.card', [ + 'href' => '#vorschau', + 'card' => [ + 'title' => $title !== '' ? $title : $element->working_title, + 'summary' => trim($this->summary) !== '' ? trim($this->summary) : null, + 'kind' => PublicMaterialReader::outputLabel((string) $element->output_class), + 'coverage' => 'offen', + 'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title, + 'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path), + 'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.', + ], + ])->render(); + } + + $subject = app(PublicMaterialReader::class)->subject($element->id, true, $draft); + + if ($subject === null) { + return '

Für dieses Medium liegt noch keine anzeigbare Fassung vor. Die Karte erscheint deshalb auch in der Vorschau nicht.

'; + } + + return view('widgets.premium_card', [ + 'subject' => $subject, + 'context' => RenderContext::preview(), + 'cardStyle' => $subject->style ?? 'media', + 'imageUrl' => null, + 'alt' => '', + 'focus' => ['x' => 50, 'y' => 45], + 'format' => 'landscape', + 'fit' => 'cover', + 'headingTag' => 'h3', + 'show' => ['summary' => true, 'kind' => true, 'meta' => true, 'action' => true], + 'actionLabel' => 'Ansehen', + 'note' => null, + 'stacked' => $this->previewWidth === '390', + ])->render(); + } + + /** + * @return list + */ + public function editorialHistory(): array + { + /** @var ContentElement $element */ + $element = $this->getRecord(); + $labels = [ + 'working_title' => 'Arbeitstitel', + 'display_title' => 'Anzeigename', + 'description' => 'Beschreibung', + 'summary' => 'Kurzbeschreibung', + 'usage_note' => 'Einsatzhinweis', + 'license_note' => 'Interner Lizenzvermerk', + 'thumbnail_alt' => 'Alternativtext', + 'thumbnail_path' => 'Vorschaubild', + 'thumbnail_source' => 'Herkunft des Vorschaubilds', + 'editorial_content_kind_id' => 'Inhaltsart', + ]; + + return IdentityChange::query() + ->where('subject_type', $element->getMorphClass()) + ->where('subject_id', $element->id) + ->latest('occurred_at') + ->limit(8) + ->get() + ->map(fn (IdentityChange $change): array => [ + 'field' => $labels[$change->field] ?? $change->field, + 'after' => is_scalar($change->after) ? (string) $change->after : '', + 'when' => $change->occurred_at?->timezone(config('app.timezone'))->format('d.m.Y H:i') ?? '', + ]) + ->all(); + } + + /** + * @return array + */ + public function usageCard(): array + { + /** @var ContentElement $element */ + $element = $this->getRecord(); + + return app(MediaLibrary::class)->cardFor($element, ContentElementResource::editor()); + } + + private function fillEditorial(): void + { + /** @var ContentElement $element */ + $element = $this->getRecord(); + $this->workingTitle = (string) $element->working_title; + $this->displayTitle = (string) ($element->display_title ?? ''); + $this->summary = (string) ($element->summary ?? ''); + $this->descriptionText = (string) ($element->description ?? ''); + $this->usageNote = (string) ($element->usage_note ?? ''); + $this->licenseNote = (string) ($element->license_note ?? ''); + $this->kindId = $element->editorial_content_kind_id; + $this->pillarIds = $element->pillars()->pluck('pillars.id')->all(); + $this->dimensionIds = IdentityDimensionValue::query() + ->where('subject_type', $element->getMorphClass()) + ->where('subject_id', $element->id) + ->where('origin', 'direkt') + ->pluck('editorial_dimension_value_id') + ->all(); + } } diff --git a/app/Filament/Support/EditorialCatalog.php b/app/Filament/Support/EditorialCatalog.php index 383ce08..473a860 100644 --- a/app/Filament/Support/EditorialCatalog.php +++ b/app/Filament/Support/EditorialCatalog.php @@ -16,7 +16,9 @@ use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\OfferStatus; +use App\Domain\Cms\Catalog\PublicMaterialReader; use App\Filament\Resources\Combinations\CombinationResource; +use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\Courses\CourseResource; use App\Filament\Resources\Exercises\ExerciseResource; use Illuminate\Database\Eloquent\Builder; @@ -111,7 +113,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all 'identity' => 'medium:'.$element->id, 'open_url' => route('content.preview', $version), 'open_label' => 'Medium ansehen', - 'edit_url' => null, + 'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]), ]; } @@ -262,7 +264,7 @@ public function search(string $query, string $scope, int $exceptCompositionId): /** * @return array{items: list>, more: bool} */ - public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId): array + public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array { $query = trim($query); $like = '%'.str_replace(['%', '_'], ['', ''], $query).'%'; @@ -294,7 +296,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce } } - if (in_array($kind, ['alle', 'modul'], true)) { + if (! $elementsOnly && in_array($kind, ['alle', 'modul'], true)) { $latestCompositions = CompositionVersion::query() ->selectRaw('MAX(id)') ->where('status', ContentVersionStatus::Bereit) @@ -372,6 +374,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce } } + $rows = $this->withVisibility($rows); + return [ 'items' => array_slice($rows, 0, $limit), 'more' => count($rows) > $limit, @@ -400,6 +404,42 @@ public function cardUrl(string $kind, int $id, ?string $path): ?string return route('editorial.card', ['kind' => $kind, 'subject' => $id]); } + /** + * @param list> $rows + * @return list> + */ + private function withVisibility(array $rows): array + { + $ids = []; + + foreach ($rows as $row) { + if (isset($row['element_id'])) { + $ids[] = (int) $row['element_id']; + } + } + + if ($ids === []) { + return $rows; + } + + $reader = app(PublicMaterialReader::class); + $elements = ContentElement::query() + ->with('editorialContentKind') + ->whereIn('id', array_values(array_unique($ids))) + ->get() + ->keyBy('id'); + + foreach ($rows as $index => $row) { + $element = $elements->get((int) ($row['element_id'] ?? 0)); + + if ($element instanceof ContentElement) { + $rows[$index]['visibility'] = $reader->visibilityNote($element); + } + } + + return $rows; + } + /** * @param Builder $builder */ @@ -408,6 +448,7 @@ private function constrainElement($builder, string $query, string $like, string $outputs = match ($kind) { 'film' => ['film'], 'text' => ['text'], + 'bild' => ['bild'], 'dokument' => ['pdf', 'document'], default => null, }; diff --git a/app/Filament/Support/MediaLibrary.php b/app/Filament/Support/MediaLibrary.php index daa32a6..cde4c8c 100644 --- a/app/Filament/Support/MediaLibrary.php +++ b/app/Filament/Support/MediaLibrary.php @@ -66,6 +66,27 @@ public function classifications(): array return $options; } + /** + * @param array $filters + * @return list> + */ + /** + * @return array + */ + public function cardFor(ContentElement $element, bool $canEdit): array + { + $element->loadMissing(['versions', 'pillars']); + $versionIds = $element->versions->pluck('id')->all(); + + return $this->card( + $element, + $this->portrait($element), + $this->placements($versionIds)[$element->id] ?? [], + $this->licenses($versionIds)[$element->id] ?? [], + $canEdit, + ); + } + /** * @param array $filters * @return list> diff --git a/resources/views/filament/cms/widget-live-preview.blade.php b/resources/views/filament/cms/widget-live-preview.blade.php index 548eea7..70c026d 100644 --- a/resources/views/filament/cms/widget-live-preview.blade.php +++ b/resources/views/filament/cms/widget-live-preview.blade.php @@ -4,13 +4,15 @@ verkleinert. So greifen die Container-Abfragen der Widgets wie auf der Website. --}} @php + $bodyClass = $bodyClass ?? ''; + $caption = $caption ?? 'Vorschau bei '.$width.' px Platzbreite, verkleinert. Gleiche Darstellung wie auf der Website.'; $document = '' .$stylesheets .'' - .'
'.$html.'
'; + .'
'.$html.'
'; @endphp
-

Vorschau bei {{ $width }} px Platzbreite, verkleinert. Gleiche Darstellung wie auf der Website.

+

{{ $caption }}

@if (trim($html) === '')

Dieses Widget zeigt mit den aktuellen Angaben öffentlich nichts an.

@else diff --git a/resources/views/filament/editorial/editor.blade.php b/resources/views/filament/editorial/editor.blade.php index 0567680..d9b919f 100644 --- a/resources/views/filament/editorial/editor.blade.php +++ b/resources/views/filament/editorial/editor.blade.php @@ -502,10 +502,15 @@
- @foreach (['alle' => 'Alle', 'film' => 'Filme', 'dokument' => 'Dokumente', 'text' => 'Texte', 'modul' => 'Module'] as $value => $label) + @foreach (['alle' => 'Alle', 'film' => 'Filme', 'bild' => 'Bilder', 'dokument' => 'Dokumente', 'text' => 'Texte', 'modul' => 'Module'] as $value => $label) @endforeach
+
+ + +
+

Entwürfe bleiben sichtbar. So kann ein Modul sie weiterhin gemeinsam mit dem Aufbau freigeben. Eine nicht passende Art filterst du hier, ohne die übrigen Medien zu verstecken.

+ Nur in der Verwaltung. Auf Karten erscheint er, wenn kein Anzeigename gepflegt ist. + + + + + + +
+ Fachliche Säulen +
+ @foreach ($options['pillars'] as $pillar) + + @endforeach +
+
+ @foreach ($options['dimensions'] as $dimension) +
+ {{ $dimension->label }} +
+ @foreach ($dimension->values as $value) + + @endforeach +
+
+ @endforeach + @if ($editable) + + @endif + + @include('filament.media.preview-frame') +
+ @endif + + @if ($fokus === 'herkunft') +
+

Die Rechte am Medium sind von den Lizenzen zu unterscheiden, die später an Käufer vergeben werden. Eine freigegebene Fassung macht das Medium nicht öffentlich.

+ + + @if ($editable) + + @endif +
+

Änderungen an den Angaben

+ @php($history = $this->editorialHistory()) + @if ($history === []) +

Noch keine protokollierte Änderung.

+ @else +
    + @foreach ($history as $change) +
  • {{ $change['when'] }} · {{ $change['field'] }}@if ($change['after'] !== '') · {{ \Illuminate\Support\Str::limit($change['after'], 80) }}@endif
  • + @endforeach +
+ @endif + @endif + + @if ($fokus === 'verwendung') + @php($card = $this->usageCard()) +

Eine Verwendung verweist auf eine konkrete Fassung. Die Rolle steht an der Verwendung, nicht als Kopie des Mediums.

+ @include('filament.media.usages', ['card' => $card]) + @endif + + @if ($fokus === 'auswahl') +

Dieselbe Auswahl wie im Modul und Programm. Der Zusammenhang bestimmt, was sinnvoll ist. Entwürfe bleiben im Modul sichtbar, damit die gemeinsame Freigabe weiter möglich ist.

+
+ @foreach (['modul' => 'Modul oder Programm', 'bild' => 'Vorschaubild', 'website' => 'Website'] as $value => $label) + + @endforeach +
+
+ + +
+ + @if ($this->pickerContext === 'bild') +

Nur Bilder. Filme und Texte sind hier nicht wählbar, weil sie kein Vorschaubild des Bestands sind.

+ @elseif ($this->pickerContext === 'website') +

Für die Website zählen nur freigegebene Präsentationsdaten. Eine Auswahl hier veröffentlicht nichts. Geschützte Dateien bleiben geschützt. Das Widget der Website nutzt dieselben Regeln.

+ @else +

Filme, Texte, Dokumente und Module. Entwürfe sind dabei, eine freigegebene Fassung ist gekennzeichnet.

+ @endif + @php($result = $this->selection()) +
+ @if ($result['items'] === []) +

Nichts gefunden.

+ @else +
    $this->pickerLayout === 'liste'])> + @foreach ($result['items'] as $hit) +
  • + +
  • + @endforeach +
+ @endif + +
+ @endif + + @if ($fokus === 'vorschau') +

Die Vorschau nutzt die Website-Karte und die Karte der Bibliothek. Ein Bibliotheksbild ist in der Vorschau sichtbar und damit nicht öffentlich freigegeben. Die ausführliche Beschreibung erscheint auf diesen Karten nicht.

+ @include('filament.media.preview-frame') + @endif + diff --git a/resources/views/filament/media/library-styles.blade.php b/resources/views/filament/media/library-styles.blade.php index 88a2aeb..c637d15 100644 --- a/resources/views/filament/media/library-styles.blade.php +++ b/resources/views/filament/media/library-styles.blade.php @@ -256,4 +256,20 @@ @media (prefers-reduced-motion: reduce) { .luf-media * { scroll-behavior: auto; } } + .luf-ws-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; } + .luf-ws-tabs button { min-height: 2.75rem; padding: 0.35rem 0.8rem; border: 1px solid var(--luf-line); background: #fff; color: var(--luf-ink); } + .luf-ws-tabs button[aria-pressed="true"] { background: var(--luf-pine); color: #fff; border-color: var(--luf-pine); } + .luf-ws { display: grid; gap: 1rem; max-width: 72rem; } + .luf-ws-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(16rem, 24rem); gap: 1.25rem; align-items: start; } + .luf-ws label { display: grid; gap: 0.25rem; font-weight: 600; } + .luf-ws input[type="text"], .luf-ws input[type="search"], .luf-ws textarea, .luf-ws select { font: inherit; width: 100%; min-height: 2.75rem; border: 1px solid var(--luf-line); background: #fff; padding: 0.4rem 0.6rem; } + .luf-ws textarea { min-height: 6rem; } + .luf-ws .luf-help { font-weight: 400; color: #3d4f45; } + .luf-ws-checks { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; } + .luf-ws-checks label { font-weight: 400; grid-auto-flow: column; align-items: center; } + .luf-live-preview-stage { width: 100%; overflow: hidden; } + .luf-live-preview-frame { border: 0; transform-origin: top left; display: block; background: #fff; } + @media (max-width: 860px) { + .luf-ws-grid { grid-template-columns: 1fr; } + } diff --git a/resources/views/filament/media/preview-frame.blade.php b/resources/views/filament/media/preview-frame.blade.php new file mode 100644 index 0000000..9026dac --- /dev/null +++ b/resources/views/filament/media/preview-frame.blade.php @@ -0,0 +1,20 @@ +
+
+ + +
+
+ + +
+

Die Website-Karte zeigt Anzeigename oder Arbeitstitel und die Kurzbeschreibung. Die Bibliothekskarte zeigt dieselben Angaben. Ob ein Mitglied sie öffnen darf, entscheidet die Lizenz, nicht diese Vorschau.

+ @include('filament.cms.widget-live-preview', [ + 'html' => $this->previewHtml(), + 'stylesheets' => \App\Filament\Support\WidgetEditor::previewStylesheets(), + 'width' => (int) $this->previewWidth, + 'bodyClass' => $this->previewSurface === 'bibliothek' ? 'member' : '', + 'caption' => $this->previewSurface === 'bibliothek' + ? 'Bibliothekskarte bei '.$this->previewWidth.' px. Dieselbe Karte wie im Mitgliederbereich.' + : 'Website-Karte bei '.$this->previewWidth.' px. Dieselbe Karte wie im öffentlichen Auftritt. Das Bibliotheksbild ist nur hier sichtbar.', + ]) +
diff --git a/resources/views/filament/media/viewer.blade.php b/resources/views/filament/media/viewer.blade.php index a6684f0..fc1d5c5 100644 --- a/resources/views/filament/media/viewer.blade.php +++ b/resources/views/filament/media/viewer.blade.php @@ -1,8 +1,30 @@ @php use App\Domain\Catalog\ContentVersionStatus; + $fokus = $this->bereich; @endphp +@include('filament.media.library-styles') +@include('filament.editorial.styles') + + + +@if (in_array($fokus, ['beschreibung', 'herkunft', 'verwendung', 'auswahl', 'vorschau'], true)) + @include('filament.media.editor-panels') +@else
+ @if ($fokus !== 'fassungen')

{{ $element->working_title }}

@if (filled($element->description)) @@ -60,6 +82,7 @@ @endif
@endif + @endif
@if ($shown === null) @@ -127,7 +150,7 @@ @endif
- @if ($usage !== []) + @if ($fokus !== 'fassungen' && $usage !== [])

Verwendung

@foreach ($usage as $line) @@ -136,3 +159,30 @@
@endif
+@endif + + diff --git a/tests/Feature/MediaEditorTest.php b/tests/Feature/MediaEditorTest.php new file mode 100644 index 0000000..32aad13 --- /dev/null +++ b/tests/Feature/MediaEditorTest.php @@ -0,0 +1,142 @@ +createElement('film', 'film', 'Lara im Park'); + $version = $content->publishElementVersion($element, 'Film'); + $editor = $this->editor(); + $this->actingAs($editor, 'staff'); + + Livewire::test(ViewContentElement::class, ['record' => $element->getKey()]) + ->set('bereich', 'beschreibung') + ->set('displayTitle', 'Lara im Park, neu') + ->set('summary', 'Ein kurzer Teaser für die Karte') + ->set('descriptionText', 'Ausführliche Beschreibung nur in der Verwaltung') + ->call('saveEditorial') + ->assertSee('Gespeichert. Es gibt keine neue Fassung.') + ->assertSee('Ein kurzer Teaser für die Karte') + ->assertSee('lf-pc'); + + $element->refresh(); + $this->assertSame(1, $element->versions()->count()); + $this->assertSame($version->id, $element->versions()->first()->id); + $this->assertSame('Lara im Park, neu', $element->display_title); + $this->assertSame('Ein kurzer Teaser für die Karte', $element->summary); + $this->assertTrue( + IdentityChange::query()->where('subject_id', $element->id)->where('field', 'summary')->exists() + ); + + $draft = app(PublicMaterialReader::class)->subject($element->id, true, [ + 'summary' => 'Noch nicht gespeichert', + ]); + $this->assertSame('Noch nicht gespeichert', $draft->summary); + $this->assertSame('Ein kurzer Teaser für die Karte', $element->fresh()->summary); + + Livewire::test(ViewContentElement::class, ['record' => $element->getKey()]) + ->set('bereich', 'vorschau') + ->set('summary', 'Noch nicht gespeichert') + ->set('previewSurface', 'bibliothek') + ->assertSee('media-card') + ->assertSee('Noch nicht gespeichert'); + } + + public function test_the_picker_keeps_drafts_for_modules_and_limits_images_and_website_choices(): void + { + $content = app(ContentService::class); + $film = $content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film'); + $draft = $content->draftElementVersion($content->createElement('text', 'text', 'Offener Entwurf'), 'Text'); + $image = $content->createElement('bild', 'bild', 'Szenenbild'); + $image->thumbnail_path = 'vorschau/szenenbild.jpg'; + $image->save(); + $content->publishElementVersion($image, null, ['file' => 'inhalte/szenenbild.jpg']); + $module = $content->createComposition('Abstand', CompositionKind::Uebung); + $editor = $this->editor(); + $this->actingAs($editor, 'staff'); + + $modulePicker = Livewire::test(EditExercise::class, ['record' => $module->id]) + ->call('openPicker') + ->set('pickerQuery', 'Offener'); + $titles = array_column($modulePicker->instance()->pickerResult()['items'], 'title'); + $this->assertContains('Offener Entwurf', $titles); + $modulePicker->assertSee('Entwürfe bleiben sichtbar'); + + $page = Livewire::test(ViewContentElement::class, ['record' => $film->element->getKey()]) + ->set('bereich', 'auswahl') + ->set('pickerContext', 'bild'); + $imageTitles = array_column($page->instance()->selection()['items'], 'title'); + $this->assertContains('Szenenbild', $imageTitles); + $this->assertNotContains('Lara im Park', $imageTitles); + $page->assertSee('Nur Bilder'); + + $page->set('pickerContext', 'website'); + $websiteTitles = array_column($page->instance()->selection()['items'], 'title'); + $this->assertContains('Offener Entwurf', $websiteTitles); + $this->assertNotContains('Abstand', $websiteTitles); + $page->assertSee('veröffentlicht nichts'); + + $target = null; + foreach ($page->instance()->selection()['items'] as $item) { + if ($item['title'] === 'Szenenbild') { + $target = $item['target']; + } + } + $page->set('pickerContext', 'bild') + ->set('pickerSelected', $target) + ->call('adoptLibraryImage') + ->assertSee('keine neue Fassung'); + + $film->element->refresh(); + $this->assertSame('vorschau/szenenbild.jpg', $film->element->thumbnail_path); + $this->assertSame(1, $film->element->versions()->count()); + $this->assertSame($draft->id, $draft->fresh()->id); + } + + public function test_browsing_images_does_not_return_films(): void + { + $content = app(ContentService::class); + $content->publishElementVersion($content->createElement('film', 'film', 'Nur ein Film'), 'Film'); + $content->publishElementVersion($content->createElement('bild', 'bild', 'Nur ein Bild'), null, ['file' => 'inhalte/bild.jpg']); + + $titles = array_column( + app(EditorialCatalog::class)->browse('', 'bild', '', 0)['items'], + 'title', + ); + + $this->assertSame(['Nur ein Bild'], $titles); + } + + private function editor(): User + { + $editor = User::factory()->redakteur()->create(); + $editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP'); + + return $editor; + } +}