Zeige Entwürfe in der Medienauswahl eines Moduls.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
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
|
public function addPart(string $target): void
|
||||||
{
|
{
|
||||||
$this->includePart($target, false);
|
$this->includePart($target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function includePart(string $target, bool $allowDraft): bool
|
private function includePart(string $target, bool $allowDraft): bool
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
|||||||
if ($kind !== 'modul') {
|
if ($kind !== 'modul') {
|
||||||
$latestElements = ContentElementVersion::query()
|
$latestElements = ContentElementVersion::query()
|
||||||
->selectRaw('MAX(id)')
|
->selectRaw('MAX(id)')
|
||||||
->where('status', ContentVersionStatus::Bereit)
|
->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf])
|
||||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId);
|
$this->constrainElement($builder, $query, $like, $kind, $dimensionId);
|
||||||
})
|
})
|
||||||
@@ -233,7 +233,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach ($elements as $version) {
|
foreach ($elements as $version) {
|
||||||
$row = $this->rowForTarget('element:'.$version->id, $exceptCompositionId);
|
$row = $this->rowForTarget('element:'.$version->id, $exceptCompositionId, allowDraft: true);
|
||||||
|
|
||||||
if ($row !== null) {
|
if ($row !== null) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
@@ -371,14 +371,14 @@ public function alternatives(string $identity, int $exceptCompositionId): array
|
|||||||
if ($match[1] === 'medium') {
|
if ($match[1] === 'medium') {
|
||||||
$versions = ContentElementVersion::query()
|
$versions = ContentElementVersion::query()
|
||||||
->where('content_element_id', $match[2])
|
->where('content_element_id', $match[2])
|
||||||
->where('status', ContentVersionStatus::Bereit)
|
->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf])
|
||||||
->orderBy('number')
|
->orderBy('number')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach ($versions as $version) {
|
foreach ($versions as $version) {
|
||||||
$options[] = [
|
$options[] = [
|
||||||
'target' => 'element:'.$version->id,
|
'target' => 'element:'.$version->id,
|
||||||
'label' => 'Fassung '.$version->number,
|
'label' => $version->status === ContentVersionStatus::Entwurf ? 'Entwurf' : 'Fassung '.$version->number,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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']);
|
$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
|
public function test_the_part_dialog_saves_a_role_without_a_new_version(): void
|
||||||
{
|
{
|
||||||
$content = app(ContentService::class);
|
$content = app(ContentService::class);
|
||||||
|
|||||||
Reference in new issue
Block a user