Zeige im Katalog, wie Inhalte, Pakete und Rechte zusammenhängen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fa706e5080
commit
cd79fb99d7
22 files changed
+1066
-200
No files matched your search
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Compositions\Pages;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\Compositions\CompositionResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewComposition extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = CompositionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('publish')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
Repeater::make('members')->label('Mitglieder')->schema([
|
||||
TextInput::make('role')->label('Rolle')->required(),
|
||||
Select::make('target')->label('Fassung')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
])->minItems(1),
|
||||
TextInput::make('note')->label('Bestätigungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
$members = [];
|
||||
|
||||
foreach ($data['members'] as $member) {
|
||||
[$type, $id] = explode(':', $member['target'], 2);
|
||||
$target = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
$members[] = ['role' => $member['role'], 'target' => $target];
|
||||
}
|
||||
|
||||
app(ContentService::class)->publishComposition(
|
||||
$composition,
|
||||
$members,
|
||||
auth()->user(),
|
||||
$data['note'] ?? null,
|
||||
);
|
||||
}, 'Die Kompositionsfassung ist bestätigt und bereit.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user