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
@@ -183,9 +183,13 @@ public function refusal(Model $subject, string $roleSlug, int $elementId): ?stri
|
||||
* Schreibt einen Arbeitsstand: entfernte Zuordnungen lösen, neue anlegen, Bindung und Reihenfolge je Rolle setzen.
|
||||
* Medien, Fassungen und Website-Freigaben bleiben unberührt.
|
||||
*
|
||||
* Mit $baseline (dem beim Laden gelesenen Stand) werden nur Zuordnungen gelöst, die dort standen und im
|
||||
* Arbeitsstand fehlen. Was inzwischen an anderer Stelle hinzugekommen ist, bleibt erhalten.
|
||||
*
|
||||
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
|
||||
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}>|null $baseline
|
||||
*/
|
||||
public function commit(Model $subject, array $staged, ?User $actor = null): void
|
||||
public function commit(Model $subject, array $staged, ?User $actor = null, ?array $baseline = null): void
|
||||
{
|
||||
$roles = PresentationRole::query()->get()->keyBy('slug');
|
||||
$seen = [];
|
||||
@@ -220,7 +224,7 @@ public function commit(Model $subject, array $staged, ?User $actor = null): void
|
||||
$this->checkedSource($subject, $element, $row['source']);
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($subject, $staged, $roles, $actor): void {
|
||||
DB::transaction(function () use ($subject, $staged, $roles, $actor, $baseline): void {
|
||||
$existing = PresentationAssignment::query()
|
||||
->with(['role', 'element'])
|
||||
->where('subject_type', $subject->getMorphClass())
|
||||
@@ -228,9 +232,15 @@ public function commit(Model $subject, array $staged, ?User $actor = null): void
|
||||
->get()
|
||||
->keyBy('id');
|
||||
$kept = array_filter(array_map(fn (array $row): ?int => $row['id'], $staged));
|
||||
$known = $baseline === null ? null : array_filter(array_map(fn (array $row): ?int => $row['id'], $baseline));
|
||||
|
||||
foreach ($existing as $id => $assignment) {
|
||||
if (! in_array((int) $id, $kept, true)) {
|
||||
$wasLoaded = $known === null || in_array((int) $id, $known, true);
|
||||
$replacedSingle = ! (bool) $assignment->role?->multiple
|
||||
&& ! in_array((int) $id, $kept, true)
|
||||
&& array_filter($staged, fn (array $row): bool => $row['role'] === $assignment->role?->slug) !== [];
|
||||
|
||||
if (! in_array((int) $id, $kept, true) && ($wasLoaded || $replacedSingle)) {
|
||||
$this->record($subject, ($assignment->role?->label ?? 'Präsentation').': '.($assignment->element?->working_title ?? ''), null, $actor);
|
||||
$assignment->delete();
|
||||
}
|
||||
@@ -257,6 +267,21 @@ public function commit(Model $subject, array $staged, ?User $actor = null): void
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
|
||||
$same = PresentationAssignment::query()
|
||||
->where('subject_type', $subject->getMorphClass())
|
||||
->where('subject_id', $subject->getKey())
|
||||
->where('presentation_role_id', $role->id)
|
||||
->where('content_element_id', $element->id)
|
||||
->first();
|
||||
|
||||
if ($same instanceof PresentationAssignment) {
|
||||
$same->position = $position;
|
||||
$same->source_version_id = $row['source'];
|
||||
$same->save();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
PresentationAssignment::query()->create([
|
||||
'subject_type' => $subject->getMorphClass(),
|
||||
'subject_id' => $subject->getKey(),
|
||||
|
||||
@@ -36,12 +36,23 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* Früheres Gesamtformular. Texte und Einordnung bearbeitet die gemeinsame Redaktion, Datei und Fassungen der
|
||||
* Medieneditor; ein zweiter Editor für dieselben Felder ist nach Dokument 14 nicht zulässig. Die Adresse bleibt
|
||||
* für alte Lesezeichen erhalten und führt nach der Rechteprüfung in die Redaktion des Mediums.
|
||||
*/
|
||||
class EditContentElement extends EditRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
parent::mount($record);
|
||||
$this->redirect(ContentElementResource::getUrl('view', ['record' => $this->getRecord(), 'redaktion' => 1]));
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Titel, Beschreibung, Hinweise und Vorschaubild gehören zum Medium. Ein Text bleibt dieselbe Fassung, solange er nicht freigegeben und verwendet wird.';
|
||||
|
||||
@@ -381,6 +381,57 @@ public function reviseAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Löschen bleibt Medien ohne Fassung vorbehalten. Bisher nur im separaten Formular, jetzt unter „Weitere Aktionen“.
|
||||
*/
|
||||
public function deleteAction(): Action
|
||||
{
|
||||
return Action::make('delete')
|
||||
->label('Medium löschen')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Medium löschen')
|
||||
->modalDescription('Das Medium hat keine Fassung und wird endgültig gelöscht. Zuordnungen als Präsentationsmedium entfallen.')
|
||||
->modalSubmitActionLabel('Löschen')
|
||||
->visible(fn (): bool => ContentElementResource::editor() && $this->getRecord()->versions()->doesntExist())
|
||||
->action(function (): void {
|
||||
abort_unless(ContentElementResource::editor() && $this->getRecord()->versions()->doesntExist(), 403);
|
||||
$this->getRecord()->delete();
|
||||
$this->redirect(ContentElementResource::getUrl('index'));
|
||||
});
|
||||
}
|
||||
|
||||
public function openThumbnailPicker(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
$this->resetPicker('vorschaubild');
|
||||
$this->pickerKind = 'bild';
|
||||
}
|
||||
|
||||
protected function adoptThumbnailFromPicker(string $target): void
|
||||
{
|
||||
$this->pickerSelected = $target;
|
||||
$this->adoptLibraryImage();
|
||||
$this->pickerSelected = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @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 $aktion === 'withdrawWebsite'
|
||||
? ['aktion' => $aktion, 'argument' => null, 'titel' => 'Website-Freigabe zurücknehmen?', 'text' => 'Das Medium verschwindet sofort von allen öffentlichen Seiten. Zuordnungen und Fassungen bleiben erhalten.', 'label' => 'Freigabe zurücknehmen', 'gefahr' => true]
|
||||
: null;
|
||||
}
|
||||
|
||||
protected function runExtraConfirmation(string $aktion, int|string|null $argument): void
|
||||
{
|
||||
if ($aktion === 'withdrawWebsite') {
|
||||
$this->withdrawWebsite();
|
||||
}
|
||||
}
|
||||
|
||||
public function hasDraftVersion(): bool
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
@@ -663,7 +714,7 @@ public function redaktionAusgabe(): ?array
|
||||
{
|
||||
return [
|
||||
'view' => 'filament.media.preview-frame',
|
||||
'stand' => 'Website- und Bibliothekskarte mit deinen aktuellen Eingaben, auch den noch nicht gespeicherten.',
|
||||
'stand' => 'Arbeitstitel, Anzeigename und Kurzbeschreibung zeigen deine aktuellen Eingaben, auch ungespeicherte. Bild und übrige Angaben zeigen den gespeicherten Stand.',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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