Files
laraundfelix/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php
T
LarsandClaude Opus 5.5 514eb46217
CI Feature / test (push) Successful in 1m0s
Deploy Test / test (push) Successful in 56s
Deploy Test / deploy (push) Successful in 23s
Ergänze die Abnahme Teil B um Tastatur, alle Anlegedialoge und Angebotsbedingungen.
Schreibt „Neue fachliche Kombination“ klein.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 09:16:21 +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 '.lcfirst($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]));
}
}),
];
}
}