Files
laraundfelix/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php
T
LarsandClaude Sonnet 5.5 bc140a0e83
CI Feature / test (push) Successful in 2m25s
Mache die Übernahme aus Shinkan auffindbar und zeige den Zustand der Anbindung
Die Übungsliste verweist mit „Aus Shinkan übernehmen“ auf die Übernahmeseite. Die Seite zeigt Adresse (nur Host) und
Schlüssel (nur ob hinterlegt) und prüft die Verbindung, ohne etwas zu übernehmen.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 17:25:37 +01:00

97 lines
3.4 KiB
PHP

<?php
namespace App\Filament\Resources\Compositions\Pages;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Filament\Pages\Uebernahme;
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, CompositionKind::Exercise], true);
}
public function getSubheading(): string|Htmlable|null
{
$desk = $this->onDesk() && $this->kind() !== CompositionKind::Exercise ? ' 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->kind() === CompositionKind::Exercise) {
return [
$this->createCompositionAction($this->kind()),
Action::make('shinkan')
->label('Aus Shinkan übernehmen')
->icon('heroicon-o-arrow-down-tray')
->color('gray')
->visible(fn (): bool => ContentElementResource::editor())
->url(fn (): string => Uebernahme::getUrl()),
];
}
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]));
}
}),
];
}
}