49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?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\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Pages\ViewRecord;
|
|
|
|
class ViewContentElement extends ViewRecord
|
|
{
|
|
use ReportsDomainRules;
|
|
|
|
protected static string $resource = ContentElementResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('version')
|
|
->label('Fassung veröffentlichen')
|
|
->schema([
|
|
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 {
|
|
/** @var ContentElement $element */
|
|
$element = $this->getRecord();
|
|
$metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : [];
|
|
app(ContentService::class)->publishElementVersion(
|
|
$element,
|
|
$data['body'] ?? null,
|
|
$metadata,
|
|
$data['change_note'] ?? null,
|
|
);
|
|
}, 'Die Fassung ist gespeichert.');
|
|
$this->getRecord()->unsetRelations();
|
|
$this->getRecord()->refresh();
|
|
}),
|
|
];
|
|
}
|
|
}
|