label('Komposition anlegen') ->visible(fn (): bool => ContentElementResource::editor()) ->schema([ TextInput::make('designation')->label('Bezeichnung')->required(), ]) ->action(function (array $data): void { $this->report(function () use ($data): void { app(ContentService::class)->createComposition($data['designation']); }, 'Die Komposition ist angelegt.'); }), Action::make('publish') ->label('Fassung veröffentlichen') ->visible(fn (): bool => ContentElementResource::editor()) ->schema([ Select::make('composition_id')->label('Komposition')->options(fn (): array => CatalogOptions::compositions())->required(), 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 { $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::query()->findOrFail($data['composition_id']), $members, auth()->user(), $data['note'] ?? null, ); }, 'Die Kompositionsfassung ist bestätigt und bereit.'); }), ]; } }