Nimm die kleine Filmstufe für die Titelbildwahl und verankere Hinweise ohne neue Fassung.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c47c3b9b32
commit
f86032cb5f
14 files changed
+283
-46
No files matched your search
@@ -65,6 +65,15 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public string $roleDraft = '';
|
||||
|
||||
public string $noteDraft = '';
|
||||
|
||||
public string $imageCaptionText = '';
|
||||
|
||||
public ?string $thumbnailSource = null;
|
||||
|
||||
/** @var list<array{version_id: int, title: string, label: string, file_url: ?string}> */
|
||||
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'] ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user