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
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
@@ -18,7 +19,7 @@
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\ElementRevision;
|
||||
use App\Filament\Support\MediaUploadLimit;
|
||||
use App\Filament\Support\MediumForm;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Actions\Action;
|
||||
@@ -44,27 +45,24 @@ class EditContentElement extends EditRecord
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Arbeitstitel, Beschreibung und Säulen gehören zum Medium. Speichern legt keine neue Fassung an. Text und Datei änderst du über eine neue Fassung; die bisherige bleibt erhalten.';
|
||||
return 'Titel, Beschreibung, Hinweise und Vorschaubild gehören zum Medium. Ein Text bleibt dieselbe Fassung, solange er nicht freigegeben und verwendet wird.';
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return $schema->columns(1)->components([
|
||||
Placeholder::make('open')->label('Medium')->content(function (): HtmlString {
|
||||
$url = ContentElementResource::getUrl('view', ['record' => $this->getRecord()]);
|
||||
|
||||
return new HtmlString('<a href="'.e($url).'">Medium und Fassungen ansehen</a>');
|
||||
}),
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
...MediumForm::fields(creating: false, element: $element),
|
||||
TextInput::make('display_title')->label('Anzeigetitel')
|
||||
->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'),
|
||||
Textarea::make('summary')->label('Kurzbeschreibung')->rows(3),
|
||||
Textarea::make('description')->label('Beschreibung')->rows(4)
|
||||
->helperText('Allgemeine Beschreibung des Mediums. Gilt nicht für eine einzelne Fassung und nicht nur für ein Modul.'),
|
||||
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4)
|
||||
->helperText('Gilt für das Medium in jeder Verwendung. Speichern legt keine Fassung an.'),
|
||||
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
|
||||
->helperText('Nur in der Verwaltung sichtbar. Erscheint nicht in der Bibliothek und nicht auf der Website.'),
|
||||
Select::make('editorial_content_kind_id')
|
||||
->label('Inhaltsart')
|
||||
->options(fn (): array => EditorialContentKind::selectOptions())
|
||||
@@ -122,9 +120,6 @@ public function form(Schema $schema): Schema
|
||||
|
||||
return new HtmlString('<img src="'.e($url).'" alt="" style="width: 16rem; height: auto;">'.($caption !== '' ? '<p>'.e($caption).'</p>' : ''));
|
||||
}),
|
||||
FileUpload::make('thumbnail_upload')->label('Eigenes Vorschaubild')
|
||||
->disk('cms_incoming')->directory('vorschau')->visibility('private')->image()
|
||||
->helperText('Gilt für die Anzeige und als Vorschlag in Modulen und Programmen. Eine Filmstelle wählst du beim Ansehen. Speichern legt keine Fassung an.'),
|
||||
CheckboxList::make('pillars')
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
@@ -135,13 +130,7 @@ public function form(Schema $schema): Schema
|
||||
|
||||
public static function uploadField(): FileUpload
|
||||
{
|
||||
return FileUpload::make('incoming')
|
||||
->label('Datei')
|
||||
->disk('cms_incoming')
|
||||
->directory('inhalte')
|
||||
->visibility('private')
|
||||
->maxSize(MediaUploadLimit::KILOBYTES)
|
||||
->helperText('Film, Audio, Bild oder PDF bis 2 GB.');
|
||||
return MediumForm::fileField();
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
@@ -192,6 +181,8 @@ protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
return [
|
||||
'working_title' => $this->getRecord()->working_title,
|
||||
'thumbnail_alt' => $this->getRecord()->thumbnail_alt,
|
||||
'body' => $this->getRecord()->versions()->orderByDesc('number')->first()?->body,
|
||||
'display_title' => $this->getRecord()->display_title,
|
||||
'description' => $this->getRecord()->description,
|
||||
'usage_note' => $this->getRecord()->usage_note,
|
||||
@@ -221,7 +212,15 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
'summary' => $data['summary'] ?? null,
|
||||
'usage_note' => $data['usage_note'] ?? null,
|
||||
'license_note' => $data['license_note'] ?? null,
|
||||
'thumbnail_alt' => $data['thumbnail_alt'] ?? null,
|
||||
], auth()->user());
|
||||
if ($record->output_class === 'text' && is_string($data['body'] ?? null)) {
|
||||
$latest = $record->versions()->orderByDesc('number')->first();
|
||||
|
||||
if ($latest instanceof ContentElementVersion) {
|
||||
app(ContentService::class)->reviseElementContent($latest, $data['body']);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('editorial_content_kind_id', $data)) {
|
||||
$record->editorial_content_kind_id = filled($data['editorial_content_kind_id'] ?? null)
|
||||
? (int) $data['editorial_content_kind_id']
|
||||
|
||||
@@ -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