- Gemeinsame Katalog-Objektseite (catalog/objekt): Kopf, Hauptabschnitte, Begleitinformation. Angebot, Paket und Rechteprofil nutzen sie; lesbare Bezeichnungen zentral in CatalogLabels. - Paket: eine Maske für erste und geänderte Fassung, bei einer Änderung mit der neuesten veröffentlichten Fassung vorbelegt; Wirkung unverändert BundleService::publish (frühere Fassungen bleiben veröffentlicht). - Rechteprofil: erlaubte Handlungen lesbar, Verwendung in Angeboten, Fassungen; der doppelte Titel „… ansehen ansehen“ entfällt. - Fachliche Säulen, Fachliche Kombinationen und Benutzer in der gemeinsamen Bestandsliste; Säulen mit Website-Zustand und Medienzahl, Konten mit Status und Rollen. - Gefüllte Filament-Hauptknöpfe überall im Verwaltungsgrün (auch Formularfuß, etwa „Speichern“ der Säule). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
4.3 KiB
PHP
108 lines
4.3 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\CatalogLabels;
|
|
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;
|
|
|
|
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(CatalogLabels::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 = CatalogLabels::faehigkeiten($version?->capabilities);
|
|
$purpose = CatalogLabels::zweck($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.'];
|
|
}
|
|
}
|