- 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>
132 lines
5.1 KiB
PHP
132 lines
5.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\RightsProfiles\Pages;
|
|
|
|
use App\Domain\Catalog\OfferService;
|
|
use App\Domain\Catalog\RightsProfile;
|
|
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
|
use App\Filament\Support\ListsCatalog;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\CheckboxList;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
|
|
class ListRightsProfiles extends ListRecords
|
|
{
|
|
use ListsCatalog;
|
|
use ReportsDomainRules;
|
|
|
|
/** Lesbare Fähigkeiten; dieselben Werte wie im Anlegedialog. */
|
|
public const FAEHIGKEITEN = [
|
|
'film:streamen' => 'Film ansehen',
|
|
'film:laden' => 'Film herunterladen',
|
|
'audio:streamen' => 'Hörstück ansehen',
|
|
'document:ansehen' => 'Dokument ansehen',
|
|
'document:laden' => 'Dokument herunterladen',
|
|
'pdf:ansehen' => 'PDF ansehen',
|
|
'pdf:laden' => 'PDF herunterladen',
|
|
'text:ansehen' => 'Text ansehen',
|
|
'bild:ansehen' => 'Bild ansehen',
|
|
];
|
|
|
|
protected static string $resource = RightsProfileResource::class;
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Ein Rechteprofil beschreibt den Zweck und die erlaubten Handlungen. Es wird nicht verkauft; ein Angebot verbindet es mit Artikeln.';
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')->label('Rechteprofil anlegen')
|
|
->modalHeading('Neues Rechteprofil')
|
|
->modalDescription('Zweck und erlaubte Handlungen. Ein Angebot verbindet das Profil später mit Artikeln.')
|
|
->modalSubmitActionLabel('Rechteprofil anlegen')
|
|
->schema([
|
|
TextInput::make('name')->label('Name')->required(),
|
|
Select::make('purpose')->label('Zweck')->options([
|
|
'ehrenamtlich' => 'Ehrenamtlich',
|
|
'kommerziell' => 'Kommerziell',
|
|
'institutionell' => 'Institutionell',
|
|
])->required(),
|
|
CheckboxList::make('capabilities')->label('Fähigkeiten')->options(self::FAEHIGKEITEN)->required(),
|
|
])->action(function (array $data): void {
|
|
$this->report(function () use ($data): void {
|
|
$capabilities = [];
|
|
|
|
foreach ($data['capabilities'] as $entry) {
|
|
[$class, $action] = explode(':', $entry, 2);
|
|
$capabilities[$class][] = $action;
|
|
}
|
|
|
|
app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities);
|
|
}, 'Das Rechteprofil ist angelegt.');
|
|
}),
|
|
];
|
|
}
|
|
|
|
protected function catalogRows(): array
|
|
{
|
|
$rows = [];
|
|
|
|
foreach (RightsProfile::query()->with('versions')->orderBy('name')->get() as $profile) {
|
|
$version = $profile->versions->sortByDesc('number')->first();
|
|
$faehigkeiten = [];
|
|
|
|
foreach ($version?->capabilities ?? [] as $class => $actions) {
|
|
foreach ((array) $actions as $action) {
|
|
$faehigkeiten[] = self::FAEHIGKEITEN[$class.':'.$action] ?? $class.': '.$action;
|
|
}
|
|
}
|
|
|
|
$purpose = match ((string) $version?->purpose) {
|
|
'ehrenamtlich' => 'Ehrenamtlich',
|
|
'kommerziell' => 'Kommerziell',
|
|
'institutionell' => 'Institutionell',
|
|
default => (string) $version?->purpose,
|
|
};
|
|
$chips = $version === null
|
|
? [['label' => 'Noch keine Fassung', 'ton' => 'offen']]
|
|
: [['label' => 'Fassung '.$version->number, 'ton' => 'neutral'], ['label' => $purpose, 'ton' => 'leise']];
|
|
|
|
if ($version?->locked_at !== null) {
|
|
$chips[] = ['label' => 'Festgeschrieben', 'ton' => 'leise'];
|
|
}
|
|
|
|
$url = RightsProfileResource::getUrl('view', ['record' => $profile]);
|
|
$rows[] = [
|
|
'schluessel' => 'r'.$profile->id,
|
|
'titel' => $profile->name,
|
|
'meta' => 'Rechteprofil',
|
|
'text' => $faehigkeiten === [] ? 'Keine Fähigkeiten' : implode(', ', $faehigkeiten),
|
|
'symbol' => 'schluessel',
|
|
'url' => $url,
|
|
'chips' => $chips,
|
|
'zustand' => [(string) $version?->purpose],
|
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
|
];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
|
|
protected function zustandOptionen(): array
|
|
{
|
|
return ['alle' => 'Jeder Zweck', 'ehrenamtlich' => 'Ehrenamtlich', 'kommerziell' => 'Kommerziell', 'institutionell' => 'Institutionell'];
|
|
}
|
|
|
|
protected function einheit(): array
|
|
{
|
|
return ['Rechteprofil', 'Rechteprofile'];
|
|
}
|
|
|
|
protected function leer(): array
|
|
{
|
|
return ['titel' => 'Noch keine Rechteprofile', 'text' => 'Mit „Rechteprofil anlegen“ oben entsteht das erste Profil.'];
|
|
}
|
|
}
|