Zeige Katalogkarten, Titelbilder und klare Freigabestatus im Arbeitsplatz.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
053a361801
commit
9195cdcd15
15 files changed
+795
-59
No files matched your search
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
@@ -42,6 +43,8 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public string $summary = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $learningGoal = '';
|
||||
|
||||
public string $durationMinutes = '';
|
||||
@@ -92,8 +95,12 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public ?string $thumbnailPath = null;
|
||||
|
||||
public string $thumbnailAlt = '';
|
||||
|
||||
public ?string $thumbnailError = null;
|
||||
|
||||
public string $imageQuery = '';
|
||||
|
||||
/** @var list<array<string, string|null>> */
|
||||
public array $members = [];
|
||||
|
||||
@@ -150,10 +157,10 @@ protected function getHeaderActions(): array
|
||||
->openUrlInNewTab()
|
||||
->visible(fn (): bool => $this->previewUrl() !== null),
|
||||
Action::make('displayRelease')
|
||||
->label('Zur Anzeige freigeben')
|
||||
->label('In Mitgliederbibliothek anzeigen')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Diese Fassung zur Anzeige freigeben')
|
||||
->modalDescription('Freigegeben wird die zuletzt übernommene Fassung. Eine frühere Fassung bleibt unverändert. Ungespeicherte Änderungen am Aufbau sind nicht Teil dieser Freigabe.')
|
||||
->modalHeading('In der Mitgliederbibliothek anzeigen')
|
||||
->modalDescription('Sichtbar wird die zuletzt übernommene Fassung. Das ist keine Website-Veröffentlichung und kein aktives Angebot. Eine frühere Fassung bleibt unverändert. Ungespeicherte Änderungen am Aufbau sind nicht Teil dieser Freigabe.')
|
||||
->visible(function (): bool {
|
||||
$version = $this->currentReadyVersion();
|
||||
|
||||
@@ -163,10 +170,10 @@ protected function getHeaderActions(): array
|
||||
$this->releaseDisplay();
|
||||
}),
|
||||
Action::make('displayRevoke')
|
||||
->label('Anzeige zurücknehmen')
|
||||
->label('Aus Mitgliederbibliothek ausblenden')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Nur die Anzeige dieser Fassung wird zurückgenommen. Der Inhalt der Fassung bleibt gespeichert.')
|
||||
->modalDescription('Die Fassung verschwindet aus der Mitgliederbibliothek. Der fachliche Inhalt bleibt gespeichert. Website und Angebot sind davon unabhängig.')
|
||||
->visible(function (): bool {
|
||||
$version = $this->currentReadyVersion();
|
||||
|
||||
@@ -177,7 +184,7 @@ protected function getHeaderActions(): array
|
||||
$actor = $this->actor();
|
||||
abort_unless($version !== null && $actor instanceof User, 403);
|
||||
app(CompositionDisplayRelease::class)->revoke($version, $actor);
|
||||
$this->feedback = 'Die Anzeige dieser Fassung ist zurückgenommen. Der Inhalt bleibt gespeichert.';
|
||||
$this->feedback = 'Die Fassung ist aus der Mitgliederbibliothek ausgeblendet. Der Inhalt bleibt gespeichert.';
|
||||
}),
|
||||
];
|
||||
}
|
||||
@@ -370,8 +377,8 @@ public function editorStatus(): string
|
||||
$display = $version === null
|
||||
? ''
|
||||
: (app(CompositionDisplayRelease::class)->isReleased($version)
|
||||
? ' Sie ist zur Anzeige freigegeben.'
|
||||
: ' Sie ist noch nicht zur Anzeige freigegeben.');
|
||||
? ' Sie ist in der Mitgliederbibliothek sichtbar.'
|
||||
: ' Sie ist nicht in der Mitgliederbibliothek.');
|
||||
$unsaved = $stored === null
|
||||
? $current !== $ready
|
||||
: $current !== $this->fingerprint($stored);
|
||||
@@ -453,7 +460,7 @@ public function versionChoices(): array
|
||||
$rows[] = [
|
||||
'id' => $version->id,
|
||||
'number' => $version->number,
|
||||
'text' => 'Fassung '.$version->number.($released ? ', zur Anzeige freigegeben' : ''),
|
||||
'text' => 'Fassung '.$version->number.($released ? ', in der Mitgliederbibliothek' : ', nicht in der Mitgliederbibliothek'),
|
||||
'current' => $latest !== null && $latest->id === $version->id,
|
||||
];
|
||||
}
|
||||
@@ -734,6 +741,8 @@ public function saveDisplay(): void
|
||||
app(IdentityProfile::class)->fill($record, [
|
||||
'display_title' => $this->displayTitle,
|
||||
'summary' => $this->summary,
|
||||
'description' => $this->description,
|
||||
'thumbnail_alt' => $this->thumbnailAlt,
|
||||
], $this->actor());
|
||||
$this->syncDimensions($record, array_map(intval(...), $this->dimensionIds));
|
||||
$record->refresh();
|
||||
@@ -778,6 +787,82 @@ public function savePreviewImage(string $storedPath): void
|
||||
$this->storePreview($storedPath);
|
||||
}
|
||||
|
||||
public function adoptPicture(int $elementId): void
|
||||
{
|
||||
$element = ContentElement::query()->find($elementId);
|
||||
$path = $element?->thumbnail_path;
|
||||
|
||||
if (! $element instanceof ContentElement || ! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||
$this->feedback = 'Für dieses Medium liegt noch kein Vorschaubild vor.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Composition $record */
|
||||
$record = $this->getRecord();
|
||||
$before = $record->versions()->count();
|
||||
DeriveThumbnail::dispatch('komposition', $record->id, null, $element->id);
|
||||
$record->refresh();
|
||||
$this->thumbnailPath = $record->thumbnail_path;
|
||||
$this->thumbnailError = $record->thumbnail_error;
|
||||
$this->feedback = $this->previewFeedback($record, $before);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: ?string, note: ?string, own: bool}
|
||||
*/
|
||||
public function coverPicture(): array
|
||||
{
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
|
||||
return app(EditorialCatalog::class)->cover($composition, $this->members);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, title: string, image: string}>
|
||||
*/
|
||||
public function filmChoices(): array
|
||||
{
|
||||
$films = app(EditorialCatalog::class)->filmPictures($this->members);
|
||||
|
||||
return count($films) > 1 ? $films : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{id: int, title: string, image: string}|null
|
||||
*/
|
||||
public function suggestedFilm(): ?array
|
||||
{
|
||||
if (filled($this->thumbnailPath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$films = app(EditorialCatalog::class)->filmPictures($this->members);
|
||||
|
||||
return count($films) === 1 ? $films[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, title: string, image: string, kind: string}>
|
||||
*/
|
||||
public function mediaChoices(): array
|
||||
{
|
||||
return app(EditorialCatalog::class)->mediaPictures($this->imageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{label: string, tone: string}>
|
||||
*/
|
||||
public function presentationChips(): array
|
||||
{
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
$offered = in_array($composition->id, app(EditorialCatalog::class)->offeredCompositionIds(), true);
|
||||
|
||||
return app(EditorialCatalog::class)->statusChips($composition, $offered);
|
||||
}
|
||||
|
||||
public function publishRevision(): bool
|
||||
{
|
||||
$this->commitRoleDraft();
|
||||
@@ -910,7 +995,9 @@ protected function loadEditor(): void
|
||||
$this->designation = $composition->designation;
|
||||
$this->displayTitle = (string) ($composition->display_title ?? '');
|
||||
$this->summary = (string) ($composition->summary ?? '');
|
||||
$this->description = (string) ($composition->description ?? '');
|
||||
$this->thumbnailPath = $composition->thumbnail_path;
|
||||
$this->thumbnailAlt = (string) ($composition->thumbnail_alt ?? '');
|
||||
$this->thumbnailError = $composition->thumbnail_error;
|
||||
$this->dimensionIds = IdentityDimensionValue::query()
|
||||
->where('subject_type', $composition->getMorphClass())
|
||||
@@ -1034,7 +1121,7 @@ protected function releaseCurrent(): void
|
||||
}
|
||||
|
||||
app(CompositionDisplayRelease::class)->release($version, $actor);
|
||||
$this->feedback = 'Fassung '.$version->number.' ist zur Anzeige freigegeben. Frühere Fassungen bleiben erhalten.';
|
||||
$this->feedback = 'Fassung '.$version->number.' ist in der Mitgliederbibliothek sichtbar. Frühere Fassungen bleiben erhalten.';
|
||||
}
|
||||
|
||||
protected function currentReadyVersion(): ?CompositionVersion
|
||||
@@ -1156,9 +1243,24 @@ protected function storePreview(string $path): void
|
||||
$record->refresh();
|
||||
$this->thumbnailPath = $record->thumbnail_path;
|
||||
$this->thumbnailError = $record->thumbnail_error;
|
||||
$this->feedback = $record->versions()->count() === $before && filled($record->thumbnail_path)
|
||||
? 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.'
|
||||
: ($record->thumbnail_error ?: 'Das Vorschaubild wurde nicht übernommen.');
|
||||
$this->feedback = $this->previewFeedback($record, $before);
|
||||
}
|
||||
|
||||
protected function previewFeedback(Composition $record, int $versionsBefore): string
|
||||
{
|
||||
if ($record->versions()->count() !== $versionsBefore) {
|
||||
return 'Das Vorschaubild wurde nicht übernommen.';
|
||||
}
|
||||
|
||||
if (filled($record->thumbnail_path) && $record->thumbnail_error === null) {
|
||||
return 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
if (config('queue.default') !== 'sync') {
|
||||
return 'Das Titelbild wird vorbereitet. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
return $record->thumbnail_error ?: 'Das Vorschaubild wurde nicht übernommen.';
|
||||
}
|
||||
|
||||
protected function statusSentence(): string
|
||||
|
||||
Reference in new issue
Block a user