Benenne Artikel im Shop und in den Listen nach ihrem Inhalt statt nach der Kennung
Deploy Test / test (push) Successful in 1m36s
Deploy Test / deploy (push) Successful in 27s

Die Produktseite zeigte im Leistungsumfang die Kennung, obwohl die Redaktion den Namen
aus dem Inhalt übernimmt. ProductOptions und PublicationReadiness lösen den Namen jetzt
wie die Redaktion auf: eigener Name, sonst Name des Inhalts, zuletzt Kennung.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-11-21 18:14:56 +01:00
1 parent d49b178ebd
commit 4520dba2f0
3 files changed
+38 -8

No files matched your search

+5 -1
View File
@@ -3,6 +3,7 @@
namespace App\Domain\Commerce; namespace App\Domain\Commerce;
use App\Domain\Catalog\Composition; use App\Domain\Catalog\Composition;
use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Offer; use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
@@ -109,6 +110,9 @@ public function articleTitle(?LicenseArticle $article): string
return '–'; return '–';
} }
return (string) ($article->display_title ?: $article->working_title ?: $article->code); // Wie in der Redaktion: eigener Name, sonst der Name des Inhalts, zuletzt die Kennung.
$name = app(EditorialProfileReader::class)->read($article, 'detail')->value('display_title');
return (string) (filled($name) ? $name : ($article->working_title ?: $article->code));
} }
} }
+16 -7
View File
@@ -8,6 +8,7 @@
use App\Domain\Catalog\BundleStatus; use App\Domain\Catalog\BundleStatus;
use App\Domain\Catalog\BundleVersion; use App\Domain\Catalog\BundleVersion;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\Offer; use App\Domain\Catalog\Offer;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
@@ -47,7 +48,7 @@ public function articleUsable(LicenseArticle $article): bool
/** Anzeige in Auswahllisten: Name, Kennung und Stand statt der bloßen Kennung. */ /** Anzeige in Auswahllisten: Name, Kennung und Stand statt der bloßen Kennung. */
public function articleLabel(LicenseArticle $article): string public function articleLabel(LicenseArticle $article): string
{ {
$title = trim((string) ($article->display_title ?: $article->working_title)); $title = $this->articleName($article);
$name = $title !== '' ? $title.' ('.$article->code.')' : (string) $article->code; $name = $title !== '' ? $title.' ('.$article->code.')' : (string) $article->code;
$release = $article->currentRelease; $release = $article->currentRelease;
@@ -58,6 +59,14 @@ public function articleLabel(LicenseArticle $article): string
return $name.' · '.($release === null ? 'noch ohne Stand, nicht verwendbar' : 'Stand gesperrt, nicht verwendbar'); return $name.' · '.($release === null ? 'noch ohne Stand, nicht verwendbar' : 'Stand gesperrt, nicht verwendbar');
} }
/** Name wie in der Redaktion: eigener Name oder Name des Inhalts, sonst der Arbeitstitel; leer ohne beides. */
public function articleName(LicenseArticle $article): string
{
$name = app(EditorialProfileReader::class)->read($article, 'artikel')->value('display_title');
return trim((string) (filled($name) ? $name : $article->working_title));
}
/** /**
* @return array<int, string> * @return array<int, string>
*/ */
@@ -113,7 +122,7 @@ public function unusableArticles(array $articleIds): array
*/ */
public function unusableMessage(array $articles, string $zweck): string public function unusableMessage(array $articles, string $zweck): string
{ {
$namen = implode(', ', array_map(fn (LicenseArticle $article): string => '„'.($article->display_title ?: $article->working_title ?: $article->code).'“ ('.$article->code.')', $articles)); $namen = implode(', ', array_map(fn (LicenseArticle $article): string => '„'.($this->articleName($article) ?: $article->code).'“ ('.$article->code.')', $articles));
return (count($articles) === 1 ? 'Der Lizenzartikel ' : 'Die Lizenzartikel ').$namen return (count($articles) === 1 ? 'Der Lizenzartikel ' : 'Die Lizenzartikel ').$namen
.(count($articles) === 1 ? ' hat' : ' haben') .(count($articles) === 1 ? ' hat' : ' haben')
@@ -142,11 +151,11 @@ public function forArticle(LicenseArticle $article): array
], ],
[ [
'titel' => 'Name und Beschreibung', 'titel' => 'Name und Beschreibung',
'text' => filled($article->display_title) 'text' => $this->articleName($article) !== ''
? 'Der Name „'.$article->display_title.'“ erscheint in Paketen, Angeboten und der Bibliothek.' ? 'Der Name „'.$this->articleName($article).'“ erscheint in Paketen, Angeboten, im Shop und in der Bibliothek.'
: 'Ohne eigenen Namen erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.', : 'Ohne Name erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.',
'stand' => filled($article->display_title) ? 'erledigt' : 'optional', 'stand' => $this->articleName($article) !== '' ? 'erledigt' : 'optional',
'aktion' => filled($article->display_title) ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"], 'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
], ],
[ [
'titel' => 'In einem Paket oder Angebot verwenden', 'titel' => 'In einem Paket oder Angebot verwenden',
@@ -9,6 +9,7 @@
use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\OfferService; use App\Domain\Catalog\OfferService;
use App\Domain\Catalog\RightsProfileVersion; use App\Domain\Catalog\RightsProfileVersion;
use App\Domain\Commerce\ProductOptions;
use App\Filament\Resources\Bundles\Pages\ViewBundle; use App\Filament\Resources\Bundles\Pages\ViewBundle;
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle; use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
use App\Filament\Resources\Offers\Pages\ViewOffer; use App\Filament\Resources\Offers\Pages\ViewOffer;
@@ -204,6 +205,22 @@ public function test_the_bundle_offer_lists_the_scope_and_is_found_in_the_shop()
$this->get(route('public.program', $starter, false))->assertOk()->assertSee('Starterpaket (zwei Programme und Einführung)')->assertSee('59,00'); $this->get(route('public.program', $starter, false))->assertOk()->assertSee('Starterpaket (zwei Programme und Einführung)')->assertSee('59,00');
} }
public function test_the_scope_names_an_article_by_its_content_and_not_by_its_code(): void
{
$root = $this->article('shop-grenzen')->currentRelease->rootCompositionVersion;
$article = app(ArticleService::class)->create('nur-kennung-abnahme');
app(ArticleService::class)->publishRelease($article, $root, 'Erster Stand dieses Lizenzartikels.');
$offer = app(OfferService::class)->create('Namensprobe');
app(OfferService::class)->activate($offer, [['target' => $article->refresh(), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 1500, 'holder_kind' => 'person']);
app(OfferService::class)->assignProduct($offer, $this->program('Grenzen setzen im Verein')->id, 'Namensprobe');
$scope = collect(app(ProductOptions::class)->forComposition($this->program('Grenzen setzen im Verein')))->firstWhere('name', 'Namensprobe')['scope'];
$this->assertSame('Grenzen setzen im Verein', $scope[0]['article']);
$this->get(route('public.program', $this->program('Grenzen setzen im Verein'), false))->assertOk()->assertDontSee('nur-kennung-abnahme');
$this->assertStringContainsString('Grenzen setzen im Verein (nur-kennung-abnahme) · Stand 1', app(PublicationReadiness::class)->articleOptions()[$article->id]);
}
private function rights(): RightsProfileVersion private function rights(): RightsProfileVersion
{ {
return RightsProfileVersion::query()->orderBy('id')->firstOrFail(); return RightsProfileVersion::query()->orderBy('id')->firstOrFail();