Öffne Katalog, Bibliothek und Testkauf für den MVP.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
463851d402
commit
fd6860efda
51 files changed
+2331
-31
No files matched your search
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListContentElements extends ListRecords
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Element anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
Select::make('kind')->label('Art')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Audio',
|
||||
'bild' => 'Bild',
|
||||
'pdf' => 'PDF',
|
||||
'text' => 'Text',
|
||||
'aufgabe' => 'Aufgabe',
|
||||
])->required(),
|
||||
Select::make('output_class')->label('Ausgabeklasse')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Audio',
|
||||
'bild' => 'Bild',
|
||||
'pdf' => 'PDF',
|
||||
'text' => 'Text',
|
||||
])->required(),
|
||||
])
|
||||
->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.');
|
||||
}),
|
||||
Action::make('version')
|
||||
->label('Fassung veröffentlichen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
Select::make('element_id')->label('Element')->options(fn (): array => CatalogOptions::elements())->required(),
|
||||
Textarea::make('body')->label('Text'),
|
||||
FileUpload::make('incoming')->label('Datei')->disk('cms_incoming')->directory('inhalte'),
|
||||
TextInput::make('change_note')->label('Änderungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
$metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : [];
|
||||
app(ContentService::class)->publishElementVersion(
|
||||
ContentElement::query()->findOrFail($data['element_id']),
|
||||
$data['body'] ?? null,
|
||||
$metadata,
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
}, 'Die Fassung ist gespeichert.');
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user