diff --git a/app/Domain/Catalog/CompositionMember.php b/app/Domain/Catalog/CompositionMember.php index c12f9ae..2555b61 100644 --- a/app/Domain/Catalog/CompositionMember.php +++ b/app/Domain/Catalog/CompositionMember.php @@ -11,6 +11,7 @@ class CompositionMember extends Model 'composition_version_id', 'position', 'role', + 'placement_note', 'content_element_version_id', 'nested_composition_version_id', ]; diff --git a/app/Domain/Catalog/ContentElement.php b/app/Domain/Catalog/ContentElement.php index f27bd04..f78a422 100644 --- a/app/Domain/Catalog/ContentElement.php +++ b/app/Domain/Catalog/ContentElement.php @@ -15,6 +15,8 @@ class ContentElement extends Model 'working_title', 'display_title', 'description', + 'usage_note', + 'license_note', 'summary', 'thumbnail_path', 'thumbnail_alt', diff --git a/app/Domain/Catalog/ContentService.php b/app/Domain/Catalog/ContentService.php index bfcf367..1957bf1 100644 --- a/app/Domain/Catalog/ContentService.php +++ b/app/Domain/Catalog/ContentService.php @@ -115,6 +115,7 @@ public function publishComposition( $version->members()->create([ 'position' => $index + 1, 'role' => $this->required($member['role'], 'Die Rolle eines Mitglieds fehlt.'), + 'placement_note' => $this->optionalText($member['note'] ?? null), 'content_element_version_id' => $target instanceof ContentElementVersion ? $target->id : null, 'nested_composition_version_id' => $target instanceof CompositionVersion ? $target->id : null, ]); @@ -215,6 +216,7 @@ private function membersHash(array $members): string $list[] = [ 'position' => $index + 1, 'role' => $member['role'], + 'note' => $this->optionalText($member['note'] ?? null), 'element_version_id' => $target instanceof ContentElementVersion ? $target->id : null, 'composition_version_id' => $target instanceof CompositionVersion ? $target->id : null, ]; diff --git a/app/Domain/Media/ThumbnailDeriver.php b/app/Domain/Media/ThumbnailDeriver.php index dcd6ff6..603f32a 100644 --- a/app/Domain/Media/ThumbnailDeriver.php +++ b/app/Domain/Media/ThumbnailDeriver.php @@ -83,24 +83,36 @@ public function forCompositionFrame(Composition $composition, ContentElementVers $this->rememberChoice($composition, 'frame:'.$version->id.'@'.$this->secondText($seconds)); } - public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string + public function frameInput(ContentElementVersion $version): ?string { - $file = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null; + $proxy = MediaRendition::query() + ->where('content_element_version_id', $version->id) + ->where('role', 'variant') + ->where('label', '480') + ->value('path'); - if (! is_string($file) || $file === '' || str_contains($file, '..') || ! str_starts_with($file, 'inhalte/')) { - return null; + if (is_string($proxy) && $this->readableDerived($proxy, 'ableitungen/')) { + return $proxy; } + $file = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null; + + return $this->readableDerived($file, 'inhalte/') ? $file : null; + } + + public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string + { if ($seconds < 0 || $seconds > 7200) { return null; } - $disk = Storage::disk('media_derived'); + $file = $this->frameInput($version); - if (! $disk->exists($file)) { + if ($file === null) { return null; } + $disk = Storage::disk('media_derived'); $binary = (new ExecutableFinder)->find('ffmpeg'); if ($binary === null) { @@ -112,19 +124,21 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ? '-hide_banner', '-loglevel', 'error', - '-i', - $disk->path($file), '-ss', $this->secondText($seconds), + '-i', + $disk->path($file), '-frames:v', '1', + '-vf', + 'scale=640:-2', '-f', 'image2pipe', '-vcodec', 'mjpeg', 'pipe:1', ]); - $process->setTimeout(30); + $process->setTimeout(15); $process->run(); $bytes = $process->getOutput(); @@ -135,6 +149,15 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ? return $bytes; } + private function readableDerived(mixed $path, string $prefix): bool + { + if (! is_string($path) || $path === '' || str_contains($path, '..') || ! str_starts_with($path, $prefix)) { + return false; + } + + return Storage::disk('media_derived')->exists($path); + } + private function secondText(float $seconds): string { $seconds = max(0, min(7200, $seconds)); diff --git a/app/Filament/Resources/Compositions/Pages/EditComposition.php b/app/Filament/Resources/Compositions/Pages/EditComposition.php index 47132f6..912c897 100644 --- a/app/Filament/Resources/Compositions/Pages/EditComposition.php +++ b/app/Filament/Resources/Compositions/Pages/EditComposition.php @@ -65,6 +65,15 @@ abstract class EditComposition extends EditRecord public string $roleDraft = ''; + public string $noteDraft = ''; + + public string $imageCaptionText = ''; + + public ?string $thumbnailSource = null; + + /** @var list */ + public array $frameFilmChoices = []; + public string $panel = 'angaben'; public bool $pickerOpen = false; @@ -685,6 +694,7 @@ public function addPart(string $target): void } $row['role'] = app(EditorialCatalog::class)->defaultRole((string) $row['kind']); + $row['note'] = ''; $this->members[] = $row; $this->members = array_values($this->members); $this->selected = array_key_last($this->members); @@ -711,6 +721,7 @@ public function removePart(int $index): void $this->members = array_values($this->members); $this->selected = null; $this->roleDraft = ''; + $this->noteDraft = ''; $this->panel = 'angaben'; $this->partOpen = false; $this->partSnapshot = []; @@ -750,6 +761,7 @@ public function useVersion(int $index, string $target): void $this->commitRoleDraft(); $row['role'] = $this->members[$index]['role'] ?? $row['kind']; + $row['note'] = $this->members[$index]['note'] ?? ''; $this->members[$index] = $row; $this->syncRoleDraft(); $this->feedback = $row['version_label'].' ist für diese Stelle ausgewählt. Der Entwurf speichert das. Eine freigegebene Fassung bleibt unverändert.'; @@ -845,7 +857,8 @@ public function openModule(): void $this->partOpen = false; $this->textOpen = false; $this->moduleTab = 'beschreibung'; - $films = $this->frameFilms(); + $this->frameFilmChoices = $this->frameFilms(); + $films = $this->frameFilmChoices; $this->imageMode = $films === [] ? 'bestand' : 'film'; if ($films !== [] && $this->frameVersionId === null) { @@ -982,20 +995,31 @@ public function framePreviewUrl(): ?string public function imageCaption(): ?string { - /** @var Composition $composition */ - $composition = $this->getRecord(); - $composition->refresh(); - $source = $composition->thumbnail_source; + return $this->imageCaptionText !== '' ? $this->imageCaptionText : null; + } + protected function captionFor(mixed $source): string + { if (! is_string($source) || $source === '') { - return null; + return ''; } if (preg_match('/^frame:(\d+)@([\d.]+)$/', $source, $match) === 1) { - $version = ContentElementVersion::query()->with('element')->find($match[1]); - $title = $version?->element?->working_title ?: 'dem Film'; + $title = null; - return 'Titelbild aus '.$title.' bei '.$match[2].' Sekunden.'; + foreach ($this->members as $member) { + if (($member['target'] ?? '') === 'element:'.$match[1]) { + $title = $member['title'] ?? null; + break; + } + } + + if ($title === null) { + $version = ContentElementVersion::query()->with('element')->find($match[1]); + $title = $version?->element?->working_title; + } + + return 'Titelbild aus '.($title ?: 'dem Film').' bei '.$match[2].' Sekunden.'; } if ($source === 'eigen') { @@ -1006,7 +1030,13 @@ public function imageCaption(): ?string return 'Titelbild aus einem vorhandenen Bild.'; } - return null; + return ''; + } + + protected function rememberCaption(Composition $record): void + { + $this->thumbnailSource = $record->thumbnail_source; + $this->imageCaptionText = $this->captionFor($record->thumbnail_source); } public function savePreview(): void @@ -1064,6 +1094,7 @@ public function adoptPicture(int $elementId): void $record->refresh(); $this->thumbnailPath = $record->thumbnail_path; $this->thumbnailError = $record->thumbnail_error; + $this->rememberCaption($record); $this->feedback = $this->previewFeedback($record, $before); } @@ -1172,7 +1203,11 @@ public function publishRevision(): bool return false; } - $payload[] = ['role' => $role, 'target' => $model]; + $payload[] = [ + 'role' => $role, + 'target' => $model, + 'note' => trim((string) ($member['note'] ?? '')), + ]; } /** @var Composition $record */ @@ -1258,6 +1293,8 @@ protected function loadEditor(): void $this->thumbnailPath = $composition->thumbnail_path; $this->thumbnailAlt = (string) ($composition->thumbnail_alt ?? ''); $this->thumbnailError = $composition->thumbnail_error; + $this->thumbnailSource = $composition->thumbnail_source; + $this->imageCaptionText = $this->captionFor($composition->thumbnail_source); $this->dimensionIds = IdentityDimensionValue::query() ->where('subject_type', $composition->getMorphClass()) ->where('subject_id', $composition->id) @@ -1313,6 +1350,7 @@ protected function applyDraft(array $draft): void } $row['role'] = (string) ($member['role'] ?? $row['kind']); + $row['note'] = trim((string) ($member['note'] ?? '')); $rows[] = $row; } @@ -1323,6 +1361,7 @@ protected function applyDraft(array $draft): void $this->revisionNote = (string) ($draft['revision_note'] ?? ''); $this->selected = null; $this->roleDraft = ''; + $this->noteDraft = ''; $this->panel = 'angaben'; if ($requested > count($rows) && $this->feedback === '') { @@ -1338,6 +1377,7 @@ protected function applyVersion(CompositionVersion $version): void $this->materialNote = (string) ($version->material_note ?? ''); $this->selected = null; $this->roleDraft = ''; + $this->noteDraft = ''; $this->panel = 'angaben'; } @@ -1353,13 +1393,14 @@ protected function commitRoleDraft(?string $value = null): void } $this->members[$this->selected]['role'] = trim($value ?? $this->roleDraft); + $this->members[$this->selected]['note'] = trim($this->noteDraft); } protected function syncRoleDraft(): void { - $this->roleDraft = $this->selected !== null && isset($this->members[$this->selected]) - ? (string) ($this->members[$this->selected]['role'] ?? '') - : ''; + $member = $this->selected !== null ? ($this->members[$this->selected] ?? null) : null; + $this->roleDraft = is_array($member) ? (string) ($member['role'] ?? '') : ''; + $this->noteDraft = is_array($member) ? (string) ($member['note'] ?? '') : ''; } public function releaseDisplay(): void @@ -1421,10 +1462,10 @@ protected function sameMembers(CompositionVersion $version): bool ? 'element:'.$member->content_element_version_id : 'composition:'.$member->nested_composition_version_id; - return $member->role.'|'.$target; + return $member->role.'|'.$target.'|'.trim((string) ($member->placement_note ?? '')); })->all(); $next = array_values(array_map( - fn (array $member): string => trim((string) ($member['role'] ?? '')).'|'.($member['target'] ?? ''), + fn (array $member): string => trim((string) ($member['role'] ?? '')).'|'.($member['target'] ?? '').'|'.trim((string) ($member['note'] ?? '')), $this->members, )); @@ -1587,6 +1628,7 @@ protected function applyChosenImage(): string|false $record->refresh(); $this->thumbnailPath = $record->thumbnail_path; $this->thumbnailError = $record->thumbnail_error; + $this->rememberCaption($record); $note = $this->previewFeedback($record, $before); if (! str_contains($note, 'unverändert')) { @@ -1616,6 +1658,7 @@ protected function storePreview(string $path): void $record->refresh(); $this->thumbnailPath = $record->thumbnail_path; $this->thumbnailError = $record->thumbnail_error; + $this->rememberCaption($record); $this->feedback = $this->previewFeedback($record, $before); } @@ -1663,6 +1706,7 @@ protected function payload(): array fn (array $member): array => [ 'role' => trim((string) ($member['role'] ?? '')), 'target' => (string) ($member['target'] ?? ''), + 'note' => trim((string) ($member['note'] ?? '')), ], $members, )), @@ -1713,6 +1757,7 @@ protected function readyPayload(): array fn (array $row): array => [ 'role' => trim((string) ($row['role'] ?? '')), 'target' => (string) ($row['target'] ?? ''), + 'note' => trim((string) ($row['note'] ?? '')), ], $rows, )), @@ -1735,6 +1780,7 @@ protected function normalizePayload(array $payload): array $members[] = [ 'role' => trim((string) ($member['role'] ?? '')), 'target' => (string) ($member['target'] ?? ''), + 'note' => trim((string) ($member['note'] ?? '')), ]; } diff --git a/app/Filament/Resources/ContentElements/ContentElementResource.php b/app/Filament/Resources/ContentElements/ContentElementResource.php index 7135b3a..5e7de6a 100644 --- a/app/Filament/Resources/ContentElements/ContentElementResource.php +++ b/app/Filament/Resources/ContentElements/ContentElementResource.php @@ -70,6 +70,9 @@ public static function table(Table $table): Table fn (ContentElement $record): string => static::getUrl('view', ['record' => $record]) )->columns([ TextColumn::make('working_title')->label('Arbeitstitel')->searchable(), + TextColumn::make('summary')->label('Kurzbeschreibung')->limit(80), + TextColumn::make('usage_note')->label('Einsatzhinweis')->limit(80), + TextColumn::make('license_note')->label('Lizenzvermerk')->limit(40), TextColumn::make('kind')->label('Art'), TextColumn::make('pillar_names')->label('Säulen')->state( fn (ContentElement $record): string => $record->pillars->pluck('name')->join(', ') ?: '—' diff --git a/app/Filament/Resources/ContentElements/Pages/EditContentElement.php b/app/Filament/Resources/ContentElements/Pages/EditContentElement.php index 1040033..f643434 100644 --- a/app/Filament/Resources/ContentElements/Pages/EditContentElement.php +++ b/app/Filament/Resources/ContentElements/Pages/EditContentElement.php @@ -58,7 +58,11 @@ public function form(Schema $schema): Schema ->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'), Textarea::make('summary')->label('Kurzbeschreibung')->rows(3), Textarea::make('description')->label('Beschreibung')->rows(4) - ->helperText('Gilt für das Medium, nicht für eine einzelne Fassung.'), + ->helperText('Allgemeine Beschreibung des Mediums. Gilt nicht für eine einzelne Fassung und nicht nur für ein Modul.'), + Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4) + ->helperText('Gilt für das Medium in jeder Verwendung. Speichern legt keine Fassung an.'), + Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3) + ->helperText('Nur in der Verwaltung sichtbar. Erscheint nicht in der Bibliothek und nicht auf der Website.'), Select::make('editorial_content_kind_id') ->label('Inhaltsart') ->options(fn (): array => EditorialContentKind::selectOptions()) @@ -170,6 +174,8 @@ protected function mutateFormDataBeforeFill(array $data): array 'working_title' => $this->getRecord()->working_title, 'display_title' => $this->getRecord()->display_title, 'description' => $this->getRecord()->description, + 'usage_note' => $this->getRecord()->usage_note, + 'license_note' => $this->getRecord()->license_note, 'summary' => $this->getRecord()->summary, 'editorial_content_kind_id' => $this->getRecord()->editorial_content_kind_id, 'dimension_ids' => IdentityDimensionValue::query() @@ -193,6 +199,8 @@ protected function handleRecordUpdate(Model $record, array $data): Model app(IdentityProfile::class)->fill($record, [ 'display_title' => $data['display_title'] ?? null, 'summary' => $data['summary'] ?? null, + 'usage_note' => $data['usage_note'] ?? null, + 'license_note' => $data['license_note'] ?? null, ], auth()->user()); if (array_key_exists('editorial_content_kind_id', $data)) { $record->editorial_content_kind_id = filled($data['editorial_content_kind_id'] ?? null) diff --git a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php index 72fff7b..f23e25d 100644 --- a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php +++ b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php @@ -6,6 +6,7 @@ use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentVersionStatus; +use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\Pillar; use App\Domain\Catalog\PillarService; use App\Filament\Resources\ContentElements\ContentElementResource; @@ -91,12 +92,17 @@ protected function getHeaderActions(): array ->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()), @@ -106,6 +112,10 @@ protected function getHeaderActions(): array /** @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(); diff --git a/app/Filament/Support/EditorialCatalog.php b/app/Filament/Support/EditorialCatalog.php index 5f62bae..5428930 100644 --- a/app/Filament/Support/EditorialCatalog.php +++ b/app/Filament/Support/EditorialCatalog.php @@ -47,6 +47,7 @@ public function rows(CompositionVersion $version, int $exceptCompositionId): arr } $row['role'] = $member->role; + $row['note'] = trim((string) ($member->placement_note ?? '')); $rows[] = $row; } @@ -80,6 +81,9 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all 'title' => $title, 'kind' => $kind, 'summary' => (string) ($element->summary ?: $element->description ?: ''), + 'medium_description' => (string) ($element->description ?? ''), + 'usage_note' => (string) ($element->usage_note ?? ''), + 'license_note' => (string) ($element->license_note ?? ''), 'tone' => $this->tone((string) $element->output_class, $kind), 'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path), 'version_label' => 'Fassung '.$version->number, diff --git a/database/migrations/2026_11_16_210000_add_editorial_notes.php b/database/migrations/2026_11_16_210000_add_editorial_notes.php new file mode 100644 index 0000000..0144bf8 --- /dev/null +++ b/database/migrations/2026_11_16_210000_add_editorial_notes.php @@ -0,0 +1,31 @@ +text('usage_note')->nullable()->after('description'); + $table->text('license_note')->nullable()->after('usage_note'); + }); + + Schema::table('composition_members', function (Blueprint $table) { + $table->text('placement_note')->nullable()->after('role'); + }); + } + + public function down(): void + { + Schema::table('content_elements', function (Blueprint $table) { + $table->dropColumn(['usage_note', 'license_note']); + }); + + Schema::table('composition_members', function (Blueprint $table) { + $table->dropColumn('placement_note'); + }); + } +}; diff --git a/resources/views/filament/editorial/editor.blade.php b/resources/views/filament/editorial/editor.blade.php index 5eed695..420735f 100644 --- a/resources/views/filament/editorial/editor.blade.php +++ b/resources/views/filament/editorial/editor.blade.php @@ -78,6 +78,9 @@ {{ $member['kind'] }} {{ $member['title'] }} {{ $member['role'] }} · {{ $member['version_label'] }} + @if (filled($member['note'] ?? null)) + {{ \Illuminate\Support\Str::limit($member['note'], 120) }} + @endif @if ($children = $this->childrenOf((string) $member['target'])) Enthält {{ $children }} @endif @@ -288,31 +291,22 @@ @if ($this->imageMode === 'film') - @php($films = $this->frameFilms()) - @if ($films === []) + @if ($this->frameFilmChoices === [])

In diesem Aufbau ist kein Film. Nimm zuerst einen Film in den Aufbau auf.

@else
- @foreach ($films as $film) + @foreach ($this->frameFilmChoices as $film) @endforeach
- @php($chosen = collect($films)->firstWhere('version_id', (int) $this->frameVersionId)) - @if (is_array($chosen) && filled($chosen['file_url'])) -
- -
- - - -
-
-

Die Vorschau zeigt die Stelle, die als Titelbild übernommen wird. Die Filmdatei selbst bleibt unverändert.

- @if ($frameUrl = $this->framePreviewUrl()) - Vorschau der gewählten Filmstelle - @endif - @elseif (is_array($chosen)) -

Für diese Filmfassung liegt noch keine abspielbare Datei vor.

+
+ + + +
+

Die Vorschau nimmt die kleine Filmstufe, sofern sie vorliegt. Die Filmdatei selbst bleibt unverändert.

+ @if ($frameUrl = $this->framePreviewUrl()) + Vorschau der gewählten Filmstelle @endif @endif @elseif ($this->imageMode === 'bestand') @@ -357,6 +351,23 @@

{{ $member['kind'] }}

{{ $member['title'] }}

{{ $member['version_label'] }}

+ @if (filled($member['medium_description'] ?? null)) +

Beschreibung des Mediums

+

{{ $member['medium_description'] }}

+ @endif + @if (filled($member['usage_note'] ?? null)) +

Hinweise für den Einsatz

+

{{ $member['usage_note'] }}

+ @endif + @if (filled($member['license_note'] ?? null)) +

Interner Lizenzvermerk

+

{{ $member['license_note'] }}

+ @endif +
+ + + Gilt nur in diesem Aufbau. Das Medium selbst bleibt unverändert. +
@if ($this->feedback !== '')

{{ $this->feedback }}

@endif @@ -460,7 +471,7 @@ @endif @if (($detail['tone'] ?? '') === 'film') @if (filled($detail['file_url'] ?? null)) - + @else

Für diese Fassung liegt noch keine abspielbare Datei vor. Ansehen öffnet die vorhandene Vorschau.

@endif diff --git a/resources/views/filament/media/viewer.blade.php b/resources/views/filament/media/viewer.blade.php index 8a3b7f7..1b12ca7 100644 --- a/resources/views/filament/media/viewer.blade.php +++ b/resources/views/filament/media/viewer.blade.php @@ -10,6 +10,14 @@ @else

Noch keine Beschreibung. Beschreibung, Arbeitstitel und Säulen lassen sich ändern, ohne eine neue Fassung anzulegen.

@endif + @if (filled($element->usage_note)) +

Hinweise für den Einsatz

+

{{ $element->usage_note }}

+ @endif + @if (filled($element->license_note)) +

Interner Lizenzvermerk

+

{{ $element->license_note }}

+ @endif

{{ $pillars === [] ? 'Keiner Säule zugeordnet.' : implode(' · ', $pillars) }}

diff --git a/tests/Feature/EditorialEditorTest.php b/tests/Feature/EditorialEditorTest.php index bed9aa0..ea1221e 100644 --- a/tests/Feature/EditorialEditorTest.php +++ b/tests/Feature/EditorialEditorTest.php @@ -526,6 +526,32 @@ public function test_a_missing_film_frame_does_not_create_a_version(): void Storage::disk('media_derived')->assertMissing('inhalte/lara.mp4'); } + public function test_a_placement_note_waits_for_release_and_keeps_the_old_version(): void + { + $content = app(ContentService::class); + $sheet = $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Hinweis'); + $version = $content->publishComposition( + $content->createComposition('Stellenmodul', CompositionKind::Uebung), + [['role' => 'Unterlage', 'target' => $sheet]], + ); + + Livewire::actingAs($this->editor(), 'staff') + ->test(EditExercise::class, ['record' => $version->composition_id]) + ->call('openPart', 0) + ->assertSee('Beschreibung an dieser Stelle') + ->set('noteDraft', 'Hier zuerst den Abstand ansprechen.') + ->call('savePart') + ->assertSee('Es entsteht keine neue Fassung') + ->call('publishRevision'); + + $composition = $version->composition->fresh(); + $this->assertSame(2, $composition->versions()->count()); + $this->assertNull($version->fresh()->members()->first()->placement_note); + $released = $composition->versions()->where('number', 2)->first(); + $this->assertSame('Hier zuerst den Abstand ansprechen.', $released->members()->first()->placement_note); + $this->assertSame(ContentVersionStatus::Bereit, $released->status); + } + private function filmWithPicture(ContentService $content, string $title): ContentElementVersion { $element = $content->createElement('film', 'film', $title); diff --git a/tests/Feature/MediaAdministrationTest.php b/tests/Feature/MediaAdministrationTest.php index 6e81e96..c9d2eb2 100644 --- a/tests/Feature/MediaAdministrationTest.php +++ b/tests/Feature/MediaAdministrationTest.php @@ -5,9 +5,12 @@ use App\Domain\Catalog\CompositionKind; use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentVersionStatus; +use App\Domain\Media\MediaRendition; +use App\Domain\Media\ThumbnailDeriver; use App\Filament\Resources\Combinations\CombinationResource; use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Resources\ContentElements\Pages\EditContentElement; +use App\Filament\Resources\ContentElements\Pages\ListContentElements; use App\Filament\Resources\ContentElements\Pages\ViewContentElement; use App\Filament\Resources\Courses\CourseResource; use App\Filament\Resources\Exercises\ExerciseResource; @@ -250,4 +253,63 @@ public function test_a_description_does_not_create_a_version_and_an_older_versio ->get(route('content.file', $first)) ->assertOk(); } + + public function test_usage_and_license_notes_stay_on_the_medium_and_in_the_list(): void + { + $content = app(ContentService::class); + $element = $content->createElement('film', 'film', 'Lara im Park'); + $content->publishElementVersion($element, 'Film'); + $editor = User::factory()->redakteur()->create(); + $editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP'); + + Livewire::actingAs($editor, 'staff') + ->test(EditContentElement::class, ['record' => $element->getKey()]) + ->fillForm([ + 'working_title' => 'Lara im Park', + 'description' => 'Lara spielt im Park.', + 'usage_note' => 'Vor dem Film den Abstand ansprechen.', + 'license_note' => 'Nur intern: Archivmaterial der Produktion.', + 'pillars' => [], + ]) + ->call('save') + ->assertHasNoFormErrors(); + + $element->refresh(); + $this->assertSame(1, $element->versions()->count()); + $this->assertSame('Vor dem Film den Abstand ansprechen.', $element->usage_note); + $this->assertSame('Nur intern: Archivmaterial der Produktion.', $element->license_note); + + Livewire::actingAs($editor, 'staff') + ->test(ListContentElements::class) + ->assertSee('Vor dem Film den Abstand ansprechen.') + ->assertSee('Nur intern: Archivmaterial'); + + Livewire::actingAs($editor, 'staff') + ->test(ViewContentElement::class, ['record' => $element->getKey()]) + ->assertSee('Hinweise für den Einsatz') + ->assertSee('Interner Lizenzvermerk'); + + $this->get('/')->assertDontSee('Nur intern: Archivmaterial der Produktion.'); + } + + public function test_a_frame_uses_the_small_film_rendition_when_it_exists(): void + { + Storage::fake('media_derived'); + $content = app(ContentService::class); + $element = $content->createElement('film', 'film', 'Lara im Park'); + $version = $content->publishElementVersion($element, null, ['file' => 'inhalte/lara.mp4']); + Storage::disk('media_derived')->put('inhalte/lara.mp4', 'original'); + Storage::disk('media_derived')->put('ableitungen/'.$version->id.'/480/index.m3u8', '#EXTM3U'); + MediaRendition::query()->create([ + 'content_element_version_id' => $version->id, + 'role' => 'variant', + 'label' => '480', + 'path' => 'ableitungen/'.$version->id.'/480/index.m3u8', + ]); + + $this->assertSame( + 'ableitungen/'.$version->id.'/480/index.m3u8', + app(ThumbnailDeriver::class)->frameInput($version), + ); + } }