diff --git a/app/Filament/Support/ManagesEditorialSurface.php b/app/Filament/Support/ManagesEditorialSurface.php index 107ec6f..8480c81 100644 --- a/app/Filament/Support/ManagesEditorialSurface.php +++ b/app/Filament/Support/ManagesEditorialSurface.php @@ -17,6 +17,7 @@ use App\Http\Controllers\ContentPreviewController; use App\Models\User; use Illuminate\Database\Eloquent\Model; +use Livewire\Attributes\Url; /** * Gemeinsamer Redaktionsmanager für Medien, Module, Programme und Lizenzartikel. @@ -30,6 +31,8 @@ */ trait ManagesEditorialSurface { + /** Steht in der Adresse, damit „Zurück“ im Browser von der Redaktion in den Ausgangseditor führt. */ + #[Url(as: 'redaktion', history: true)] public bool $redaktionOpen = false; public string $redaktionTab = 'texte'; @@ -146,6 +149,24 @@ public function closeRedaktion(): void $this->deskFeedback = ''; } + /** + * Browser-Zurück und -Vor setzen den Wert über die Adresse. Dann gelten dieselben Regeln wie beim Knopf. + */ + public function updatedRedaktionOpen(bool $value): void + { + if ($value) { + abort_unless($this->canViewEditorial(), 403); + $this->redaktionWillOpen(); + $this->loadRedaktionStaging(); + + return; + } + + $this->ausgabeOpen = false; + $this->closePicker(); + $this->deskFeedback = ''; + } + public function showRedaktionTab(string $tab): void { if (in_array($tab, ['texte', 'medien', 'einordnung'], true)) { diff --git a/tests/Feature/VerwaltungArbeitsplatzTest.php b/tests/Feature/VerwaltungArbeitsplatzTest.php index 8b17dac..eedda15 100644 --- a/tests/Feature/VerwaltungArbeitsplatzTest.php +++ b/tests/Feature/VerwaltungArbeitsplatzTest.php @@ -130,6 +130,26 @@ public function test_media_redaktion_return_keeps_the_open_version_text(): void $this->assertNull($film->thumbnail_alt); } + public function test_the_redaktion_state_lives_in_the_address_for_browser_back(): void + { + $content = app(ContentService::class); + $film = $content->createElement('film', 'film', 'Lara im Park'); + $content->publishElementVersion($film, 'Filmfassung'); + + Livewire::actingAs($this->editor(), 'staff') + ->withQueryParams(['redaktion' => '1']) + ->test(ViewContentElement::class, ['record' => $film->getKey()]) + ->assertSet('redaktionOpen', true) + ->assertSee('Zurück zur Medienbearbeitung') + ->set('teaser', 'Offen beim Zurückblättern') + ->set('redaktionOpen', false) + ->assertDontSee('Zurück zur Medienbearbeitung') + ->assertSee('Redaktion mit ungespeicherten Änderungen') + ->assertSet('teaser', 'Offen beim Zurückblättern'); + + $this->assertNull($film->fresh()->teaser); + } + public function test_website_release_does_not_save_open_redaktion_inputs(): void { $content = app(ContentService::class);