Zeige vor der Freigabe die enthaltene Struktur und gib Entwürfe nur mit Zustimmung frei.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1168c04228
commit
d12ba67b45
9 files changed
+934
-88
No files matched your search
@@ -59,6 +59,10 @@ public function rows(CompositionVersion $version, int $exceptCompositionId): arr
|
||||
*/
|
||||
public function rowForTarget(string $target, int $exceptCompositionId, bool $allowSelf = false, bool $allowDraft = false): ?array
|
||||
{
|
||||
if (preg_match('/^composition-draft:(\d+)$/', $target, $draftMatch) === 1) {
|
||||
return $this->draftCompositionRow((int) $draftMatch[1], $exceptCompositionId, $allowSelf);
|
||||
}
|
||||
|
||||
if (preg_match('/^(element|composition):(\d+)$/', $target, $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -134,6 +138,39 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string|null>|null
|
||||
*/
|
||||
private function draftCompositionRow(int $compositionId, int $exceptCompositionId, bool $allowSelf): ?array
|
||||
{
|
||||
if (! $allowSelf && $compositionId === $exceptCompositionId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$composition = Composition::query()->with('editorialContentKind')->find($compositionId);
|
||||
|
||||
if (! $composition instanceof Composition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$kind = $composition->editorialContentKind?->label
|
||||
?: ($composition->kind instanceof CompositionKind ? $composition->kind->deskLabel() : 'Zusammenstellung');
|
||||
|
||||
return [
|
||||
'target' => 'composition-draft:'.$composition->id,
|
||||
'title' => $this->compositionTitle($composition),
|
||||
'kind' => $kind,
|
||||
'summary' => (string) ($composition->summary ?? ''),
|
||||
'tone' => $this->tone('', $kind),
|
||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
||||
'version_label' => 'Entwurf',
|
||||
'identity' => 'zusammenstellung:'.$composition->id,
|
||||
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
||||
'open_label' => 'Entwurf ansehen',
|
||||
'edit_url' => self::editUrl($composition),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, string|null>>
|
||||
*/
|
||||
@@ -280,6 +317,43 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
$unreleased = Composition::query()
|
||||
->where('id', '!=', $exceptCompositionId)
|
||||
->whereNotNull('working_draft')
|
||||
->whereDoesntHave('versions', function ($builder): void {
|
||||
$builder->where('status', ContentVersionStatus::Bereit);
|
||||
})
|
||||
->when($kind === 'modul', function ($builder): void {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->get();
|
||||
|
||||
foreach ($unreleased as $composition) {
|
||||
$draft = is_array($composition->working_draft) ? $composition->working_draft : [];
|
||||
$draftMembers = is_array($draft['members'] ?? null) ? $draft['members'] : [];
|
||||
|
||||
if ($draftMembers === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($dimensionId > 0 && ! in_array($composition->id, $this->dimensionSubjectIds(Composition::class, $dimensionId), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $this->compositionTitle($composition);
|
||||
|
||||
if ($query !== '' && ! str_contains(mb_strtolower($title.' '.(string) ($composition->summary ?? '')), mb_strtolower($query))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = $this->rowForTarget('composition-draft:'.$composition->id, $exceptCompositionId);
|
||||
|
||||
if ($row !== null) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in new issue
Block a user