Halte ungenutzte Medien bearbeitbar und lege Dateien direkt im Modul an.
Deploy Test / test (push) Successful in 26s
Deploy Test / deploy (push) Successful in 30s

Eine Fassung wird erst unveränderlich, wenn sie freigegeben und verwendet wird. Das Auge am Listeneintrag öffnet die Vorschau.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-17 10:34:42 +01:00
1 parent 1fb48783bf
commit c73207f2c3
11 files changed
+547 -25

No files matched your search

@@ -38,6 +38,18 @@ protected static function booted(): void
return;
}
if (
$original === ContentVersionStatus::Bereit->value
&& StatusValue::of($version->status) === ContentVersionStatus::Bereit->value
&& ! app(ContentService::class)->isCommitted($version)
) {
$contentFields = ['body', 'metadata', 'content_hash', 'change_note', 'updated_at'];
if (array_diff(array_keys($version->getDirty()), $contentFields) === []) {
return;
}
}
$allowed = ['status', 'updated_at'];
if (
+86
View File
@@ -78,6 +78,92 @@ public function publishElementVersion(
return $version;
}
public function draftElementVersion(
ContentElement $element,
?string $body = null,
array $metadata = [],
): ContentElementVersion {
if (($body === null || $body === '') && $metadata === []) {
throw new DomainRuleException('Eine Inhaltsfassung braucht einen Inhalt.');
}
$number = ((int) $element->versions()->max('number')) + 1;
$version = $element->versions()->create([
'number' => $number,
'status' => ContentVersionStatus::Entwurf,
'content_hash' => hash('sha256', json_encode([
'body' => $body,
'metadata' => $metadata,
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE)),
'body' => $body,
'metadata' => $metadata === [] ? null : $metadata,
'change_note' => null,
]);
$incoming = $metadata['incoming'] ?? null;
if (is_string($incoming) && $incoming !== '') {
StoreContentFile::dispatch($version->id, $incoming);
$version->refresh();
}
return $version;
}
public function isCommitted(ContentElementVersion $version): bool
{
if ($version->status !== ContentVersionStatus::Bereit) {
return false;
}
$usedByComposition = CompositionMember::query()
->where('content_element_version_id', $version->id)
->whereHas('compositionVersion', function ($query): void {
$query->where('status', ContentVersionStatus::Bereit);
})
->exists();
if ($usedByComposition) {
return true;
}
return ReleaseContent::query()
->where('content_element_version_id', $version->id)
->exists();
}
public function reviseElementContent(ContentElementVersion $version, string $body): ContentElementVersion
{
$body = trim($body);
if ($body === '') {
throw new DomainRuleException('Der Text braucht einen Inhalt.');
}
$version->loadMissing('element');
if ($version->status === ContentVersionStatus::Gesperrt) {
throw new DomainRuleException('Eine deaktivierte Fassung lässt sich nicht ändern.');
}
if (trim((string) $version->body) === $body) {
return $version;
}
if ($this->isCommitted($version)) {
return $this->publishElementVersion($version->element, $body);
}
$metadata = $version->metadata ?? [];
$version->body = $body;
$version->content_hash = hash('sha256', json_encode([
'body' => $body,
'metadata' => $metadata,
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
$version->save();
return $version->refresh();
}
/**
* @param list<array{role: string, target: ContentElementVersion|CompositionVersion}> $members
*/
@@ -20,6 +20,7 @@
use App\Domain\Catalog\IdentityProfile;
use App\Domain\Catalog\StructureNode;
use App\Filament\Support\EditorialCatalog;
use App\Filament\Support\IncomingFile;
use App\Http\Controllers\ContentPreviewController;
use App\Jobs\DeriveCompositionFrame;
use App\Jobs\DeriveThumbnail;
@@ -88,6 +89,8 @@ abstract class EditComposition extends EditRecord
public bool $textOpen = false;
public bool $fileOpen = false;
public bool $releaseArmed = false;
public string $returnUrl = '';
@@ -100,6 +103,14 @@ abstract class EditComposition extends EditRecord
public string $newTextBody = '';
public string $newFileTitle = '';
public mixed $incomingFile = null;
public string $partTitle = '';
public string $partBody = '';
public string $newModuleName = '';
public mixed $previewUpload = null;
@@ -301,6 +312,7 @@ public function openPicker(): void
$this->pickerOpen = true;
$this->textOpen = false;
$this->fileOpen = false;
$this->pickerSelected = '';
}
@@ -396,6 +408,7 @@ public function openText(): void
$this->pickerOpen = false;
$this->moduleOpen = false;
$this->partOpen = false;
$this->fileOpen = false;
$this->textOpen = true;
}
@@ -406,6 +419,22 @@ public function cancelText(): void
$this->newTextBody = '';
}
public function openFile(): void
{
$this->pickerOpen = false;
$this->moduleOpen = false;
$this->partOpen = false;
$this->textOpen = false;
$this->fileOpen = true;
}
public function cancelFile(): void
{
$this->fileOpen = false;
$this->newFileTitle = '';
$this->incomingFile = null;
}
public function saveDraft(): void
{
$this->commitRoleDraft();
@@ -668,11 +697,16 @@ public function selectPart(int $index): void
}
public function addPart(string $target): void
{
$this->includePart($target, false);
}
private function includePart(string $target, bool $allowDraft): bool
{
if (preg_match('/^(element|composition):\d+$/', $target) !== 1) {
$this->feedback = 'Dieser Bestandteil ist nicht verfügbar.';
return;
return false;
}
foreach ($this->members as $index => $member) {
@@ -681,16 +715,16 @@ public function addPart(string $target): void
$this->panel = 'bestandteil';
$this->feedback = 'Diese Fassung ist schon enthalten.';
return;
return false;
}
}
$row = app(EditorialCatalog::class)->rowForTarget($target, (int) $this->getRecord()->getKey());
$row = app(EditorialCatalog::class)->rowForTarget($target, (int) $this->getRecord()->getKey(), allowDraft: $allowDraft);
if ($row === null) {
$this->feedback = 'Diese Fassung ist nicht bereit oder gehört zu diesem Eintrag.';
return;
return false;
}
$row['role'] = app(EditorialCatalog::class)->defaultRole((string) $row['kind']);
@@ -705,10 +739,12 @@ public function addPart(string $target): void
$this->pickerSelected = '';
if (! $this->persistDraft()) {
return;
return false;
}
$this->feedback = $row['title'].' ist in den Aufbau übernommen. Die Datei wird nicht kopiert. Der Entwurf ist gespeichert. Es entsteht keine neue Fassung.';
return true;
}
public function removePart(int $index): void
@@ -796,7 +832,7 @@ public function addText(): void
try {
$service = app(ContentService::class);
$element = $service->createElement('text', 'text', $title);
$version = $service->publishElementVersion($element, $body);
$version = $service->draftElementVersion($element, $body);
} catch (DomainRuleException $exception) {
$this->feedback = $exception->getMessage();
@@ -806,8 +842,62 @@ public function addText(): void
$this->newTextTitle = '';
$this->newTextBody = '';
$this->textOpen = false;
$this->addPart('element:'.$version->id);
$this->feedback = $title.' ist angelegt und in den Aufbau übernommen. Derselbe Text kann später woanders wiederverwendet werden. Der Entwurf ist gespeichert. Es entsteht keine neue Fassung dieses Eintrags.';
if (! $this->includePart('element:'.$version->id, true)) {
return;
}
$this->feedback = $title.' ist angelegt und in den Aufbau übernommen. Der Text bleibt bearbeitbar, solange diese Fassung nicht freigegeben und verwendet wird. Es entsteht keine neue Fassung dieses Eintrags.';
}
public function addFile(): void
{
$title = trim($this->newFileTitle);
$stored = IncomingFile::store($this->incomingFile);
if ($title === '' || $stored === null) {
$this->feedback = 'Das Medium braucht einen Titel und eine Datei.';
return;
}
$extension = strtolower(pathinfo($stored, PATHINFO_EXTENSION));
$shape = match ($extension) {
'mp4', 'webm', 'mov', 'm4v' => ['film', 'film'],
'mp3', 'm4a', 'wav', 'ogg' => ['audio', 'audio'],
'png', 'jpg', 'jpeg', 'webp', 'gif' => ['bild', 'bild'],
'pdf' => ['dokument', 'document'],
default => null,
};
if ($shape === null) {
$this->feedback = 'Diese Dateiart lässt sich hier nicht anlegen.';
return;
}
try {
$service = app(ContentService::class);
$element = $service->createElement($shape[0], $shape[1], $title);
$version = $service->draftElementVersion($element, null, [
'incoming' => $stored,
'hold' => true,
]);
} catch (DomainRuleException $exception) {
$this->feedback = $exception->getMessage();
return;
}
$this->newFileTitle = '';
$this->incomingFile = null;
$this->fileOpen = false;
if (! $this->includePart('element:'.$version->id, true)) {
return;
}
$this->feedback = $title.' ist angelegt und in den Aufbau übernommen. Die Datei liegt bei den Medien. Eine neue Fassung entsteht erst, wenn diese Fassung freigegeben und verwendet wird.';
}
public function startModule(): void
@@ -856,6 +946,7 @@ public function openModule(): void
$this->pickerOpen = false;
$this->partOpen = false;
$this->textOpen = false;
$this->fileOpen = false;
$this->moduleTab = 'beschreibung';
$this->frameFilmChoices = $this->frameFilms();
$films = $this->frameFilmChoices;
@@ -914,10 +1005,14 @@ public function saveModule(): void
public function openPart(int $index): void
{
$this->selectPart($index);
$member = $this->selectedMember();
$this->partTitle = (string) ($member['title'] ?? '');
$this->partBody = (string) ($member['body'] ?? '');
$this->partSnapshot = $this->members;
$this->moduleOpen = false;
$this->pickerOpen = false;
$this->textOpen = false;
$this->fileOpen = false;
$this->partOpen = true;
}
@@ -941,6 +1036,11 @@ public function savePart(): void
}
$this->commitRoleDraft();
$textNote = $this->writePartText();
if ($textNote === false) {
return;
}
if (! $this->persistDraft()) {
return;
@@ -948,7 +1048,9 @@ public function savePart(): void
$this->partOpen = false;
$this->partSnapshot = [];
$this->feedback = 'Die Angaben zum Bestandteil sind im Entwurf. Es entsteht keine neue Fassung.';
$this->feedback = $textNote !== ''
? $textNote
: 'Die Angaben zum Bestandteil sind im Entwurf. Es entsteht keine neue Fassung.';
}
/**
@@ -1098,6 +1200,118 @@ public function adoptPicture(int $elementId): void
$this->feedback = $this->previewFeedback($record, $before);
}
private function writePartText(): string|false
{
$index = $this->selected;
$member = $this->selectedMember();
if ($index === null || $member === null || ($member['output'] ?? '') !== 'text') {
return '';
}
$title = trim($this->partTitle);
$body = trim($this->partBody);
if ($title === '' || $body === '') {
$this->feedback = 'Der Text braucht einen Titel und einen Inhalt.';
return false;
}
if (preg_match('/^element:(\d+)$/', (string) ($member['target'] ?? ''), $match) !== 1) {
return '';
}
$version = ContentElementVersion::query()->with('element')->find($match[1]);
if (! $version instanceof ContentElementVersion || $version->element === null) {
$this->feedback = 'Dieser Text ist nicht mehr vorhanden.';
return false;
}
$changed = $title !== (string) ($member['title'] ?? '') || $body !== trim((string) $version->body);
if (! $changed) {
return '';
}
try {
$service = app(ContentService::class);
$service->describe($version->element, $title, $version->element->description);
$updated = $service->reviseElementContent($version, $body);
} catch (DomainRuleException $exception) {
$this->feedback = $exception->getMessage();
return false;
}
if ($updated->id === $version->id) {
$this->members[$index]['title'] = $title;
$this->members[$index]['body'] = $body;
return 'Der Text ist in derselben Fassung geändert. Eine neue Fassung entsteht, sobald diese Fassung freigegeben und verwendet wird.';
}
$row = app(EditorialCatalog::class)->rowForTarget(
'element:'.$updated->id,
(int) $this->getRecord()->getKey(),
allowSelf: true,
allowDraft: true,
);
if ($row === null) {
$this->feedback = 'Die neue Fassung ließ sich nicht in den Aufbau übernehmen.';
return false;
}
$row['role'] = (string) ($this->members[$index]['role'] ?? $row['kind']);
$row['note'] = (string) ($this->members[$index]['note'] ?? '');
$this->members[$index] = $row;
return 'Die Änderung liegt in einer neuen Fassung. Die bisherige Fassung bleibt in den freigegebenen Aufbauten.';
}
/**
* @param list<array{role: string, target: ContentElementVersion|CompositionVersion, note: string}> $payload
*/
private function promoteDraftElements(array $payload): bool
{
foreach ($payload as $member) {
$target = $member['target'];
if (! $target instanceof ContentElementVersion || $target->status !== ContentVersionStatus::Entwurf) {
continue;
}
$meta = is_array($target->metadata) ? $target->metadata : [];
if (isset($meta['incoming']) && ! isset($meta['file'])) {
$this->feedback = 'Eine Datei wird noch übernommen. Gib den Aufbau frei, sobald die Datei bereitsteht.';
return false;
}
if (isset($meta['error'])) {
$this->feedback = (string) $meta['error'];
return false;
}
unset($meta['held']);
$target->metadata = $meta === [] ? null : $meta;
$target->content_hash = hash('sha256', json_encode([
'body' => $target->body,
'metadata' => $meta,
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
$target->status = ContentVersionStatus::Bereit;
$target->save();
}
return true;
}
/**
* @return array{url: ?string, note: ?string, own: bool}
*/
@@ -1210,6 +1424,10 @@ public function publishRevision(): bool
];
}
if (! $this->promoteDraftElements($payload)) {
return false;
}
/** @var Composition $record */
$record = $this->getRecord();
$note = trim($this->revisionNote);
@@ -1343,7 +1561,7 @@ protected function applyDraft(array $draft): void
}
$requested++;
$row = $catalog->rowForTarget((string) ($member['target'] ?? ''), (int) $this->getRecord()->getKey(), allowSelf: true);
$row = $catalog->rowForTarget((string) ($member['target'] ?? ''), (int) $this->getRecord()->getKey(), allowSelf: true, allowDraft: true);
if ($row === null) {
continue;
@@ -3,6 +3,7 @@
namespace App\Filament\Resources\ContentElements;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Identity\StaffRole;
use App\Filament\Resources\ContentElements\Pages\EditContentElement;
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
@@ -85,8 +86,11 @@ public static function table(Table $table): Table
}
$file = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
$label = $version->status === ContentVersionStatus::Entwurf
? 'Entwurf'
: 'Fassung '.$version->number;
return 'Fassung '.$version->number.(is_string($file) && $file !== '' ? ' · mit Datei' : ' · ohne Datei');
return $label.(is_string($file) && $file !== '' ? ' · mit Datei' : ' · ohne Datei');
}),
]);
}
@@ -39,6 +39,8 @@ class ViewContentElement extends ViewRecord
public string $frameSecond = '';
public string $bodyDraft = '';
public string $thumbnailAlt = '';
public string $pictureFeedback = '';
@@ -56,6 +58,7 @@ public function mount(int|string $record): void
}
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
$this->syncBodyDraft();
}
public function getSubheading(): string|Htmlable|null
@@ -74,6 +77,25 @@ public function showVersion(int $version): void
{
abort_unless($this->ownedVersion($version) instanceof ContentElementVersion, 404);
$this->fassung = $version;
$this->syncBodyDraft();
}
public function saveShownText(): void
{
$shown = $this->shownVersion();
if (! ContentElementResource::editor() || ! $shown instanceof ContentElementVersion || $shown->element?->output_class !== 'text') {
return;
}
$created = app(ContentService::class)->isCommitted($shown);
$this->report(function () use ($shown): void {
app(ContentService::class)->reviseElementContent($shown, $this->bodyDraft);
}, $created
? 'Die neue Fassung ist angelegt. Die bisherige bleibt erhalten.'
: 'Der Text ist in derselben Fassung gespeichert.');
$this->getRecord()->unsetRelation('versions');
$this->syncBodyDraft();
}
public function adoptFrame(): void
@@ -282,6 +304,7 @@ private function viewerData(): array
?? $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Bereit)
?? $versions->first();
$preview = app(ContentPreviewController::class);
$committed = $shown instanceof ContentElementVersion && app(ContentService::class)->isCommitted($shown);
return [
'element' => $element,
@@ -292,11 +315,21 @@ private function viewerData(): array
'pillars' => $element->pillars->pluck('name')->all(),
'usage' => app(CatalogReading::class)->elementUsage($element),
'canRevise' => ContentElementResource::editor(),
'canEditBody' => ContentElementResource::editor()
&& $shown instanceof ContentElementVersion
&& $element->output_class === 'text'
&& $shown->status !== ContentVersionStatus::Gesperrt,
'bodyCommitted' => $committed,
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
'pictureCaption' => $this->pictureCaption($element),
];
}
private function syncBodyDraft(): void
{
$this->bodyDraft = (string) ($this->shownVersion()?->body ?? '');
}
private function shownVersion(): ?ContentElementVersion
{
/** @var ContentElement $element */
+14 -6
View File
@@ -40,7 +40,7 @@ public function rows(CompositionVersion $version, int $exceptCompositionId): arr
$target = $member->content_element_version_id
? 'element:'.$member->content_element_version_id
: 'composition:'.$member->nested_composition_version_id;
$row = $this->rowForTarget($target, $exceptCompositionId, allowSelf: true);
$row = $this->rowForTarget($target, $exceptCompositionId, allowSelf: true, allowDraft: true);
if ($row === null) {
continue;
@@ -57,7 +57,7 @@ public function rows(CompositionVersion $version, int $exceptCompositionId): arr
/**
* @return array<string, string|null>|null
*/
public function rowForTarget(string $target, int $exceptCompositionId, bool $allowSelf = false): ?array
public function rowForTarget(string $target, int $exceptCompositionId, bool $allowSelf = false, bool $allowDraft = false): ?array
{
if (preg_match('/^(element|composition):(\d+)$/', $target, $match) !== 1) {
return null;
@@ -67,8 +67,13 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
$version = ContentElementVersion::query()
->with('element.editorialContentKind')
->find($match[2]);
$acceptable = [ContentVersionStatus::Bereit];
if (! $version instanceof ContentElementVersion || $version->status !== ContentVersionStatus::Bereit) {
if ($allowDraft) {
$acceptable[] = ContentVersionStatus::Entwurf;
}
if (! $version instanceof ContentElementVersion || ! in_array($version->status, $acceptable, true)) {
return null;
}
@@ -80,13 +85,16 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
'target' => 'element:'.$version->id,
'title' => $title,
'kind' => $kind,
'output' => (string) $element->output_class,
'body' => (string) ($version->body ?? ''),
'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,
'version_label' => $version->status === ContentVersionStatus::Entwurf ? 'Entwurf' : 'Fassung '.$version->number,
'committed' => app(ContentService::class)->isCommitted($version),
'identity' => 'medium:'.$element->id,
'open_url' => route('content.preview', $version),
'open_label' => 'Medium ansehen',
@@ -119,8 +127,8 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
'version_label' => 'Fassung '.$version->number,
'identity' => 'zusammenstellung:'.$composition->id,
'open_url' => null,
'open_label' => null,
'open_url' => route('editorial.preview', ['composition' => $composition, 'version' => $version]),
'open_label' => 'Aufbau ansehen',
'edit_url' => self::editUrl($composition),
];
}
+12 -2
View File
@@ -63,14 +63,24 @@ public function handle(): void
}
$metadata = $version->metadata ?? [];
unset($metadata['incoming']);
$hold = ($metadata['hold'] ?? false) === true;
unset($metadata['incoming'], $metadata['hold']);
$metadata['file'] = $target;
if ($hold) {
$metadata['held'] = true;
}
$version->metadata = $metadata;
$version->content_hash = hash('sha256', json_encode([
'body' => $version->body,
'metadata' => $metadata,
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
$version->status = ContentVersionStatus::Bereit;
if (! $hold) {
$version->status = ContentVersionStatus::Bereit;
}
$version->save();
DeriveThumbnail::dispatch('element', $version->content_element_id);
DeriveFilmRenditions::dispatch($version->id);
@@ -38,15 +38,19 @@
<section class="luf-pane" aria-label="Aufbau">
<div class="luf-pane-head">
<h2>Aufbau</h2>
<button type="button" class="luf-primary" wire:click="openPicker">Bestandteil hinzufügen</button>
<div class="luf-actions">
<button type="button" class="luf-primary" wire:click="openPicker">Bestandteil hinzufügen</button>
<button type="button" class="luf-quiet" wire:click="openText">Text erstellen</button>
<button type="button" class="luf-quiet" wire:click="openFile">Medium anlegen</button>
</div>
</div>
<p class="luf-note">Der Aufbau ist die Arbeitsfläche. Das Stiftsymbol öffnet die Eigenschaften eines Bestandteils. Ziehen ändert die Reihenfolge, Nach oben und Nach unten tun dasselbe ohne Ziehen.</p>
<p class="luf-note">Der Aufbau ist die Arbeitsfläche. Das Stiftsymbol bearbeitet den Bestandteil, das Auge öffnet eine Vorschau. Ziehen ändert die Reihenfolge, Nach oben und Nach unten tun dasselbe ohne Ziehen.</p>
@if ($this->members === [])
<p class="luf-empty">
@if ($this->isProgram())
Dieses Programm hat noch keinen Bestandteil. Füge ein Modul oder ein Medium hinzu. Die Datei wird nicht kopiert.
@else
Dieses Modul hat noch keinen Bestandteil. Füge ein vorhandenes Medium hinzu oder erstelle einen Text. Ein Film ist nicht nötig.
Dieses Modul hat noch keinen Bestandteil. Füge ein vorhandenes Medium hinzu, erstelle einen Text oder lege eine Datei an. Ein Film ist nicht nötig.
@endif
</p>
@else
@@ -87,6 +91,14 @@
</span>
</button>
<div class="luf-move">
@if (! empty($member['open_url']))
<a class="luf-icon" href="{{ $member['open_url'] }}" target="_blank" rel="noopener" aria-label="Vorschau: {{ $member['title'] }}">
<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">
<path d="M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6S2 12 2 12z" fill="none" stroke="currentColor" stroke-width="1.8"/>
<circle cx="12" cy="12" r="2.5" fill="none" stroke="currentColor" stroke-width="1.8"/>
</svg>
</a>
@endif
<button type="button" class="luf-icon" wire:click="openPart({{ $index }})" aria-label="Bearbeiten: {{ $member['title'] }}">
<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true">
<path d="M4 20h4l10.2-10.2-4-4L4 16v4z" fill="none" stroke="currentColor" stroke-width="1.8"/>
@@ -145,9 +157,6 @@
<div class="luf-actions">
<button type="button" class="luf-primary" wire:click="openModule">{{ $this->hostLabel() }} bearbeiten</button>
</div>
@if ($member = $this->selectedMember())
<p class="luf-note">Ausgewählt: {{ $member['title'] }}, Rolle {{ $member['role'] }}. Das Stiftsymbol öffnet die Bearbeitung.</p>
@endif
<h3>Freigegebene Fassungen</h3>
@if ($this->versionChoices() === [])
@@ -351,6 +360,23 @@
<p class="luf-kicker">{{ $member['kind'] }}</p>
<h3>{{ $member['title'] }}</h3>
<p class="luf-meta">{{ $member['version_label'] }}</p>
@if (($member['output'] ?? '') === 'text')
<div class="luf-field">
<label for="teil-titel">Titel</label>
<input id="teil-titel" type="text" wire:model="partTitle">
</div>
<div class="luf-field">
<label for="teil-inhalt">Inhalt</label>
<textarea id="teil-inhalt" rows="8" wire:model="partBody"></textarea>
</div>
<p class="luf-note">
@if (! empty($member['committed']))
Diese Fassung ist freigegeben und wird verwendet. Eine Änderung des Textes legt eine neue Fassung an. Die bisherige bleibt in den freigegebenen Aufbauten.
@else
Dieser Text ist noch nicht freigegeben und verwendet. Die Änderung schreibt dieselbe Fassung fort.
@endif
</p>
@endif
@if (filled($member['medium_description'] ?? null))
<p class="luf-kicker">Beschreibung des Mediums</p>
<p>{{ $member['medium_description'] }}</p>
@@ -504,6 +530,7 @@
@endif
<div class="luf-actions">
<button type="button" class="luf-quiet" wire:click="openText">Neuen Text erstellen</button>
<button type="button" class="luf-quiet" wire:click="openFile">Medium anlegen</button>
@if ($this->isProgram())
<p class="luf-note">Ein neues Modul legst du im Aufbau an. Du kehrst danach hierher zurück.</p>
@endif
@@ -542,4 +569,29 @@
</form>
</div>
@endif
@if ($this->fileOpen)
<div class="luf-modal" role="dialog" aria-modal="true" aria-labelledby="datei-titel-ueberschrift">
<form class="luf-modal-card luf-modal-narrow" wire:submit="addFile">
<div class="luf-pane-head">
<h2 id="datei-titel-ueberschrift">Medium anlegen</h2>
<button type="button" class="luf-quiet" wire:click="cancelFile">Abbrechen</button>
</div>
<p class="luf-note">Die Datei wird bei den Medien gespeichert und in diesen Aufbau übernommen. Sie wird nicht kopiert. Solange die Fassung nicht freigegeben und verwendet wird, bleibt sie ein Entwurf.</p>
<div class="luf-field">
<label for="datei-titel">Titel</label>
<input id="datei-titel" type="text" wire:model="newFileTitle" required>
</div>
<div class="luf-field">
<label for="datei-datei">Datei</label>
<input id="datei-datei" type="file" wire:model="incomingFile" accept=".mp4,.webm,.mov,.m4v,.mp3,.m4a,.wav,.ogg,.png,.jpg,.jpeg,.webp,.gif,.pdf" required>
<span class="luf-meta">Film, Hörstück, Bild oder PDF.</span>
</div>
<div class="luf-actions">
<button class="luf-primary" type="submit">Medium anlegen und übernehmen</button>
<button type="button" class="luf-quiet" wire:click="cancelFile">Abbrechen</button>
</div>
</form>
</div>
@endif
</div>
@@ -67,6 +67,18 @@
@else
<h2 style="font-size: 1.125rem; font-weight: 600;">Fassung {{ $shown->number }}</h2>
@include('content.player', ['version' => $shown, 'fileUrl' => $fileUrl, 'pending' => $pending])
@if ($canEditBody)
<label for="fassung-text">Text</label>
<textarea id="fassung-text" rows="8" wire:model="bodyDraft"></textarea>
<button type="button" wire:click="saveShownText">Text speichern</button>
<p>
@if ($bodyCommitted)
Diese Fassung ist freigegeben und wird verwendet. Speichern legt eine neue Fassung an. Die bisherige bleibt erhalten.
@else
Solange diese Fassung nicht freigegeben und verwendet wird, bleibt es dieselbe Fassung.
@endif
</p>
@endif
@if (! $fileUrl && ! $pending && blank($shown->body) && ! is_string((is_array($shown->metadata) ? $shown->metadata : [])['file'] ?? null))
<p>Für diese Fassung liegt noch kein Text und keine Datei vor.</p>
@endif
+12
View File
@@ -164,6 +164,18 @@ public function test_g_a_new_element_version_does_not_change_a_published_composi
$first->save();
}
public function test_an_unused_ready_text_changes_without_a_new_version(): void
{
$content = app(ContentService::class);
$version = $content->publishElementVersion($content->createElement('text', 'text', 'Notiz'), 'Alt');
$updated = $content->reviseElementContent($version, 'Neu');
$this->assertFalse($content->isCommitted($updated));
$this->assertSame($version->id, $updated->id);
$this->assertSame('Neu', $updated->body);
$this->assertSame(1, $version->element->versions()->count());
}
public function test_h_a_bundle_change_does_not_change_an_activated_offer(): void
{
$first = $this->publishedArticle('grundlage', 'Grundlage');
+75
View File
@@ -5,10 +5,12 @@
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\ContentVersionStatus;
use App\Filament\Pages\EditorialDesk;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Resources\Courses\CourseResource;
use App\Filament\Resources\Courses\Pages\EditCourse;
use App\Filament\Resources\Exercises\ExerciseResource;
@@ -16,6 +18,7 @@
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
use Tests\TestCase;
@@ -553,6 +556,78 @@ public function test_a_placement_note_waits_for_release_and_keeps_the_old_versio
$this->assertSame(ContentVersionStatus::Bereit, $released->status);
}
public function test_a_module_text_stays_editable_until_it_is_released_and_used(): void
{
$editor = $this->editor();
$module = app(ContentService::class)->createComposition('Text im Modul', CompositionKind::Uebung);
$component = Livewire::actingAs($editor, 'staff')
->test(EditExercise::class, ['record' => $module->id])
->set('newTextTitle', 'Hinweis')
->set('newTextBody', 'Erster Wortlaut')
->call('addText')
->assertSee('Vorschau: Hinweis')
->assertSee('das Auge öffnet eine Vorschau')
->assertDontSee('Das Stiftsymbol öffnet die Bearbeitung')
->call('openPart', 0)
->assertSee('dieselbe Fassung fort')
->set('partBody', 'Geänderter Wortlaut')
->call('savePart')
->assertSee('derselben Fassung');
$element = ContentElement::query()->where('working_title', 'Hinweis')->firstOrFail();
$version = $element->versions()->sole();
$this->assertSame(ContentVersionStatus::Entwurf, $version->status);
$this->assertSame('Geänderter Wortlaut', $version->body);
$this->assertSame(1, $element->versions()->count());
$this->actingAs($editor, 'staff')
->get(ContentElementResource::getUrl('index'))
->assertOk()
->assertSee('Hinweis')
->assertSee('Entwurf');
$component->call('publishRevision');
$this->assertSame(ContentVersionStatus::Bereit, $version->fresh()->status);
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
$component
->call('openPart', 0)
->set('partBody', 'Nach der Freigabe')
->call('savePart')
->assertSee('neuen Fassung');
$this->assertSame(2, $element->fresh()->versions()->count());
$this->assertSame('Geänderter Wortlaut', $version->fresh()->body);
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
$this->assertSame('element:'.$element->versions()->orderByDesc('number')->first()->id, $module->fresh()->working_draft['members'][0]['target']);
}
public function test_a_file_can_be_created_inside_the_module(): void
{
Storage::fake('cms_incoming');
Storage::fake('media_derived');
$editor = $this->editor();
$module = app(ContentService::class)->createComposition('Datei im Modul', CompositionKind::Uebung);
Livewire::actingAs($editor, 'staff')
->test(EditExercise::class, ['record' => $module->id])
->set('newFileTitle', 'Merkblatt')
->set('incomingFile', UploadedFile::fake()->create('merkblatt.pdf', 12, 'application/pdf'))
->call('addFile')
->assertSee('Merkblatt')
->call('publishRevision');
$element = ContentElement::query()->where('working_title', 'Merkblatt')->firstOrFail();
$version = $element->versions()->sole();
$this->assertSame('document', $element->output_class);
$this->assertSame(ContentVersionStatus::Bereit, $version->status);
$this->assertIsString($version->metadata['file'] ?? null);
Storage::disk('media_derived')->assertExists($version->metadata['file']);
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
}
private function filmWithPicture(ContentService $content, string $title): ContentElementVersion
{
$element = $content->createElement('film', 'film', $title);