Files
laraundfelix/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php
T
LarsandClaude Opus 5.5 51d58ac55c
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 55s
Deploy Test / deploy (push) Successful in 23s
Ordne Paket, Rechteprofil, Säulen, Kombinationen und Benutzer in die gemeinsamen Muster ein.
- 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>
2026-11-20 08:53:25 +01:00

84 lines
2.8 KiB
PHP

<?php
namespace App\Filament\Resources\Compositions\Pages;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\ListsCompositions;
use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Pages\ListRecords;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width;
use Illuminate\Contracts\Support\Htmlable;
/**
* Listen „Module“, „Programme“ und „Fachliche Kombinationen“: dieselbe Bestandsliste wie der Arbeitsplatz, mit festem
* Typ. Module und Programme teilen den Anlegedialog des Arbeitsplatzes; Kombinationen behalten ihren.
*/
abstract class ListCompositionKind extends ListRecords
{
use ListsCompositions;
use ReportsDomainRules;
abstract protected function kind(): CompositionKind;
protected function fixedKind(): ?CompositionKind
{
return $this->kind();
}
private function onDesk(): bool
{
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true);
}
public function getSubheading(): string|Htmlable|null
{
$desk = $this->onDesk() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
return $this->kind()->deskExplanation().$desk;
}
public function getMaxContentWidth(): Width|string|null
{
return Width::Full;
}
public function content(Schema $schema): Schema
{
return $schema->components([View::make('filament.verwaltung.bestand')]);
}
protected function getHeaderActions(): array
{
if ($this->onDesk()) {
return [$this->createCompositionAction($this->kind())];
}
return [
Action::make('create')
->label($this->kind()->createLabel())
->modalHeading('Neue '.$this->kind()->label())
->modalSubmitActionLabel($this->kind()->createLabel())
->visible(fn (): bool => ContentElementResource::editor())
->schema([
TextInput::make('designation')->label('Bezeichnung')->required(),
])
->action(function (array $data): void {
$composition = null;
$this->report(function () use ($data, &$composition): void {
$composition = app(ContentService::class)->createComposition($data['designation'], $this->kind());
}, $this->kind()->label().' ist angelegt.');
if ($composition !== null) {
$this->redirect(static::getResource()::getUrl('edit', ['record' => $composition]));
}
}),
];
}
}