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
@@ -4,6 +4,9 @@
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use Filament\Pages\Page;
|
||||
@@ -31,6 +34,12 @@ class EditorialDesk extends Page
|
||||
#[Url]
|
||||
public string $kindFilter = 'alle';
|
||||
|
||||
#[Url]
|
||||
public string $pillar = '';
|
||||
|
||||
#[Url]
|
||||
public string $visibility = 'alle';
|
||||
|
||||
public string $programName = '';
|
||||
|
||||
public string $moduleName = '';
|
||||
@@ -58,18 +67,55 @@ public static function canAccess(): bool
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{title: string, kind: string, stand: string, url: string, summary: string}>
|
||||
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
||||
*/
|
||||
public function dimensionFilters(): array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||
$values = [];
|
||||
|
||||
foreach ($dimension->values as $value) {
|
||||
$values[] = ['id' => $value->id, 'label' => $value->label];
|
||||
}
|
||||
|
||||
if ($values !== []) {
|
||||
$groups[] = ['label' => $dimension->label, 'values' => $values];
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->query = '';
|
||||
$this->kindFilter = 'alle';
|
||||
$this->pillar = '';
|
||||
$this->visibility = 'alle';
|
||||
}
|
||||
|
||||
public function hasActiveFilters(): bool
|
||||
{
|
||||
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function entries(): array
|
||||
{
|
||||
$query = trim($this->query);
|
||||
$needle = mb_strtolower($query);
|
||||
$catalog = app(EditorialCatalog::class);
|
||||
$offered = $catalog->offeredCompositionIds();
|
||||
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
|
||||
$rows = [];
|
||||
|
||||
$compositions = Composition::query()
|
||||
->whereIn('kind', [CompositionKind::Kurs, CompositionKind::Uebung])
|
||||
->with(['editorialContentKind', 'versions'])
|
||||
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
|
||||
->orderBy('designation')
|
||||
->get();
|
||||
|
||||
@@ -77,7 +123,6 @@ public function entries(): array
|
||||
$kind = $composition->kind instanceof CompositionKind
|
||||
? $composition->kind
|
||||
: CompositionKind::from((string) $composition->kind);
|
||||
$label = $kind->deskLabel();
|
||||
|
||||
if ($this->kindFilter === 'programm' && $kind !== CompositionKind::Kurs) {
|
||||
continue;
|
||||
@@ -87,26 +132,98 @@ public function entries(): array
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stand = $catalog->stand($composition);
|
||||
|
||||
if (! $this->matchesVisibility($stand)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $catalog->compositionTitle($composition);
|
||||
$haystack = mb_strtolower($title.' '.$composition->designation.' '.(string) $composition->summary);
|
||||
$summary = (string) ($composition->summary ?? '');
|
||||
$haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.(string) $composition->description);
|
||||
|
||||
if ($needle !== '' && ! str_contains($haystack, $needle)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cover = $catalog->cover($composition, $this->coverMembers($composition));
|
||||
$rows[] = [
|
||||
'title' => $title,
|
||||
'kind' => $label,
|
||||
'kind' => $kind->deskLabel(),
|
||||
'tone' => $kind === CompositionKind::Kurs ? 'programm' : 'modul',
|
||||
'stand' => $catalog->stand($composition)['text'],
|
||||
'summary' => $summary,
|
||||
'url' => EditorialCatalog::editUrl($composition),
|
||||
'summary' => (string) ($composition->summary ?? ''),
|
||||
'image' => $cover['url'],
|
||||
'image_note' => $cover['note'],
|
||||
'chips' => $catalog->statusChips($composition, in_array($composition->id, $offered, true)),
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{target: string}>
|
||||
*/
|
||||
private function coverMembers(Composition $composition): array
|
||||
{
|
||||
$draft = $composition->working_draft;
|
||||
|
||||
if (is_array($draft) && is_array($draft['members'] ?? null) && $draft['members'] !== []) {
|
||||
return $draft['members'];
|
||||
}
|
||||
|
||||
$version = $composition->versions
|
||||
->filter(fn ($item): bool => $item->status === ContentVersionStatus::Bereit)
|
||||
->sortByDesc('number')
|
||||
->first();
|
||||
|
||||
if ($version === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$members = [];
|
||||
|
||||
foreach ($version->members as $member) {
|
||||
$target = $member->content_element_version_id
|
||||
? 'element:'.$member->content_element_version_id
|
||||
: 'composition:'.$member->nested_composition_version_id;
|
||||
$members[] = ['target' => $target];
|
||||
}
|
||||
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
private function pillarSubjects(int $valueId): array
|
||||
{
|
||||
return IdentityDimensionValue::query()
|
||||
->where('subject_type', (new Composition)->getMorphClass())
|
||||
->where('editorial_dimension_value_id', $valueId)
|
||||
->pluck('subject_id')
|
||||
->map(fn (mixed $id): int => (int) $id)
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{text: string, number: int|null, released_number: int|null} $stand
|
||||
*/
|
||||
private function matchesVisibility(array $stand): bool
|
||||
{
|
||||
return match ($this->visibility) {
|
||||
'bibliothek' => $stand['released_number'] !== null,
|
||||
'verborgen' => $stand['number'] !== null && $stand['released_number'] === null,
|
||||
'entwurf' => $stand['number'] === null,
|
||||
default => true,
|
||||
};
|
||||
}
|
||||
|
||||
public function createProgram(): void
|
||||
{
|
||||
$this->create(CompositionKind::Kurs, $this->programName);
|
||||
|
||||
Reference in new issue
Block a user