Zeige Entwürfe in der Medienauswahl eines Moduls.
Deploy Test / test (push) Successful in 26s
Deploy Test / deploy (push) Successful in 28s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-17 11:10:35 +01:00
1 parent b71ee8023b
commit 1168c04228
3 files changed
+38 -5

No files matched your search

@@ -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
+4 -4
View File
@@ -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,
];
}
+33
View File
@@ -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);