Mache Medien, Übungen und Kurse in der Verwaltung bearbeitbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4f2e5a5f3b
commit
3ee9f529ca
33 files changed
+1105
-284
No files matched your search
@@ -4,9 +4,11 @@
|
||||
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\IncomingFile;
|
||||
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;
|
||||
@@ -19,14 +21,14 @@ class ListContentElements extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Das Material selbst: Film, Text, PDF. Unter Kurse und Übungen werden daraus Abläufe, unter Pakete verkaufbare Zusammenstellungen.';
|
||||
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('Element anlegen')
|
||||
->label('Medium anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
@@ -45,11 +47,37 @@ protected function getHeaderActions(): array
|
||||
'pdf' => 'PDF',
|
||||
'text' => 'Text',
|
||||
])->required(),
|
||||
Textarea::make('body')->label('Text'),
|
||||
EditContentElement::uploadField(),
|
||||
TextInput::make('decision_seconds')->label('Entscheidungsmarke in Sekunden')->numeric()->minValue(0),
|
||||
TextInput::make('change_note')->label('Änderungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
app(ContentService::class)->createElement($data['kind'], $data['output_class'], $data['working_title']);
|
||||
}, 'Das Inhaltselement ist angelegt.');
|
||||
$element = null;
|
||||
$this->report(function () use ($data, &$element): void {
|
||||
$service = app(ContentService::class);
|
||||
$element = $service->createElement($data['kind'], $data['output_class'], $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);
|
||||
}
|
||||
}, 'Das Medium ist angelegt.');
|
||||
|
||||
if ($element !== null) {
|
||||
$this->redirect(ContentElementResource::getUrl('edit', ['record' => $element]));
|
||||
}
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user