Texte, Materialart und Präsentationsmedien bleiben am Medium, Modul, Programm und Lizenzartikel und werden von Verwaltung und Karten aus derselben Quelle gelesen, ohne Fassung oder Lizenz zu verändern. Co-authored-by: Cursor <cursoragent@cursor.com>
198 lines
5.7 KiB
PHP
198 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\ContentElements\Pages;
|
|
|
|
use App\Domain\Catalog\EditorialContentKind;
|
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
|
use App\Filament\Support\MediaLibrary;
|
|
use App\Filament\Support\MediumForm;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
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;
|
|
|
|
protected static string $resource = ContentElementResource::class;
|
|
|
|
#[Url(as: 'suche', except: '')]
|
|
public string $suche = '';
|
|
|
|
#[Url(as: 'ansicht', except: 'kacheln')]
|
|
public string $ansicht = 'kacheln';
|
|
|
|
#[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([
|
|
$this->getTabsContentComponent(),
|
|
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
|
|
View::make('filament.media.library'),
|
|
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
|
|
]);
|
|
}
|
|
|
|
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';
|
|
}
|
|
|
|
/**
|
|
* @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')
|
|
->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]));
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
}
|