From 1168c04228152b2969b22c16792c312111c5c151 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 17 Nov 2026 11:10:35 +0100 Subject: [PATCH] =?UTF-8?q?Zeige=20Entw=C3=BCrfe=20in=20der=20Medienauswah?= =?UTF-8?q?l=20eines=20Moduls.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../Compositions/Pages/EditComposition.php | 2 +- app/Filament/Support/EditorialCatalog.php | 8 ++--- tests/Feature/EditorialEditorTest.php | 33 +++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/app/Filament/Resources/Compositions/Pages/EditComposition.php b/app/Filament/Resources/Compositions/Pages/EditComposition.php index 29f09b0..05e8367 100644 --- a/app/Filament/Resources/Compositions/Pages/EditComposition.php +++ b/app/Filament/Resources/Compositions/Pages/EditComposition.php @@ -676,7 +676,7 @@ public function selectPart(int $index): void public function addPart(string $target): void { - $this->includePart($target, false); + $this->includePart($target, true); } private function includePart(string $target, bool $allowDraft): bool diff --git a/app/Filament/Support/EditorialCatalog.php b/app/Filament/Support/EditorialCatalog.php index 05deeda..52e13e5 100644 --- a/app/Filament/Support/EditorialCatalog.php +++ b/app/Filament/Support/EditorialCatalog.php @@ -220,7 +220,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce if ($kind !== 'modul') { $latestElements = ContentElementVersion::query() ->selectRaw('MAX(id)') - ->where('status', ContentVersionStatus::Bereit) + ->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf]) ->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void { $this->constrainElement($builder, $query, $like, $kind, $dimensionId); }) @@ -233,7 +233,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce ->get(); foreach ($elements as $version) { - $row = $this->rowForTarget('element:'.$version->id, $exceptCompositionId); + $row = $this->rowForTarget('element:'.$version->id, $exceptCompositionId, allowDraft: true); if ($row !== null) { $rows[] = $row; @@ -371,14 +371,14 @@ public function alternatives(string $identity, int $exceptCompositionId): array if ($match[1] === 'medium') { $versions = ContentElementVersion::query() ->where('content_element_id', $match[2]) - ->where('status', ContentVersionStatus::Bereit) + ->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf]) ->orderBy('number') ->get(); foreach ($versions as $version) { $options[] = [ 'target' => 'element:'.$version->id, - 'label' => 'Fassung '.$version->number, + 'label' => $version->status === ContentVersionStatus::Entwurf ? 'Entwurf' : 'Fassung '.$version->number, ]; } diff --git a/tests/Feature/EditorialEditorTest.php b/tests/Feature/EditorialEditorTest.php index a57ac0f..1cd99cb 100644 --- a/tests/Feature/EditorialEditorTest.php +++ b/tests/Feature/EditorialEditorTest.php @@ -467,6 +467,39 @@ public function test_the_picker_groups_versions_and_adopts_the_chosen_one(): voi $this->assertSame('element:'.$first->id, $module->working_draft['members'][0]['target']); } + public function test_the_picker_includes_draft_media(): void + { + $content = app(ContentService::class); + $ready = $content->publishElementVersion($content->createElement('text', 'text', 'Fertiger Hinweis'), 'Text'); + $onlyDraft = $content->draftElementVersion($content->createElement('film', 'film', 'Felix beim Onkel'), 'Szene'); + $revised = $content->createElement('text', 'text', 'Hinweis mit Entwurf'); + $content->publishElementVersion($revised, 'Alt'); + $newerDraft = $content->draftElementVersion($revised, 'Neu'); + $module = $content->createComposition('Auswahl', CompositionKind::Uebung); + + $component = Livewire::actingAs($this->editor(), 'staff') + ->test(EditExercise::class, ['record' => $module->id]) + ->call('openPicker'); + + $byTitle = []; + + foreach ($component->instance()->pickerResult()['items'] as $item) { + $byTitle[$item['title']] = $item['target']; + } + + $this->assertSame('element:'.$ready->id, $byTitle['Fertiger Hinweis']); + $this->assertSame('element:'.$onlyDraft->id, $byTitle['Felix beim Onkel']); + $this->assertSame('element:'.$newerDraft->id, $byTitle['Hinweis mit Entwurf']); + + $component + ->set('pickerSelected', 'element:'.$onlyDraft->id) + ->assertSee('Felix beim Onkel') + ->call('addPart', 'element:'.$onlyDraft->id); + + $this->assertSame('element:'.$onlyDraft->id, $module->fresh()->working_draft['members'][0]['target']); + $this->assertSame(ContentVersionStatus::Entwurf, $onlyDraft->fresh()->status); + } + public function test_the_part_dialog_saves_a_role_without_a_new_version(): void { $content = app(ContentService::class);