'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.']; } }