- Lizenzartikel, Pakete, Rechteprofile und Angebote nutzen die gemeinsame Bestandsliste (ListsCatalog): Suche, Zustandsfilter, lesbare Zustände aus vorhandenen Daten statt „Aktueller Stand: 1“ oder „Fassungen: aktiv“ (Stand veröffentlicht/in Arbeit/gesperrt, in aktivem Angebot, Fassung aktiv mit Vergabe und Preis, Bestandteile, Zweck und Fähigkeiten). Lizenzartikel zeigen ihr Titelbild. - Anlegedialoge benennen Zweck und Bestätigung und öffnen danach den neuen Eintrag, statt in der Liste stehen zu bleiben. - Angebot im gemeinsamen Rahmen (Kopf, Positionen, aufgelöster Leistungsumfang, Fassungsverlauf). Eine Maske für Anlegen und Ändern (FACH-20): „Fassung aktivieren“ bzw. „Geänderte Fassung aktivieren“, bei einer Änderung mit der aktiven Fassung vorbelegt (FACH-08). Wirkung unverändert OfferService::activate: die bisherige Fassung wird beendet und bleibt gespeichert. „Als Vorlage verwenden“ (FACH-09) bleibt offen (OFF-04). - Entfernt: editorial/catalog-card (ersetzt). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
153 lines
6.3 KiB
PHP
153 lines
6.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\LicenseArticles\Pages;
|
|
|
|
use App\Domain\Catalog\ArticleService;
|
|
use App\Domain\Catalog\ContentElement;
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
use App\Domain\Catalog\PresentationMedia;
|
|
use App\Domain\Catalog\ReleaseStatus;
|
|
use App\Domain\Catalog\StatusValue;
|
|
use App\Domain\Media\ThumbnailRef;
|
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
|
use App\Filament\Support\ListsCatalog;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ListLicenseArticles extends ListRecords
|
|
{
|
|
use ListsCatalog;
|
|
use ReportsDomainRules;
|
|
|
|
protected static string $resource = LicenseArticleResource::class;
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Kleinste lizenzierbare Einheit. Der Stand hält fest, welche Inhalte dazugehören. Pakete und Angebote verweisen auf den Artikel, sie kopieren ihn nicht.';
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')
|
|
->label('Artikel anlegen')
|
|
->modalHeading('Neuer Lizenzartikel')
|
|
->modalDescription('Kennung und Produktlinie genügen. Titel, Texte und Stand pflegst du danach am Artikel.')
|
|
->modalSubmitActionLabel('Artikel anlegen')
|
|
->schema([
|
|
TextInput::make('code')->label('Kennung')->required(),
|
|
TextInput::make('product_line')->label('Produktlinie'),
|
|
])
|
|
->action(function (array $data): void {
|
|
$article = null;
|
|
$this->report(function () use ($data, &$article): void {
|
|
$article = app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null);
|
|
}, 'Der Lizenzartikel ist angelegt.');
|
|
|
|
if ($article instanceof LicenseArticle) {
|
|
$this->redirect(LicenseArticleResource::getUrl('view', ['record' => $article]));
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
|
|
protected function catalogRows(): array
|
|
{
|
|
$offered = DB::table('resolved_scopes')
|
|
->join('offer_versions', 'offer_versions.id', '=', 'resolved_scopes.offer_version_id')
|
|
->where('offer_versions.status', 'aktiv')
|
|
->distinct()
|
|
->pluck('resolved_scopes.license_article_id')
|
|
->map(fn (mixed $id): int => (int) $id)
|
|
->all();
|
|
$presentation = app(PresentationMedia::class);
|
|
$rows = [];
|
|
|
|
foreach (LicenseArticle::query()->with(['currentRelease', 'releases'])->orderBy('code')->get() as $article) {
|
|
$current = $article->currentRelease;
|
|
$currentStatus = $current !== null ? StatusValue::of($current->status) : null;
|
|
$draft = $article->releases->first(fn ($release): bool => StatusValue::of($release->status) === ReleaseStatus::Entwurf->value);
|
|
$chips = [];
|
|
$zustand = [];
|
|
|
|
if ($current === null) {
|
|
$chips[] = ['label' => 'Noch kein Stand', 'ton' => 'offen'];
|
|
$zustand[] = 'ohne';
|
|
} elseif ($currentStatus === ReleaseStatus::Gesperrt->value) {
|
|
$chips[] = ['label' => 'Stand '.$current->number.' gesperrt', 'ton' => 'achtung'];
|
|
$zustand[] = 'gesperrt';
|
|
} else {
|
|
$chips[] = ['label' => 'Stand '.$current->number.' veröffentlicht', 'ton' => 'gut'];
|
|
$zustand[] = 'stand';
|
|
}
|
|
|
|
if ($draft !== null) {
|
|
$chips[] = ['label' => 'Stand '.$draft->number.' in Arbeit', 'ton' => 'offen'];
|
|
$zustand[] = 'entwurf';
|
|
}
|
|
|
|
$inOffer = in_array($article->id, $offered, true);
|
|
$chips[] = $inOffer ? ['label' => 'In einem aktiven Angebot', 'ton' => 'gut'] : ['label' => 'In keinem aktiven Angebot', 'ton' => 'leise'];
|
|
$zustand[] = $inOffer ? 'angebot' : 'ohne-angebot';
|
|
|
|
if ($article->archived_at !== null) {
|
|
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
|
|
$zustand[] = 'archiviert';
|
|
}
|
|
|
|
$coverId = $presentation->coverElementId($article);
|
|
$cover = $coverId !== null ? ContentElement::query()->find($coverId) : null;
|
|
$title = trim((string) ($article->display_title ?: $article->working_title)) ?: $article->code;
|
|
$url = LicenseArticleResource::getUrl('view', ['record' => $article]);
|
|
$rows[] = [
|
|
'schluessel' => 'a'.$article->id,
|
|
'titel' => $title,
|
|
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
|
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
|
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path) : null,
|
|
'symbol' => 'dokument',
|
|
'url' => $url,
|
|
'chips' => $chips,
|
|
'zustand' => $zustand,
|
|
'suchtext' => implode(' ', array_filter([$article->code, $article->working_title, $article->display_title, $article->summary, $article->product_line, $article->search_terms])),
|
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
|
];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
|
|
protected function zustandOptionen(): array
|
|
{
|
|
return [
|
|
'alle' => 'Jeder Zustand',
|
|
'stand' => 'Mit veröffentlichtem Stand',
|
|
'ohne' => 'Noch ohne Stand',
|
|
'entwurf' => 'Stand in Arbeit',
|
|
'gesperrt' => 'Gesperrter Stand',
|
|
'angebot' => 'In einem aktiven Angebot',
|
|
'ohne-angebot' => 'In keinem aktiven Angebot',
|
|
'archiviert' => 'Archiviert',
|
|
];
|
|
}
|
|
|
|
protected function einheit(): array
|
|
{
|
|
return ['Lizenzartikel', 'Lizenzartikel'];
|
|
}
|
|
|
|
protected function leer(): array
|
|
{
|
|
return ['titel' => 'Noch keine Lizenzartikel', 'text' => 'Mit „Artikel anlegen“ oben entsteht der erste Artikel.'];
|
|
}
|
|
|
|
protected function suchPlatzhalter(): string
|
|
{
|
|
return 'Kennung, Titel oder Produktlinie';
|
|
}
|
|
}
|