Mache Auswahl, Aufbau und Entwurf im Redaktionseditor bedienbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6955830579
commit
053a361801
14 files changed
+1040
-155
No files matched your search
@@ -5,13 +5,16 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class EditorialPreviewController extends Controller
|
||||
{
|
||||
@@ -30,6 +33,101 @@ public function show(Composition $composition, ?CompositionVersion $version = nu
|
||||
abort_unless((int) $version->composition_id === (int) $composition->id, 404);
|
||||
abort_unless($version->status === ContentVersionStatus::Bereit, 404);
|
||||
|
||||
return $this->render(
|
||||
$composition,
|
||||
$version->learning_goal,
|
||||
$version->duration_minutes,
|
||||
$version->material_note,
|
||||
$version->number,
|
||||
false,
|
||||
array_map(
|
||||
fn (StructureNode $node): array => $this->present($node, app(EditorialCatalog::class)),
|
||||
app(CompositionStructureReader::class)->tree($version),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function draft(Composition $composition): View
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
$draft = $composition->working_draft;
|
||||
abort_unless(is_array($draft) && ($draft['members'] ?? null) !== null, 404);
|
||||
|
||||
$catalog = app(EditorialCatalog::class);
|
||||
$nodes = [];
|
||||
|
||||
foreach ($draft['members'] as $member) {
|
||||
if (! is_array($member)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = $catalog->rowForTarget((string) ($member['target'] ?? ''), (int) $composition->id, allowSelf: true);
|
||||
|
||||
if ($row === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$children = [];
|
||||
|
||||
if (preg_match('/^composition:(\d+)$/', (string) $row['target'], $match) === 1) {
|
||||
$nested = CompositionVersion::query()->find($match[1]);
|
||||
|
||||
if ($nested instanceof CompositionVersion) {
|
||||
$children = array_map(
|
||||
fn (StructureNode $node): array => $this->present($node, $catalog),
|
||||
app(CompositionStructureReader::class)->tree($nested),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$nodes[] = [
|
||||
'role' => (string) ($member['role'] ?? $row['kind']),
|
||||
'title' => $row['title'],
|
||||
'kind' => $row['kind'],
|
||||
'version' => $row['version_label'],
|
||||
'open_url' => $row['open_url'],
|
||||
'children' => $children,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render(
|
||||
$composition,
|
||||
$draft['learning_goal'] ?? null,
|
||||
$draft['duration_minutes'] ?? null,
|
||||
$draft['material_note'] ?? null,
|
||||
null,
|
||||
true,
|
||||
$nodes,
|
||||
);
|
||||
}
|
||||
|
||||
public function card(string $kind, int $subject): StreamedResponse
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
||||
$model = $kind === 'komposition'
|
||||
? Composition::query()->findOrFail($subject)
|
||||
: ContentElement::query()->findOrFail($subject);
|
||||
$path = $model->thumbnail_path;
|
||||
abort_unless(is_string($path) && str_starts_with($path, 'vorschau/') && ! str_contains($path, '..'), 404);
|
||||
$disk = Storage::disk('media_derived');
|
||||
abort_unless($disk->exists($path), 404);
|
||||
|
||||
return $disk->response($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $nodes
|
||||
*/
|
||||
private function render(
|
||||
Composition $composition,
|
||||
mixed $learningGoal,
|
||||
mixed $durationMinutes,
|
||||
mixed $materialNote,
|
||||
mixed $number,
|
||||
bool $draft,
|
||||
array $nodes,
|
||||
): View {
|
||||
$catalog = app(EditorialCatalog::class);
|
||||
|
||||
return view('filament.editorial.preview', [
|
||||
@@ -37,15 +135,13 @@ public function show(Composition $composition, ?CompositionVersion $version = nu
|
||||
'summary' => $composition->summary,
|
||||
'kind' => $composition->editorialContentKind?->label
|
||||
?? ($composition->kind?->deskLabel()),
|
||||
'learningGoal' => $version->learning_goal,
|
||||
'durationMinutes' => $version->duration_minutes,
|
||||
'materialNote' => $version->material_note,
|
||||
'number' => $version->number,
|
||||
'learningGoal' => $learningGoal,
|
||||
'durationMinutes' => $durationMinutes,
|
||||
'materialNote' => $materialNote,
|
||||
'number' => $number,
|
||||
'draft' => $draft,
|
||||
'backUrl' => $catalog->editUrl($composition),
|
||||
'nodes' => array_map(
|
||||
fn (StructureNode $node): array => $this->present($node, $catalog),
|
||||
app(CompositionStructureReader::class)->tree($version),
|
||||
),
|
||||
'nodes' => $nodes,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user