- Lizenzartikel, Pakete, Rechteprofile und Angebote nutzen die gemeinsame Bestandsliste (ListsCatalog): Suche, Zustandsfilter, lesbare Zustände aus vorhandenen Daten statt „Aktueller Stand: 1“ oder „Fassungen: aktiv“ (Stand veröffentlicht/in Arbeit/gesperrt, in aktivem Angebot, Fassung aktiv mit Vergabe und Preis, Bestandteile, Zweck und Fähigkeiten). Lizenzartikel zeigen ihr Titelbild. - Anlegedialoge benennen Zweck und Bestätigung und öffnen danach den neuen Eintrag, statt in der Liste stehen zu bleiben. - Angebot im gemeinsamen Rahmen (Kopf, Positionen, aufgelöster Leistungsumfang, Fassungsverlauf). Eine Maske für Anlegen und Ändern (FACH-20): „Fassung aktivieren“ bzw. „Geänderte Fassung aktivieren“, bei einer Änderung mit der aktiven Fassung vorbelegt (FACH-08). Wirkung unverändert OfferService::activate: die bisherige Fassung wird beendet und bleibt gespeichert. „Als Vorlage verwenden“ (FACH-09) bleibt offen (OFF-04). - Entfernt: editorial/catalog-card (ersetzt). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
112 lines
4.2 KiB
PHP
112 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Bundles\Pages;
|
|
|
|
use App\Domain\Catalog\Bundle;
|
|
use App\Domain\Catalog\BundleService;
|
|
use App\Domain\Catalog\BundleStatus;
|
|
use App\Domain\Catalog\StatusValue;
|
|
use App\Filament\Resources\Bundles\BundleResource;
|
|
use App\Filament\Support\ListsCatalog;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
|
|
class ListBundles extends ListRecords
|
|
{
|
|
use ListsCatalog;
|
|
use ReportsDomainRules;
|
|
|
|
protected static string $resource = BundleResource::class;
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Ein Paket stellt Lizenzartikel und andere Pakete zusammen. Öffne es, um Bestandteile und die aufgelösten Artikel zu sehen.';
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')->label('Paket anlegen')
|
|
->modalHeading('Neues Paket')
|
|
->modalDescription('Der Name genügt. Bestandteile stellst du danach am Paket zusammen.')
|
|
->modalSubmitActionLabel('Paket anlegen')
|
|
->schema([
|
|
TextInput::make('name')->label('Name')->required(),
|
|
])->action(function (array $data): void {
|
|
$bundle = null;
|
|
$this->report(function () use ($data, &$bundle): void {
|
|
$bundle = app(BundleService::class)->create($data['name']);
|
|
}, 'Das Paket ist angelegt.');
|
|
|
|
if ($bundle instanceof Bundle) {
|
|
$this->redirect(BundleResource::getUrl('view', ['record' => $bundle]));
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
|
|
protected function catalogRows(): array
|
|
{
|
|
$rows = [];
|
|
|
|
foreach (Bundle::query()->with(['versions.items'])->orderBy('name')->get() as $bundle) {
|
|
$versions = $bundle->versions->sortByDesc('number');
|
|
$published = $versions->first(fn ($version): bool => StatusValue::of($version->status) === BundleStatus::Veroeffentlicht->value);
|
|
$draft = $versions->first(fn ($version): bool => StatusValue::of($version->status) === BundleStatus::Entwurf->value);
|
|
$chips = [];
|
|
$zustand = [];
|
|
|
|
if ($published !== null) {
|
|
$chips[] = ['label' => 'Fassung '.$published->number.' veröffentlicht', 'ton' => 'gut'];
|
|
$chips[] = ['label' => $published->items->count() === 1 ? '1 Bestandteil' : $published->items->count().' Bestandteile', 'ton' => 'leise'];
|
|
$zustand[] = 'veroeffentlicht';
|
|
} else {
|
|
$chips[] = ['label' => $versions->isEmpty() ? 'Noch keine Fassung' : 'Noch nicht veröffentlicht', 'ton' => 'offen'];
|
|
$zustand[] = 'ohne';
|
|
}
|
|
|
|
if ($draft !== null) {
|
|
$chips[] = ['label' => 'Fassung '.$draft->number.' in Arbeit', 'ton' => 'offen'];
|
|
$zustand[] = 'entwurf';
|
|
}
|
|
|
|
if ($bundle->archived_at !== null) {
|
|
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
|
|
$zustand[] = 'archiviert';
|
|
}
|
|
|
|
$url = BundleResource::getUrl('view', ['record' => $bundle]);
|
|
$rows[] = [
|
|
'schluessel' => 'p'.$bundle->id,
|
|
'titel' => $bundle->name,
|
|
'meta' => 'Paket',
|
|
'symbol' => 'modul',
|
|
'url' => $url,
|
|
'chips' => $chips,
|
|
'zustand' => $zustand,
|
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
|
];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
|
|
protected function zustandOptionen(): array
|
|
{
|
|
return ['alle' => 'Jeder Zustand', 'veroeffentlicht' => 'Veröffentlicht', 'ohne' => 'Noch nicht veröffentlicht', 'entwurf' => 'Fassung in Arbeit', 'archiviert' => 'Archiviert'];
|
|
}
|
|
|
|
protected function einheit(): array
|
|
{
|
|
return ['Paket', 'Pakete'];
|
|
}
|
|
|
|
protected function leer(): array
|
|
{
|
|
return ['titel' => 'Noch keine Pakete', 'text' => 'Mit „Paket anlegen“ oben entsteht das erste Paket.'];
|
|
}
|
|
}
|