- „Geänderte Fassung aktivieren“ übernimmt Inhaberart, Laufzeitregel, Steuerklasse und „dynamisch“ aus der aktiven Fassung. Bisher wurden sie still auf Person/dauerhaft zurückgesetzt, obwohl die Maske „vorbelegt“ sagte. Ohne aktive Fassung gilt wie bisher die Vorgabe. - Nur Such- und Filteränderungen lassen die Liste wieder oben beginnen; Eingaben in einem geöffneten Anlegedialog klappen „Weitere anzeigen“ nicht mehr zu. - Test: Kombinationen öffnen Aufbau und Redaktion aus der Liste. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
302 lines
12 KiB
PHP
302 lines
12 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\ContentElements\Pages;
|
|
|
|
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;
|
|
use Filament\Schemas\Components\View;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Enums\Width;
|
|
use Filament\View\PanelsRenderHook;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
use Livewire\Attributes\Url;
|
|
|
|
class ListContentElements extends ListRecords
|
|
{
|
|
use ReportsDomainRules;
|
|
use ShowsBestand;
|
|
|
|
protected static string $resource = ContentElementResource::class;
|
|
|
|
#[Url(as: 'suche', except: '')]
|
|
public string $suche = '';
|
|
|
|
/** 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 = '';
|
|
|
|
#[Url(as: 'freigabe', except: '')]
|
|
public string $freigabe = '';
|
|
|
|
#[Url(as: 'entwurf', except: '')]
|
|
public string $entwurf = '';
|
|
|
|
#[Url(as: 'fassung', except: '')]
|
|
public string $fassung = '';
|
|
|
|
#[Url(as: 'nutzung', except: '')]
|
|
public string $nutzung = '';
|
|
|
|
#[Url(as: 'saeule', except: '')]
|
|
public string $saeule = '';
|
|
|
|
#[Url(as: 'inhaltsart', except: '')]
|
|
public string $inhaltsart = '';
|
|
|
|
#[Url(as: 'einordnung', except: '')]
|
|
public string $einordnung = '';
|
|
|
|
#[Url(as: 'verarbeitung', except: '')]
|
|
public string $verarbeitung = '';
|
|
|
|
#[Url(as: 'archiv', except: 'aktiv')]
|
|
public string $archiv = 'aktiv';
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Die Dateien und Texte. Ein Modul oder ein Programm verweist auf eine Fassung; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
|
}
|
|
|
|
public function getMaxContentWidth(): Width|string|null
|
|
{
|
|
return Width::Full;
|
|
}
|
|
|
|
public function content(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
|
|
View::make('filament.verwaltung.bestand'),
|
|
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
|
|
]);
|
|
}
|
|
|
|
protected function bestandFilterEigenschaften(): array
|
|
{
|
|
return ['suche', 'art', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
|
}
|
|
|
|
public function showingList(): bool
|
|
{
|
|
return $this->ansicht === 'liste';
|
|
}
|
|
|
|
/**
|
|
* @return list<array<string, mixed>>
|
|
*/
|
|
public function cards(): array
|
|
{
|
|
return app(MediaLibrary::class)->cards($this->libraryFilters(), ContentElementResource::editor());
|
|
}
|
|
|
|
/**
|
|
* @return list<array{value: string, label: string}>
|
|
*/
|
|
public function typeOptions(): array
|
|
{
|
|
return app(MediaLibrary::class)->types();
|
|
}
|
|
|
|
/**
|
|
* @return list<array{id: int, name: string}>
|
|
*/
|
|
public function pillarOptions(): array
|
|
{
|
|
return app(MediaLibrary::class)->pillars();
|
|
}
|
|
|
|
/**
|
|
* @return list<array{id: int, label: string}>
|
|
*/
|
|
public function classificationOptions(): array
|
|
{
|
|
return app(MediaLibrary::class)->classifications();
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public function contentKindOptions(): array
|
|
{
|
|
return EditorialContentKind::selectOptions();
|
|
}
|
|
|
|
public function filtersActive(): bool
|
|
{
|
|
return trim($this->suche) !== ''
|
|
|| $this->art !== ''
|
|
|| $this->freigabe !== ''
|
|
|| $this->entwurf !== ''
|
|
|| $this->fassung !== ''
|
|
|| $this->nutzung !== ''
|
|
|| $this->saeule !== ''
|
|
|| $this->einordnung !== ''
|
|
|| $this->inhaltsart !== ''
|
|
|| $this->verarbeitung !== ''
|
|
|| $this->archiv !== 'aktiv';
|
|
}
|
|
|
|
public function resetFilters(): void
|
|
{
|
|
$this->suche = '';
|
|
$this->art = '';
|
|
$this->freigabe = '';
|
|
$this->entwurf = '';
|
|
$this->fassung = '';
|
|
$this->nutzung = '';
|
|
$this->saeule = '';
|
|
$this->einordnung = '';
|
|
$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,
|
|
])),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
private function libraryFilters(): array
|
|
{
|
|
return [
|
|
'suche' => $this->suche,
|
|
'art' => $this->art,
|
|
'freigabe' => $this->freigabe,
|
|
'entwurf' => $this->entwurf,
|
|
'fassung' => $this->fassung,
|
|
'nutzung' => $this->nutzung,
|
|
'saeule' => $this->saeule,
|
|
'einordnung' => $this->einordnung,
|
|
'inhaltsart' => $this->inhaltsart,
|
|
'verarbeitung' => $this->verarbeitung,
|
|
'archiv' => $this->archiv,
|
|
];
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')
|
|
->label('Medium anlegen')
|
|
->modalSubmitActionLabel('Medium anlegen')
|
|
->visible(fn (): bool => ContentElementResource::editor())
|
|
->modalDescription('Dieselbe Maske gilt im Medienbestand, im Modul und im Programm. Der Upload zeigt seinen Fortschritt. Beschreibung, Hinweise und Vorschaubild gehören dazu.')
|
|
->schema(fn (): array => MediumForm::fields(creating: true))
|
|
->action(function (array $data): void {
|
|
$element = null;
|
|
$this->report(function () use ($data, &$element): void {
|
|
$element = MediumForm::create($data, hold: false);
|
|
}, 'Das Medium ist angelegt.');
|
|
|
|
if ($element !== null) {
|
|
$this->redirect(ContentElementResource::getUrl('view', ['record' => $element]));
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
}
|