Beschreibung, Hinweise und Vorschaubild bleiben danach in derselben Maske bearbeitbar, im Bestand wie im Modul und Programm. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.7 KiB
PHP
44 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\ContentElements\Pages;
|
|
|
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
|
use App\Filament\Support\MediumForm;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
|
|
class ListContentElements extends ListRecords
|
|
{
|
|
use ReportsDomainRules;
|
|
|
|
protected static string $resource = ContentElementResource::class;
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Die Dateien und Texte. Eine Übung, ein Kurs oder eine fachliche Kombination verweist darauf; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')
|
|
->label('Medium anlegen')
|
|
->visible(fn (): bool => ContentElementResource::editor())
|
|
->modalDescription('Dieselbe Maske gilt im Medienbestand, im Modul und im Programm. Der Upload zeigt seinen Fortschritt. Beschreibung, Hinweise und Vorschaubild gehören dazu.')
|
|
->schema(fn (): array => MediumForm::fields(creating: true))
|
|
->action(function (array $data): void {
|
|
$element = null;
|
|
$this->report(function () use ($data, &$element): void {
|
|
$element = MediumForm::create($data, hold: false);
|
|
}, 'Das Medium ist angelegt.');
|
|
|
|
if ($element !== null) {
|
|
$this->redirect(ContentElementResource::getUrl('view', ['record' => $element]));
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
}
|