diff --git a/app/Filament/Resources/ContentElements/Pages/ListContentElements.php b/app/Filament/Resources/ContentElements/Pages/ListContentElements.php index 714c0d0..87e0c5d 100644 --- a/app/Filament/Resources/ContentElements/Pages/ListContentElements.php +++ b/app/Filament/Resources/ContentElements/Pages/ListContentElements.php @@ -82,6 +82,11 @@ public function content(Schema $schema): Schema ]); } + protected function bestandFilterEigenschaften(): array + { + return ['suche', 'art', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv']; + } + public function showingList(): bool { return $this->ansicht === 'liste'; diff --git a/app/Filament/Resources/Offers/Pages/ViewOffer.php b/app/Filament/Resources/Offers/Pages/ViewOffer.php index b89cb0a..4c39779 100644 --- a/app/Filament/Resources/Offers/Pages/ViewOffer.php +++ b/app/Filament/Resources/Offers/Pages/ViewOffer.php @@ -94,7 +94,7 @@ public function activateAction(): Action ? 'Angebot ändern: Fassung '.$this->nextNumber().' aktivieren' : 'Erste Fassung aktivieren') ->modalDescription(fn (): string => ($active = $this->activeVersion()) !== null - ? 'Die Maske ist mit Fassung '.$active->number.' vorbelegt. Beim Aktivieren wird Fassung '.$active->number.' beendet und bleibt unverändert gespeichert; neue Erwerbe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen ändern sich dadurch nicht.' + ? 'Die Maske ist mit Fassung '.$active->number.' vorbelegt; Inhaberart, Laufzeitregel und Steuerklasse werden übernommen. Beim Aktivieren wird Fassung '.$active->number.' beendet und bleibt unverändert gespeichert; neue Erwerbe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen ändern sich dadurch nicht.' : 'Positionen, Vergabe und Preis bilden die erste Fassung. Nach dem Aktivieren ist sie unveränderlich; Änderungen ergeben eine weitere Fassung.') ->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' aktivieren') ->modalWidth('4xl') @@ -147,10 +147,19 @@ public function activateAction(): Action ]; } + // Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung; ohne + // aktive Fassung gilt wie bisher die Vorgabe (Personen, dauerhaft). + $active = $this->activeVersion(); + $kept = $active === null ? ['holder_kind' => 'person'] : [ + 'holder_kind' => $active->holder_kind, + 'term_rule' => $active->term_rule, + 'tax_class' => $active->tax_class, + 'dynamic' => (bool) $active->dynamic, + ]; $version = app(OfferService::class)->activate($offer, $lines, [ + ...$kept, 'grant_kind' => $data['grant_kind'], 'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'], - 'holder_kind' => 'person', 'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null, ]); diff --git a/app/Filament/Support/ListsCatalog.php b/app/Filament/Support/ListsCatalog.php index 52f5fd8..c641d4e 100644 --- a/app/Filament/Support/ListsCatalog.php +++ b/app/Filament/Support/ListsCatalog.php @@ -41,6 +41,11 @@ abstract protected function einheit(): array; */ abstract protected function leer(): array; + protected function bestandFilterEigenschaften(): array + { + return ['suche', 'zustand']; + } + protected function suchPlatzhalter(): string { return 'Name oder Beschreibung'; diff --git a/app/Filament/Support/ListsCompositions.php b/app/Filament/Support/ListsCompositions.php index 5ab1410..3ae1495 100644 --- a/app/Filament/Support/ListsCompositions.php +++ b/app/Filament/Support/ListsCompositions.php @@ -37,6 +37,11 @@ protected function fixedKind(): ?CompositionKind return null; } + protected function bestandFilterEigenschaften(): array + { + return ['query', 'kindFilter', 'pillar', 'visibility']; + } + public function resetFilters(): void { $this->query = ''; diff --git a/app/Filament/Support/ShowsBestand.php b/app/Filament/Support/ShowsBestand.php index 1aed629..5e821b6 100644 --- a/app/Filament/Support/ShowsBestand.php +++ b/app/Filament/Support/ShowsBestand.php @@ -23,9 +23,17 @@ public function mehrAnzeigen(): void $this->bestandGrenze += Bestand::SCHRITT; } + /** + * Eigenschaften, deren Änderung die Liste wieder oben beginnen lässt (Suche und Filter). Andere Änderungen, + * etwa Eingaben in einem geöffneten Anlegedialog, lassen die angezeigte Menge unverändert. + * + * @return list + */ + abstract protected function bestandFilterEigenschaften(): array; + public function updatedShowsBestand(string $name): void { - if ($name !== 'bestandGrenze') { + if (in_array($name, $this->bestandFilterEigenschaften(), true)) { $this->bestandGrenze = Bestand::SCHRITT; } } diff --git a/tests/Feature/BestandslisteTest.php b/tests/Feature/BestandslisteTest.php index 11e1079..5cd2600 100644 --- a/tests/Feature/BestandslisteTest.php +++ b/tests/Feature/BestandslisteTest.php @@ -28,6 +28,7 @@ use App\Filament\Resources\RightsProfiles\Pages\ViewRightsProfile; use App\Filament\Resources\Users\Pages\ListUsers; use App\Filament\Support\Bestand; +use App\Filament\Support\EditorialCatalog; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Livewire\Livewire; @@ -115,6 +116,10 @@ public function test_active_filters_are_named_and_removable_and_the_list_grows_i ->assertDontSee('Modul 51') ->call('mehrAnzeigen') ->assertSee('Modul 53') + ->mountAction('createModule') + ->set('mountedActions.0.data.designation', 'Noch nicht angelegt') + ->assertSet('bestandGrenze', 2 * Bestand::SCHRITT) + ->unmountAction() ->set('query', 'Modul 5') ->assertSet('bestandGrenze', Bestand::SCHRITT) ->assertSee('Suche: „Modul 5“') @@ -361,6 +366,51 @@ public function test_pillars_combinations_and_accounts_use_the_same_list(): void ->assertDontSee($editor->email); } + public function test_changing_an_offer_keeps_terms_the_mask_does_not_show(): void + { + $content = app(ContentService::class); + $articles = app(ArticleService::class); + $offers = app(OfferService::class); + $sheet = $content->publishElementVersion($content->createElement('pdf', 'pdf', 'Merkblatt'), 'Hinweis'); + $article = $articles->create('demo-merkblatt', 'Erprobung'); + $articles->publishRelease($article, $sheet, 'A.'); + $rights = $offers->createRightsProfile('Lesen', 'institutionell', ['pdf' => ['ansehen']]); + $offer = $offers->create('Für Einrichtungen'); + $offers->activate($offer, [['target' => $article->fresh(), 'rights' => $rights]], [ + 'grant_kind' => 'kauf', 'price_cents' => 900, 'holder_kind' => 'organisation', + 'term_rule' => 'befristet', 'tax_class' => 'ermaessigt', 'dynamic' => true, + ]); + + Livewire::actingAs($this->keeper(), 'staff') + ->test(ViewOffer::class, ['record' => $offer->getKey()]) + ->mountAction('activate') + ->fillForm(['price_cents' => 1200]) + ->callMountedAction() + ->assertHasNoFormErrors() + ->assertSee('Fassung 2 aktiv · Kauf · 12,00 €'); + + $second = $offer->versions()->where('number', 2)->firstOrFail(); + $this->assertSame('organisation', $second->holder_kind); + $this->assertSame('befristet', $second->term_rule); + $this->assertSame('ermaessigt', $second->tax_class); + $this->assertTrue((bool) $second->dynamic); + } + + public function test_a_combination_opens_its_structure_and_its_editorial_desk_from_the_list(): void + { + $combination = app(ContentService::class)->createComposition('Materialsatz Alltag', CompositionKind::Kombination); + $editor = $this->editor(); + $url = EditorialCatalog::editUrl($combination); + + Livewire::actingAs($editor, 'staff') + ->test(ListCombinations::class) + ->assertSeeHtml('href="'.$url.'"') + ->assertSeeHtml('href="'.$url.'?redaktion=1"'); + + $this->actingAs($editor, 'staff')->get($url)->assertOk()->assertSee('Materialsatz Alltag'); + $this->actingAs($editor, 'staff')->get($url.'?redaktion=1')->assertOk()->assertSee('Redaktion speichern'); + } + private function keeper(): User { $keeper = User::factory()->katalogverwalter()->create();