Sichere den Redaktions-Arbeitsstand ab und entferne den Parallel-Editor.
- Speichern löst nur Zuordnungen, die beim Laden da waren; zwischenzeitlich
anderswo ergänzte bleiben erhalten.
- Eine belegte Einzelrolle (Titelbild, Hero, Hover) wird im Picker
ausdrücklich ausgetauscht, mit Banner und benanntem Ersatz.
- Gemeinsamer Bestätigungsdialog statt Browser-confirm(); Warnung beim
Verlassen der Seite mit ungespeicherten Änderungen.
- „Ausgabe prüfen“ am Medium benennt, welche Angaben aktuell und welche
gespeichert sind.
- Das frühere Gesamtformular für Medien leitet in die Redaktion; „Löschen“
steht unter „Weitere Aktionen“, die Medienliste öffnet die Redaktion.
- Vorschaubild aus vorhandenem Bild wieder über den gemeinsamen Picker
wählbar (Oberfläche war seit 72130d6 entfallen).
- Vorgemerkte Upload-Dateien bleiben sichtbar, Brotkrumen führen zur Liste,
die Redaktion lässt sich über die Adresse nicht ohne Recht öffnen.
- Agentenregeln und CLAUDE.md verweisen auf die gemeinsamen Bausteine.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
872f156d7d
commit
e7b0932e54
21 files changed
+481
-47
No files matched your search
@@ -88,6 +88,9 @@ trait ManagesEditorialSurface
|
||||
|
||||
public ?string $replacingKey = null;
|
||||
|
||||
/** @var array{aktion: string, argument: int|string|null, titel: string, text: string, label: string, gefahr: bool}|null */
|
||||
public ?array $bestaetigung = null;
|
||||
|
||||
public function getBreadcrumbs(): array
|
||||
{
|
||||
return [];
|
||||
@@ -103,6 +106,70 @@ public function getSubheading(): ?string
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wer die Redaktion über die Adresse öffnet, braucht dieselben Rechte wie über den Knopf.
|
||||
*/
|
||||
public function mountManagesEditorialSurface(): void
|
||||
{
|
||||
if ($this->redaktionOpen && ! $this->canViewEditorial()) {
|
||||
$this->redaktionOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fragt eine folgenreiche Handlung im gemeinsamen Dialog nach. Nur die hier genannten Handlungen sind erlaubt.
|
||||
*/
|
||||
public function askConfirmation(string $aktion, int|string|null $argument = null): void
|
||||
{
|
||||
$title = null;
|
||||
|
||||
if ($argument !== null && in_array($aktion, ['releaseAssigned', 'withdrawAssigned'], true)) {
|
||||
$element = ContentElement::query()->find((int) $argument);
|
||||
$title = $element instanceof ContentElement ? (string) ($element->display_title ?: $element->working_title) : null;
|
||||
}
|
||||
|
||||
$this->bestaetigung = match ($aktion) {
|
||||
'discardRedaktion' => ['aktion' => $aktion, 'argument' => null, 'titel' => 'Änderungen der Redaktion verwerfen?', 'text' => 'Texte, Präsentationsmedien und Einordnung kehren zum gespeicherten Stand zurück. Offene Eingaben im '.(($this->redaktionKopf()['zurueck'] ?? '') !== '' ? 'Ausgangseditor' : 'Editor').' bleiben erhalten.', 'label' => 'Verwerfen', 'gefahr' => true],
|
||||
'releaseAssigned' => ['aktion' => $aktion, 'argument' => $argument, 'titel' => '„'.($title ?? 'Medium').'“ für die Website freigeben?', 'text' => 'Die Freigabe gilt sofort für alle Verwendungen dieses Mediums, nicht nur hier. Gespeichert wird sie unabhängig von „Redaktion speichern“.', 'label' => 'Für die Website freigeben', 'gefahr' => false],
|
||||
'withdrawAssigned' => ['aktion' => $aktion, 'argument' => $argument, 'titel' => 'Website-Freigabe von „'.($title ?? 'Medium').'“ zurücknehmen?', 'text' => 'Das Medium verschwindet sofort aus allen öffentlichen Verwendungen. Zuordnungen und übrige Inhalte bleiben erhalten.', 'label' => 'Freigabe zurücknehmen', 'gefahr' => true],
|
||||
default => $this->extraConfirmation($aktion, $argument),
|
||||
};
|
||||
}
|
||||
|
||||
public function confirmConfirmation(): void
|
||||
{
|
||||
$frage = $this->bestaetigung;
|
||||
$this->bestaetigung = null;
|
||||
|
||||
if ($frage === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
match ($frage['aktion']) {
|
||||
'discardRedaktion' => $this->discardRedaktion(),
|
||||
'releaseAssigned' => $this->releaseAssigned((int) $frage['argument']),
|
||||
'withdrawAssigned' => $this->withdrawAssigned((int) $frage['argument']),
|
||||
default => $this->runExtraConfirmation($frage['aktion'], $frage['argument']),
|
||||
};
|
||||
}
|
||||
|
||||
public function cancelConfirmation(): void
|
||||
{
|
||||
$this->bestaetigung = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seiten können weitere bestätigte Handlungen ergänzen.
|
||||
*
|
||||
* @return array{aktion: string, argument: int|string|null, titel: string, text: string, label: string, gefahr: bool}|null
|
||||
*/
|
||||
protected function extraConfirmation(string $aktion, int|string|null $argument): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function runExtraConfirmation(string $aktion, int|string|null $argument): void {}
|
||||
|
||||
public function editorialSubject(): Model
|
||||
{
|
||||
return $this->getRecord();
|
||||
@@ -195,7 +262,7 @@ public function saveRedaktion(): void
|
||||
|
||||
try {
|
||||
if ($this->presentationUnsaved()) {
|
||||
app(PresentationMedia::class)->commit($this->editorialSubject(), $this->praesentation, $this->deskActor());
|
||||
app(PresentationMedia::class)->commit($this->editorialSubject(), $this->praesentation, $this->deskActor(), $this->praesentationGespeichert);
|
||||
}
|
||||
|
||||
if ($this->variantsUnsaved()) {
|
||||
@@ -465,9 +532,38 @@ public function openPresentationPicker(?string $role = null): void
|
||||
$this->guardEditorial();
|
||||
$this->loadRedaktionStaging();
|
||||
$roles = $this->presentationRoleOptions();
|
||||
$this->presentationRole = $role !== null && isset($roles[$role]) ? $role : (isset($roles[$this->presentationRole]) ? $this->presentationRole : (string) array_key_first($roles));
|
||||
$this->presentationRole = $role !== null && isset($roles[$role]) ? $role : $this->defaultRole();
|
||||
$this->resetPicker('praesentation');
|
||||
$this->pickerKind = $this->defaultKindForRole($this->presentationRole);
|
||||
$this->replacingKey = $this->occupiedSingleRoleKey($this->presentationRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erste freie Rolle für „Medien zuordnen“: das Titelbild, solange es fehlt, sonst die Galerie.
|
||||
*/
|
||||
protected function defaultRole(): string
|
||||
{
|
||||
$roles = $this->presentationRoleOptions();
|
||||
|
||||
if (isset($roles['titelbild']) && $this->stagingIndexesOfRole('titelbild') === []) {
|
||||
return 'titelbild';
|
||||
}
|
||||
|
||||
return isset($roles['galerie']) ? 'galerie' : (string) array_key_first($roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schlüssel der vorhandenen Zuordnung, wenn eine Rolle nur ein Medium erlaubt und schon belegt ist.
|
||||
*/
|
||||
protected function occupiedSingleRoleKey(string $role): ?string
|
||||
{
|
||||
if ($this->roleAllowsMany($role)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$indexes = $this->stagingIndexesOfRole($role);
|
||||
|
||||
return $indexes === [] ? null : $this->praesentation[$indexes[0]]['key'];
|
||||
}
|
||||
|
||||
public function beginExchange(string $key): void
|
||||
@@ -491,6 +587,7 @@ public function updatedPresentationRole(string $value): void
|
||||
{
|
||||
if ($this->pickerPurpose === 'praesentation') {
|
||||
$this->pickerKind = $this->defaultKindForRole($value);
|
||||
$this->replacingKey = $this->occupiedSingleRoleKey($value);
|
||||
}
|
||||
|
||||
if (! in_array($value, PresentationRole::BOUND_ROLES, true)) {
|
||||
@@ -566,6 +663,11 @@ public function pickerAllowsMany(): bool
|
||||
return $this->pickerPurpose === 'praesentation' && $this->roleAllowsMany($this->presentationRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* Für Seiten mit eigenem Vorschaubild: ein vorhandenes Bild als Vorschaubild übernehmen.
|
||||
*/
|
||||
protected function adoptThumbnailFromPicker(string $target): void {}
|
||||
|
||||
public function confirmPicker(): void
|
||||
{
|
||||
$marked = array_keys($this->pickerMarked);
|
||||
@@ -587,12 +689,19 @@ public function confirmPicker(): void
|
||||
|
||||
$this->guardEditorial();
|
||||
|
||||
if ($this->pickerPurpose === 'austausch') {
|
||||
if ($this->pickerPurpose === 'austausch' || ($this->pickerPurpose === 'praesentation' && $this->replacingKey !== null)) {
|
||||
$this->exchangeStaged($marked[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->pickerPurpose === 'vorschaubild') {
|
||||
$this->closePicker();
|
||||
$this->adoptThumbnailFromPicker($marked[0]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$added = [];
|
||||
$notes = [];
|
||||
|
||||
@@ -722,6 +831,10 @@ public function pickerVersions(): array
|
||||
*/
|
||||
public function pickerKinds(): array
|
||||
{
|
||||
if ($this->pickerPurpose === 'vorschaubild') {
|
||||
return ['bild' => 'Bilder'];
|
||||
}
|
||||
|
||||
if ($this->pickerPurpose === 'aufbau') {
|
||||
return ['alle' => 'Alle Inhalte', 'film' => 'Filme', 'bild' => 'Bilder', 'audio' => 'Hörstücke', 'dokument' => 'Dokumente', 'text' => 'Texte', 'modul' => 'Module'];
|
||||
}
|
||||
@@ -742,6 +855,7 @@ public function pickerTitle(): string
|
||||
return match ($this->pickerPurpose) {
|
||||
'aufbau' => 'Bestandteil auswählen',
|
||||
'austausch' => 'Medium austauschen',
|
||||
'vorschaubild' => 'Vorschaubild aus dem Bestand',
|
||||
default => 'Medien auswählen',
|
||||
};
|
||||
}
|
||||
@@ -750,9 +864,14 @@ public function pickerConfirmLabel(): string
|
||||
{
|
||||
$count = count($this->pickerMarked);
|
||||
|
||||
if ($this->pickerPurpose === 'praesentation' && $this->replacingKey !== null) {
|
||||
return 'Austauschen';
|
||||
}
|
||||
|
||||
return match ($this->pickerPurpose) {
|
||||
'aufbau' => 'In den Aufbau übernehmen',
|
||||
'austausch' => 'Austauschen',
|
||||
'vorschaubild' => 'Als Vorschaubild übernehmen',
|
||||
default => $count === 1 ? '1 Medium übernehmen' : ($count === 0 ? 'Medien übernehmen' : $count.' Medien übernehmen'),
|
||||
};
|
||||
}
|
||||
@@ -878,6 +997,7 @@ protected function exchangeStaged(string $target): void
|
||||
}
|
||||
|
||||
$title = $this->pickerMarked[$target] ?? 'Das neue Medium';
|
||||
$oldTitle = ContentElement::query()->whereKey($old['element_id'])->value('working_title');
|
||||
$this->praesentation[$index] = [
|
||||
'key' => $old['element_id'] === $elementId ? $old['key'] : 'n'.bin2hex(random_bytes(4)),
|
||||
'id' => $old['element_id'] === $elementId ? $old['id'] : null,
|
||||
@@ -891,7 +1011,7 @@ protected function exchangeStaged(string $target): void
|
||||
$this->pickerSelected = '';
|
||||
$this->pickerInspected = '';
|
||||
$this->replacingKey = null;
|
||||
$this->feedback('„'.$title.'“ ersetzt die bisherige Zuordnung an derselben Stelle. Wirksam wird das mit „Redaktion speichern“.');
|
||||
$this->feedback('„'.$title.'“ ersetzt „'.($oldTitle ?? 'die bisherige Zuordnung').'“ an derselben Stelle. Wirksam wird das mit „Redaktion speichern“.');
|
||||
}
|
||||
|
||||
protected function insertStaged(array $row): void
|
||||
|
||||
@@ -503,7 +503,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
||||
'usages' => $uses,
|
||||
'licenseText' => $this->licenseText($codes),
|
||||
'url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
'editUrl' => $canEdit ? ContentElementResource::getUrl('edit', ['record' => $element]) : null,
|
||||
'editUrl' => $canEdit ? ContentElementResource::getUrl('view', ['record' => $element, 'redaktion' => 1]) : null,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user