Halte die Rolle an dem Bestandteil, der gerade ausgewählt ist.
Deploy Test / test (push) Successful in 21s
Deploy Test / deploy (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-16 14:25:05 +01:00
1 parent 42415dff51
commit 7eb50c8a8d
3 files changed
+69 -1

No files matched your search

@@ -57,6 +57,8 @@ abstract class EditComposition extends EditRecord
public ?int $selected = null;
public string $roleDraft = '';
public string $panel = 'angaben';
public string $returnUrl = '';
@@ -355,8 +357,10 @@ public function selectPart(int $index): void
return;
}
$this->commitRoleDraft();
$this->selected = $index;
$this->panel = 'bestandteil';
$this->syncRoleDraft();
}
public function addPart(string $target): void
@@ -390,6 +394,7 @@ public function addPart(string $target): void
$this->members = array_values($this->members);
$this->selected = array_key_last($this->members);
$this->panel = 'bestandteil';
$this->syncRoleDraft();
$this->search = '';
$this->feedback = $row['title'].' ist in den Aufbau übernommen. Die neue Fassung entsteht erst mit „Neue Fassung übernehmen“.';
}
@@ -403,12 +408,14 @@ public function removePart(int $index): void
unset($this->members[$index]);
$this->members = array_values($this->members);
$this->selected = null;
$this->roleDraft = '';
$this->panel = 'angaben';
$this->feedback = 'Der Bestandteil ist aus dem Arbeitsstand genommen. Gespeichert ist das erst mit einer neuen Fassung.';
}
public function movePart(int $index, int $direction): void
{
$this->commitRoleDraft();
$target = $index + $direction;
if (! isset($this->members[$index], $this->members[$target])) {
@@ -420,6 +427,7 @@ public function movePart(int $index, int $direction): void
$this->members[$target] = $current;
$this->members = array_values($this->members);
$this->selected = $target;
$this->syncRoleDraft();
}
public function useVersion(int $index, string $target): void
@@ -436,8 +444,10 @@ public function useVersion(int $index, string $target): void
return;
}
$this->commitRoleDraft();
$row['role'] = $this->members[$index]['role'] ?? $row['kind'];
$this->members[$index] = $row;
$this->syncRoleDraft();
$this->feedback = $row['version_label'].' ist für diese Stelle ausgewählt. Übernehmen legt dafür eine neue Fassung an.';
}
@@ -560,6 +570,8 @@ public function savePreviewImage(string $storedPath): void
public function publishRevision(): bool
{
$this->commitRoleDraft();
if ($this->members === []) {
$this->feedback = 'Eine Fassung braucht mindestens einen Bestandteil. Anzeige und Kurzbeschreibung kannst du schon speichern.';
@@ -716,9 +728,31 @@ protected function applyVersion(CompositionVersion $version): void
$this->durationMinutes = $version->duration_minutes === null ? '' : (string) $version->duration_minutes;
$this->materialNote = (string) ($version->material_note ?? '');
$this->selected = null;
$this->roleDraft = '';
$this->panel = 'angaben';
}
public function updatedRoleDraft(string $value): void
{
$this->commitRoleDraft($value);
}
protected function commitRoleDraft(?string $value = null): void
{
if ($this->selected === null || ! isset($this->members[$this->selected])) {
return;
}
$this->members[$this->selected]['role'] = trim($value ?? $this->roleDraft);
}
protected function syncRoleDraft(): void
{
$this->roleDraft = $this->selected !== null && isset($this->members[$this->selected])
? (string) ($this->members[$this->selected]['role'] ?? '')
: '';
}
public function releaseDisplay(): void
{
$this->releaseCurrent();