Lege Medien über eine gemeinsame Maske mit Upload-Fortschritt an.
Beschreibung, Hinweise und Vorschaubild bleiben danach in derselben Maske bearbeitbar, im Bestand wie im Modul und Programm. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c73207f2c3
commit
89c574106f
8 files changed
+407
-160
No files matched your search
@@ -2,14 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\IncomingFile;
|
||||
use App\Filament\Support\MediumForm;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
@@ -30,47 +26,12 @@ protected function getHeaderActions(): array
|
||||
Action::make('create')
|
||||
->label('Medium anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Titel')->required(),
|
||||
Select::make('shape')->label('Was ist das?')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Hörstück',
|
||||
'bild' => 'Bild',
|
||||
'document' => 'Dokument',
|
||||
'text' => 'Text',
|
||||
])->required()->live(),
|
||||
Textarea::make('body')->label('Text')->visible(fn ($get): bool => $get('shape') === 'text'),
|
||||
EditContentElement::uploadField()->visible(fn ($get): bool => $get('shape') !== 'text'),
|
||||
TextInput::make('change_note')->label('Notiz zur ersten Fassung'),
|
||||
])
|
||||
->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 {
|
||||
$service = app(ContentService::class);
|
||||
[$kind, $output] = match ($data['shape']) {
|
||||
'audio' => ['audio', 'audio'],
|
||||
'bild' => ['bild', 'bild'],
|
||||
'document' => ['dokument', 'document'],
|
||||
'text' => ['text', 'text'],
|
||||
default => ['film', 'film'],
|
||||
};
|
||||
$element = $service->createElement($kind, $output, $data['working_title']);
|
||||
$metadata = [];
|
||||
$incoming = IncomingFile::store($data['incoming'] ?? null);
|
||||
|
||||
if (is_string($incoming) && $incoming !== '') {
|
||||
$metadata['incoming'] = $incoming;
|
||||
}
|
||||
|
||||
if (is_numeric($data['decision_seconds'] ?? null)) {
|
||||
$metadata['decision_seconds'] = (int) $data['decision_seconds'];
|
||||
}
|
||||
|
||||
$body = $data['body'] ?? null;
|
||||
|
||||
if ((is_string($body) && $body !== '') || $metadata !== []) {
|
||||
$service->publishElementVersion($element, is_string($body) ? $body : null, $metadata, $data['change_note'] ?? null);
|
||||
}
|
||||
$element = MediumForm::create($data, hold: false);
|
||||
}, 'Das Medium ist angelegt.');
|
||||
|
||||
if ($element !== null) {
|
||||
|
||||
Reference in new issue
Block a user