Zeige Katalogkarten, Titelbilder und klare Freigabestatus im Arbeitsplatz.
Deploy Test / test (push) Successful in 23s
Deploy Test / deploy (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-16 17:54:12 +01:00
1 parent 053a361801
commit 9195cdcd15
15 files changed
+795 -59

No files matched your search

+188 -3
View File
@@ -14,11 +14,14 @@
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\OfferStatus;
use App\Filament\Resources\Combinations\CombinationResource;
use App\Filament\Resources\Courses\CourseResource;
use App\Filament\Resources\Exercises\ExerciseResource;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class EditorialCatalog
{
@@ -447,20 +450,202 @@ public function stand(Composition $composition): array
];
}
$text = 'Fassung '.$latest->number.($release->isReleased($latest) ? ', zur Anzeige freigegeben' : ', noch nicht zur Anzeige freigegeben');
$visible = $released instanceof CompositionVersion;
$text = 'Fassung '.$latest->number.($visible ? ', in der Mitgliederbibliothek' : ', nicht in der Mitgliederbibliothek');
$text = ($draft ? 'Entwurf gespeichert. ' : '').$text;
if ($released instanceof CompositionVersion && $released->number !== $latest->number) {
if ($visible && $released->number !== $latest->number) {
$text .= '. Angezeigt wird Fassung '.$released->number;
}
return [
'text' => $text,
'number' => $latest->number,
'released_number' => $released instanceof CompositionVersion ? $released->number : null,
'released_number' => $visible ? $released->number : null,
];
}
/**
* @return list<array{label: string, tone: string}>
*/
public function statusChips(Composition $composition, bool $offered): array
{
$stand = $this->stand($composition);
$chips = [];
if ($stand['number'] === null) {
$chips[] = [
'label' => str_contains($stand['text'], 'Entwurf') ? 'Entwurf gespeichert' : 'Noch ohne Fassung',
'tone' => 'yellow',
];
} else {
$chips[] = ['label' => 'Fassung '.$stand['number'], 'tone' => 'ink'];
if (str_starts_with($stand['text'], 'Entwurf gespeichert')) {
$chips[] = ['label' => 'Entwurf offen', 'tone' => 'yellow'];
}
$chips[] = $stand['released_number'] !== null
? ['label' => 'In der Mitgliederbibliothek', 'tone' => 'pine']
: ['label' => 'Nicht in der Mitgliederbibliothek', 'tone' => 'quiet'];
if ($stand['released_number'] !== null && $stand['released_number'] !== $stand['number']) {
$chips[] = ['label' => 'Bibliothek zeigt Fassung '.$stand['released_number'], 'tone' => 'pine'];
}
}
$chips[] = ['label' => 'Nicht auf der Website', 'tone' => 'quiet'];
$chips[] = $offered
? ['label' => 'Angebot aktiv', 'tone' => 'pine']
: ['label' => 'Kein aktives Angebot', 'tone' => 'quiet'];
return $chips;
}
/**
* @return list<int>
*/
public function offeredCompositionIds(): array
{
$articleIds = DB::table('resolved_scopes')
->join('offer_versions', 'offer_versions.id', '=', 'resolved_scopes.offer_version_id')
->where('offer_versions.status', OfferStatus::Aktiv->value)
->pluck('resolved_scopes.license_article_id');
if ($articleIds->isEmpty()) {
return [];
}
$releaseIds = LicenseArticle::query()
->whereIn('id', $articleIds)
->whereNotNull('current_release_id')
->pluck('current_release_id');
$versionIds = ArticleRelease::query()
->whereIn('id', $releaseIds)
->whereNotNull('root_composition_version_id')
->pluck('root_composition_version_id');
return CompositionVersion::query()
->whereIn('id', $versionIds)
->pluck('composition_id')
->map(fn (mixed $id): int => (int) $id)
->unique()
->values()
->all();
}
/**
* @param list<array<string, mixed>> $members
* @return list<array{id: int, title: string, image: string}>
*/
public function filmPictures(array $members): array
{
$versionIds = [];
foreach ($members as $member) {
$target = (string) ($member['target'] ?? '');
if (preg_match('/^element:(\d+)$/', $target, $match) === 1) {
$versionIds[] = (int) $match[1];
}
}
if ($versionIds === []) {
return [];
}
$pictures = [];
foreach (ContentElementVersion::query()->with('element')->whereIn('id', $versionIds)->get() as $version) {
$element = $version->element;
if (! $element instanceof ContentElement || $element->output_class !== 'film') {
continue;
}
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
if ($image === null || isset($pictures[$element->id])) {
continue;
}
$pictures[$element->id] = [
'id' => $element->id,
'title' => filled($element->display_title) ? $element->display_title : $element->working_title,
'image' => $image,
];
}
return array_values($pictures);
}
/**
* @return list<array{id: int, title: string, image: string, kind: string}>
*/
public function mediaPictures(string $query): array
{
$query = trim($query);
if (mb_strlen($query) < 2) {
return [];
}
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
return ContentElement::query()
->where('thumbnail_path', 'like', 'vorschau/%')
->where(function ($builder) use ($like): void {
$builder->where('working_title', 'like', $like)
->orWhere('display_title', 'like', $like)
->orWhere('summary', 'like', $like);
})
->orderBy('working_title')
->limit(12)
->get()
->map(function (ContentElement $element): ?array {
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
if ($image === null) {
return null;
}
return [
'id' => $element->id,
'title' => filled($element->display_title) ? $element->display_title : $element->working_title,
'image' => $image,
'kind' => $element->editorialContentKind?->label ?: $this->outputLabel((string) $element->output_class),
];
})
->filter()
->values()
->all();
}
/**
* @param list<array<string, mixed>> $members
* @return array{url: ?string, note: ?string, own: bool}
*/
public function cover(Composition $composition, array $members): array
{
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path);
if ($own !== null) {
return ['url' => $own, 'note' => null, 'own' => true];
}
$films = $this->filmPictures($members);
if (count($films) === 1) {
return [
'url' => $films[0]['image'],
'note' => 'Vorschlag aus dem Film '.$films[0]['title'],
'own' => false,
];
}
return ['url' => null, 'note' => null, 'own' => false];
}
public function create(string $designation, CompositionKind $kind): Composition
{
$composition = app(ContentService::class)->createComposition($designation, $kind);