Führe die gemeinsame Bestandsliste für Arbeitsplatz, Module, Programme und Medien ein.
CI Feature / test (push) Successful in 59s
Deploy Test / test (push) Successful in 54s
Deploy Test / deploy (push) Successful in 23s

Dokument 14 §3 und §9: eine gepflegte Liste statt Kartenwand, Filterwand und
Filament-Tabellen.

- Gemeinsamer Eintrag x-vw.eintrag (Vorschau, Titel, Typzeile), genutzt vom
  Picker und von allen Listen.
- Ansicht verwaltung/bestand mit Trait ShowsBestand: Suche, wenige sichtbare
  Filter, „Weitere Filter“, aktive Filter als entfernbare Chips mit „Alle
  zurücksetzen“, Trefferzahl, Zeilen mit Zustand und benannten Aktionen,
  Kacheln als Option, „Weitere anzeigen“ in Schritten von 50, Leerzustand und
  eigener Dialogbereich (sonst öffnen „… anlegen“-Dialoge nicht).
- Arbeitsplatz, „Module“ und „Programme“ zeigen dieselben Zeilen
  (ListsCompositions); die Listen mit festem Typ. Ein Anlegedialog für Module
  und Programme statt Inline-Feldern und eines zweiten Filament-Dialogs; die
  Anlage nutzt wie bisher EditorialCatalog::create.
- Medien: Suche, Technische Art, Freigabe und Verwendung sichtbar, die übrigen
  acht Filter unter „Weitere Filter“; alle Adressnamen bleiben. Grundansicht ist
  jetzt die Liste (Dokument 14: kompakte Listen), Kacheln bleiben wählbar.
- Hauptknöpfe im Filament-Seitenkopf im Verwaltungsgrün.
- Entfernt: media/library, media/card, media/mark (ersetzt).

Tests bewusst angepasst: Die Medienliste öffnet als Liste; das Ersatzsymbol
nennt die Art über data-symbol.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-20 08:20:57 +01:00
1 parent f846c0b2ee
commit 532979aa86
19 files changed
+948 -557

No files matched your search

+13 -204
View File
@@ -2,20 +2,21 @@
namespace App\Filament\Pages;
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 App\Filament\Support\ListsCompositions;
use Filament\Pages\Page;
use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable;
use Livewire\Attributes\Url;
/**
* Arbeitsplatz: Programme und Module in der gemeinsamen Bestandsliste. Die Listen „Module“ und „Programme“ zeigen
* dieselben Zeilen mit festem Typ (ListsCompositions).
*/
class EditorialDesk extends Page
{
use ListsCompositions;
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
protected static ?string $navigationLabel = 'Arbeitsplatz';
@@ -28,24 +29,6 @@ class EditorialDesk extends Page
protected string $view = 'filament.editorial.desk-page';
#[Url]
public string $query = '';
#[Url]
public string $kindFilter = 'alle';
#[Url]
public string $pillar = '';
#[Url]
public string $visibility = 'alle';
public string $programName = '';
public string $moduleName = '';
public string $feedback = '';
public function getHeading(): string|Htmlable|null
{
return 'Programme und Module';
@@ -53,7 +36,7 @@ public function getHeading(): string|Htmlable|null
public function getSubheading(): string|Htmlable|null
{
return 'Vorhandene Einträge öffnen oder einen neuen anlegen. Technische Kennungen sind dafür nicht nötig.';
return 'Vorhandene Einträge öffnen oder einen neuen anlegen. Ein Programm ordnet Module; ein Modul ordnet Medien und Texte.';
}
public function getMaxContentWidth(): Width|string|null
@@ -66,185 +49,11 @@ public static function canAccess(): bool
return ContentElementResource::editor();
}
/**
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
*/
public function dimensionFilters(): array
protected function getHeaderActions(): 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.members.contentElementVersion.element'])
->orderBy('designation')
->get();
foreach ($compositions as $composition) {
$kind = $composition->kind instanceof CompositionKind
? $composition->kind
: CompositionKind::from((string) $composition->kind);
if ($this->kindFilter === 'programm' && $kind !== CompositionKind::Kurs) {
continue;
}
if ($this->kindFilter === 'modul' && $kind !== CompositionKind::Uebung) {
continue;
}
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
continue;
}
$stand = $catalog->stand($composition);
if (! $this->matchesVisibility($stand)) {
continue;
}
$title = $catalog->compositionTitle($composition);
$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' => $kind->deskLabel(),
'tone' => $kind === CompositionKind::Kurs ? 'programm' : 'modul',
'summary' => $summary,
'url' => EditorialCatalog::editUrl($composition),
'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);
}
public function createModule(): void
{
$this->create(CompositionKind::Uebung, $this->moduleName);
}
private function create(CompositionKind $kind, string $name): void
{
$name = trim($name);
if ($name === '') {
$this->feedback = 'Der Name fehlt.';
return;
}
$composition = app(EditorialCatalog::class)->create($name, $kind);
$this->redirect(EditorialCatalog::editUrl($composition), navigate: false);
return [
$this->createCompositionAction(CompositionKind::Uebung),
$this->createCompositionAction(CompositionKind::Kurs),
];
}
}
@@ -4,38 +4,68 @@
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\ListsCompositions;
use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ListRecords;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable;
/**
* Listen „Module“ und „Programme“: dieselbe Bestandsliste wie der Arbeitsplatz, mit festem Typ. Fachliche
* Kombinationen behalten vorerst ihre Tabelle (Teil B, Abschnitt 3).
*/
abstract class ListCompositionKind extends ListRecords
{
use ListsCompositions;
use ReportsDomainRules;
abstract protected function kind(): CompositionKind;
protected function fixedKind(): ?CompositionKind
{
return $this->kind();
}
private function usesBestand(): bool
{
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true);
}
public function getSubheading(): string|Htmlable|null
{
$desk = in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true)
? ' Programme und Module liegen gemeinsam auf dem Arbeitsplatz.'
: '';
$desk = $this->usesBestand() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
return $this->kind()->deskExplanation().$desk;
}
public function getMaxContentWidth(): Width|string|null
{
return $this->usesBestand() ? Width::Full : parent::getMaxContentWidth();
}
public function content(Schema $schema): Schema
{
if (! $this->usesBestand()) {
return parent::content($schema);
}
return $schema->components([View::make('filament.verwaltung.bestand')]);
}
protected function getHeaderActions(): array
{
if ($this->usesBestand()) {
return [$this->createCompositionAction($this->kind())];
}
return [
Action::make('create')
->label(match ($this->kind()) {
CompositionKind::Kurs => 'Programm anlegen',
CompositionKind::Uebung => 'Modul anlegen',
default => $this->kind()->createLabel(),
})
->label($this->kind()->createLabel())
->visible(fn (): bool => ContentElementResource::editor())
->schema([
TextInput::make('designation')->label('Bezeichnung')->required(),
@@ -44,16 +74,6 @@ protected function getHeaderActions(): array
$composition = null;
$this->report(function () use ($data, &$composition): void {
$composition = app(ContentService::class)->createComposition($data['designation'], $this->kind());
$slug = match ($this->kind()) {
CompositionKind::Kurs => 'programm',
CompositionKind::Uebung => 'modul',
default => null,
};
$editorial = $slug === null ? null : EditorialContentKind::query()->where('slug', $slug)->first();
if ($editorial !== null) {
$composition->editorial_content_kind_id = $editorial->id;
$composition->save();
}
}, $this->kind()->label().' ist angelegt.');
if ($composition !== null) {
@@ -4,9 +4,11 @@
use App\Domain\Catalog\EditorialContentKind;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\Bestand;
use App\Filament\Support\MediaLibrary;
use App\Filament\Support\MediumForm;
use App\Filament\Support\ReportsDomainRules;
use App\Filament\Support\ShowsBestand;
use Filament\Actions\Action;
use Filament\Resources\Pages\ListRecords;
use Filament\Schemas\Components\RenderHook;
@@ -20,14 +22,16 @@
class ListContentElements extends ListRecords
{
use ReportsDomainRules;
use ShowsBestand;
protected static string $resource = ContentElementResource::class;
#[Url(as: 'suche', except: '')]
public string $suche = '';
#[Url(as: 'ansicht', except: 'kacheln')]
public string $ansicht = 'kacheln';
/** Dokument 14 §3: kompakte Liste als Grundansicht; Kacheln bleiben wählbar. */
#[Url(as: 'ansicht', except: 'liste')]
public string $ansicht = 'liste';
#[Url(as: 'art', except: '')]
public string $art = '';
@@ -72,9 +76,8 @@ public function getMaxContentWidth(): Width|string|null
public function content(Schema $schema): Schema
{
return $schema->components([
$this->getTabsContentComponent(),
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
View::make('filament.media.library'),
View::make('filament.verwaltung.bestand'),
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
]);
}
@@ -152,6 +155,101 @@ public function resetFilters(): void
$this->inhaltsart = '';
$this->verarbeitung = '';
$this->archiv = 'aktiv';
$this->bestandGrenze = Bestand::SCHRITT;
}
/**
* Gemeinsame Bestandsliste: Suche und häufige Filter sichtbar, die übrigen unter „Weitere Filter“.
*
* @return array<string, mixed>
*/
public function bestand(): array
{
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
->all();
$weitere = [
['eigenschaft' => 'inhaltsart', 'label' => 'Fachliche Materialart', 'vorgabe' => '', 'alle' => 'Alle Materialarten', 'optionen' => $this->contentKindOptions()],
['eigenschaft' => 'entwurf', 'label' => 'Entwurf', 'vorgabe' => '', 'alle' => 'Entwurf egal', 'optionen' => ['offen' => 'Offener Entwurf', 'keiner' => 'Kein offener Entwurf']],
['eigenschaft' => 'fassung', 'label' => 'Deaktivierte Fassungen', 'vorgabe' => '', 'alle' => 'Regulärer Bestand', 'optionen' => ['mit' => 'Mit deaktivierter Fassung', 'nur' => 'Nur deaktivierte Fassungen']],
];
if (($pillars = $this->pillarOptions()) !== []) {
$weitere[] = ['eigenschaft' => 'saeule', 'label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $optionen($pillars, 'id', 'name')];
}
if (($classes = $this->classificationOptions()) !== []) {
$weitere[] = ['eigenschaft' => 'einordnung', 'label' => 'Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'optionen' => $optionen($classes, 'id', 'label')];
}
$weitere[] = ['eigenschaft' => 'verarbeitung', 'label' => 'Verarbeitung', 'vorgabe' => '', 'alle' => 'Verarbeitung egal', 'optionen' => ['fehler' => 'Verarbeitungsfehler', 'uebernahme' => 'Datei wird übernommen']];
$weitere[] = ['eigenschaft' => 'archiv', 'label' => 'Archiv', 'vorgabe' => 'aktiv', 'optionen' => ['aktiv' => 'Aktive Medien', 'archiviert' => 'Archivierte Medien', 'alle' => 'Auch archivierte']];
return [
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
'filter' => [
['eigenschaft' => 'art', 'label' => 'Technische Art', 'vorgabe' => '', 'alle' => 'Alle Arten', 'optionen' => $optionen($this->typeOptions(), 'value', 'label')],
['eigenschaft' => 'freigabe', 'label' => 'Freigabe', 'vorgabe' => '', 'alle' => 'Alle Freigaben', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
['eigenschaft' => 'nutzung', 'label' => 'Verwendung', 'vorgabe' => '', 'alle' => 'Verwendung egal', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
],
'weitere' => $weitere,
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Deaktivierte und archivierte Medien bleiben über „Weitere Filter“ auffindbar.',
'zeilen' => array_map($this->zeile(...), $this->cards()),
'einheit' => ['Medium', 'Medien'],
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
'ansicht' => 'ansicht',
];
}
/**
* @param array<string, mixed> $card
* @return array<string, mixed>
*/
private function zeile(array $card): array
{
$chips = [['label' => $card['stand'], 'ton' => match ($card['standTone']) {
'ready' => 'gut',
'draft' => 'offen',
'blocked' => 'achtung',
default => 'leise',
}]];
foreach ([['draftNote', 'offen'], ['blockedNote', 'achtung'], ['processing', 'offen'], ['versionLabel', 'leise']] as [$feld, $ton]) {
if (filled($card[$feld] ?? null)) {
$chips[] = ['label' => (string) $card[$feld], 'ton' => $ton];
}
}
if ($card['archived']) {
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
}
return [
'schluessel' => 'm'.$card['id'],
'titel' => $card['title'],
'meta' => $card['type'].(filled($card['editorialKind'] ?? null) ? ' · '.$card['editorialKind'] : ''),
'text' => $card['description'],
'bild' => $card['image'],
'bildAlt' => $card['imageAlt'],
'symbol' => match ($card['typeKey']) {
'film' => 'film',
'bild' => 'bild',
'audio' => 'audio',
default => 'dokument',
},
'url' => $card['url'],
'chips' => $chips,
'hinweise' => array_values(array_filter([
$card['imageNote'] ? 'Vorschaubild: '.$card['imageNote'] : null,
$card['usageNote'] ? 'Einsatz: '.$card['usageNote'] : null,
$card['licenseNote'] ? 'Interner Lizenzvermerk: '.$card['licenseNote'] : null,
])),
'zusatz' => ['view' => 'filament.media.usages', 'daten' => ['card' => $card]],
'aktionen' => array_values(array_filter([
['label' => 'Ansehen', 'href' => $card['url'], 'icon' => 'auge'],
$card['editUrl'] ? ['label' => 'Redaktion', 'href' => $card['editUrl'], 'icon' => 'stift'] : null,
])),
];
}
/**
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Support;
/**
* Werte der gemeinsamen Bestandsliste (ShowsBestand, Ansicht filament.verwaltung.bestand).
*/
final class Bestand
{
/** So viele Einträge zeigt eine Liste zunächst und je „Weitere anzeigen“. */
public const SCHRITT = 50;
}
+281
View File
@@ -0,0 +1,281 @@
<?php
namespace App\Filament\Support;
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 Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Livewire\Attributes\Url;
/**
* Eine Liste für Programme und Module (Arbeitsplatz, „Module“, „Programme“): dieselben Zeilen, Filter und derselbe
* Anlegedialog. Seiten mit festem Typ setzen fixedKind(); der Arbeitsplatz zeigt beide Arten mit Umschalter.
*/
trait ListsCompositions
{
use ShowsBestand;
#[Url]
public string $query = '';
#[Url]
public string $kindFilter = 'alle';
#[Url]
public string $pillar = '';
#[Url]
public string $visibility = 'alle';
protected function fixedKind(): ?CompositionKind
{
return null;
}
public function resetFilters(): void
{
$this->query = '';
$this->kindFilter = 'alle';
$this->pillar = '';
$this->visibility = 'alle';
$this->bestandGrenze = Bestand::SCHRITT;
}
public function hasActiveFilters(): bool
{
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
}
/**
* @return array<string, mixed>
*/
public function bestand(): array
{
$fixed = $this->fixedKind();
$einheit = match ($fixed) {
CompositionKind::Kurs => ['Programm', 'Programme'],
CompositionKind::Uebung => ['Modul', 'Module'],
default => ['Programm oder Modul', 'Programme und Module'],
};
$gruppen = [];
foreach ($this->dimensionFilters() as $gruppe) {
$optionen = [];
foreach ($gruppe['values'] as $value) {
$optionen[(string) $value['id']] = $value['label'];
}
$gruppen[] = ['label' => $gruppe['label'], 'optionen' => $optionen];
}
return [
'suche' => ['eigenschaft' => 'query', 'label' => 'Suche', 'platzhalter' => 'Titel oder Kurzbeschreibung'],
'segmente' => $fixed === null ? [[
'eigenschaft' => 'kindFilter', 'label' => 'Art', 'vorgabe' => 'alle',
'optionen' => ['alle' => 'Alle', 'programm' => 'Programme', 'modul' => 'Module'],
]] : [],
'filter' => [[
'eigenschaft' => 'visibility', 'label' => 'Stand', 'vorgabe' => 'alle',
'optionen' => ['alle' => 'Jeder Stand', 'bibliothek' => 'In der Mitgliederbibliothek', 'verborgen' => 'Nicht in der Mitgliederbibliothek', 'entwurf' => 'Noch ohne Fassung'],
]],
'weitere' => $gruppen === [] ? [] : [[
'eigenschaft' => 'pillar', 'label' => 'Fachliche Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'gruppen' => $gruppen,
]],
'zeilen' => $this->entries(),
'einheit' => $einheit,
'leer' => [
'titel' => 'Noch keine '.$einheit[1],
'text' => 'Mit „'.($fixed === CompositionKind::Kurs ? 'Programm' : 'Modul').' anlegen“ oben entsteht der erste Eintrag. Der Name genügt.',
],
];
}
/**
* @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;
}
/**
* Zeilen der gemeinsamen Bestandsliste.
*
* @return list<array<string, mixed>>
*/
public function entries(): array
{
$needle = mb_strtolower(trim($this->query));
$catalog = app(EditorialCatalog::class);
$offered = $catalog->offeredCompositionIds();
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
$fixed = $this->fixedKind();
$kinds = $fixed !== null ? [$fixed] : match ($this->kindFilter) {
'programm' => [CompositionKind::Kurs],
'modul' => [CompositionKind::Uebung],
default => [CompositionKind::Kurs, CompositionKind::Uebung],
};
$canEdit = ContentElementResource::editor();
$rows = [];
$compositions = Composition::query()
->whereIn('kind', $kinds)
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
->orderBy('designation')
->get();
foreach ($compositions as $composition) {
$kind = $composition->kind instanceof CompositionKind
? $composition->kind
: CompositionKind::from((string) $composition->kind);
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
continue;
}
$stand = $catalog->stand($composition);
if (! $this->matchesVisibility($stand)) {
continue;
}
$title = $catalog->compositionTitle($composition);
$summary = trim((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));
$url = EditorialCatalog::editUrl($composition);
$rows[] = [
'schluessel' => 'c'.$composition->id,
'titel' => $title,
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : ''),
'text' => $summary,
'bild' => $cover['url'],
'bildFehlt' => 'Kein Titelbild',
'hinweise' => filled($cover['note']) ? ['Bild: '.$cover['note']] : [],
'symbol' => 'modul',
'url' => $url,
'chips' => array_map(fn (array $chip): array => [
'label' => $chip['label'],
'ton' => match ($chip['tone']) {
'pine' => 'gut',
'yellow' => 'offen',
'quiet' => 'leise',
default => 'neutral',
},
], $catalog->statusChips($composition, in_array($composition->id, $offered, true))),
'aktionen' => array_values(array_filter([
['label' => 'Aufbau', 'href' => $url, 'icon' => 'modul'],
$canEdit ? ['label' => 'Redaktion', 'href' => $url.'?redaktion=1', 'icon' => 'stift'] : null,
])),
];
}
return $rows;
}
/**
* Anlegedialog für Module und Programme; derselbe auf dem Arbeitsplatz und in den Listen.
*/
protected function createCompositionAction(CompositionKind $kind): Action
{
$label = $kind === CompositionKind::Kurs ? 'Programm' : 'Modul';
return Action::make($kind === CompositionKind::Kurs ? 'createProgram' : 'createModule')
->label($label.' anlegen')
->modalHeading('Neues '.$label)
->modalDescription('Der Name genügt. Danach öffnet sich der Aufbau; Texte, Bilder und Einordnung folgen dort und in der Redaktion.')
->modalSubmitActionLabel($label.' anlegen')
->modalWidth('lg')
->visible(fn (): bool => ContentElementResource::editor())
->schema([
TextInput::make('designation')->label('Name')->required()->maxLength(255),
])
->action(function (array $data) use ($kind): void {
abort_unless(ContentElementResource::editor(), 403);
$composition = app(EditorialCatalog::class)->create(trim((string) $data['designation']), $kind);
$this->redirect(EditorialCatalog::editUrl($composition), navigate: false);
});
}
/**
* @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) {
$members[] = ['target' => $member->content_element_version_id
? 'element:'.$member->content_element_version_id
: 'composition:'.$member->nested_composition_version_id];
}
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,
};
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Filament\Support;
/**
* Gemeinsame Bestandsliste (Ansicht filament.verwaltung.bestand). Die Seite beschreibt Suche, Filter und Zeilen in
* bestand() und setzt alle Filter in resetFilters() zurück. Die Liste zeigt zunächst Bestand::SCHRITT Einträge; jede
* Filteränderung beginnt wieder oben.
*/
trait ShowsBestand
{
public int $bestandGrenze = Bestand::SCHRITT;
/**
* @return array<string, mixed>
*/
abstract public function bestand(): array;
abstract public function resetFilters(): void;
public function mehrAnzeigen(): void
{
$this->bestandGrenze += Bestand::SCHRITT;
}
public function updatedShowsBestand(string $name): void
{
if ($name !== 'bestandGrenze') {
$this->bestandGrenze = Bestand::SCHRITT;
}
}
}