MVP 1.2 (inkl. Shop) #3
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
@@ -109,6 +110,9 @@ public function articleTitle(?LicenseArticle $article): string
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
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. */
|
||||
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;
|
||||
$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');
|
||||
}
|
||||
|
||||
/** 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>
|
||||
*/
|
||||
@@ -113,7 +122,7 @@ public function unusableArticles(array $articleIds): array
|
||||
*/
|
||||
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
|
||||
.(count($articles) === 1 ? ' hat' : ' haben')
|
||||
@@ -142,11 +151,11 @@ public function forArticle(LicenseArticle $article): array
|
||||
],
|
||||
[
|
||||
'titel' => 'Name und Beschreibung',
|
||||
'text' => filled($article->display_title)
|
||||
? 'Der Name „'.$article->display_title.'“ erscheint in Paketen, Angeboten und der Bibliothek.'
|
||||
: 'Ohne eigenen Namen erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.',
|
||||
'stand' => filled($article->display_title) ? 'erledigt' : 'optional',
|
||||
'aktion' => filled($article->display_title) ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
'text' => $this->articleName($article) !== ''
|
||||
? 'Der Name „'.$this->articleName($article).'“ erscheint in Paketen, Angeboten, im Shop und in der Bibliothek.'
|
||||
: 'Ohne Name erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.',
|
||||
'stand' => $this->articleName($article) !== '' ? 'erledigt' : 'optional',
|
||||
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\Bundles\Pages\ViewBundle;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
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');
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return RightsProfileVersion::query()->orderBy('id')->firstOrFail();
|
||||
|
||||
Reference in new issue
Block a user