Medium, Modul, Programm und Lizenzartikel nutzen denselben Objektkopf, dieselben Register (Texte, Präsentationsmedien, Einordnung) und denselben visuellen Picker. Präsentationsmedien, Abweichungen und Texte bilden einen Arbeitsstand, den nur „Redaktion speichern“ schreibt; Austausch behält die Position, Sortierung bleibt in der Rolle. Der Wechsel zur Redaktion und zurück erhält offene Eingaben des Ausgangseditors. Entfernt versteckte Mitspeicherungen: Der Didaktikdialog schreibt keine Redaktionstexte mehr, die Website-Freigabe keine offenen Quellenzeilen, Entwurf verwerfen setzt keine offenen Redaktionseingaben zurück. Tests, die alte Orte oder CSS-Zeichenketten prüften, sind auf die neue Bedienung umgestellt; neue Tests decken Arbeitsstand, Austausch, Abbrechen und Rückweg ab. Datenmodell, Fassungen und Rechte bleiben unverändert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41658d98dd
commit
e1fd59491c
44 files changed
+3917
-2173
No files matched your search
@@ -3,15 +3,22 @@
|
||||
namespace App\Filament\Resources\LicenseArticles\Pages;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
@@ -19,6 +26,8 @@
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ViewLicenseArticle extends ViewRecord
|
||||
{
|
||||
@@ -41,6 +50,10 @@ class ViewLicenseArticle extends ViewRecord
|
||||
|
||||
public int|string|null $kindId = null;
|
||||
|
||||
public ?int $releaseBeforeSave = null;
|
||||
|
||||
public int $releaseCountBeforeSave = 0;
|
||||
|
||||
/** @var list<int|string> */
|
||||
public array $dimensionIds = [];
|
||||
|
||||
@@ -55,14 +68,29 @@ public function canEditEditorial(): bool
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public function canViewEditorial(): bool
|
||||
{
|
||||
return LicenseArticleResource::keeper();
|
||||
}
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return $this->redaktionTitel();
|
||||
}
|
||||
|
||||
public function saveLicenseEditorial(): void
|
||||
{
|
||||
$this->saveRedaktion();
|
||||
}
|
||||
|
||||
protected function saveRedaktionTexte(): bool
|
||||
{
|
||||
$this->guardEditorial();
|
||||
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$releaseId = $article->current_release_id;
|
||||
$releases = $article->releases()->count();
|
||||
$this->releaseBeforeSave = $article->current_release_id;
|
||||
$this->releaseCountBeforeSave = $article->releases()->count();
|
||||
|
||||
app(IdentityProfile::class)->fill($article, [
|
||||
'working_title' => $this->workingTitle,
|
||||
@@ -78,25 +106,164 @@ public function saveLicenseEditorial(): void
|
||||
|
||||
$article->refresh();
|
||||
$this->fillLicenseEditorial();
|
||||
$this->deskFeedback = $article->current_release_id === $releaseId && $article->releases()->count() === $releases
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function redaktionSavedMessage(): string
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
|
||||
return $article->current_release_id === $this->releaseBeforeSave && $article->releases()->count() === $this->releaseCountBeforeSave
|
||||
? 'Gespeichert. Stand, Preis und Rechte bleiben unverändert.'
|
||||
: 'Gespeichert. Prüfe den Artikelstand, er hat sich geändert.';
|
||||
}
|
||||
|
||||
public function redaktionUnsaved(): bool
|
||||
protected function resetRedaktionTexte(): void
|
||||
{
|
||||
$this->fillLicenseEditorial();
|
||||
}
|
||||
|
||||
public function einordnungUnsaved(): bool
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord()->fresh() ?? $this->getRecord();
|
||||
$kind = filled($this->kindId) ? (int) $this->kindId : null;
|
||||
$storedKind = $article->editorial_content_kind_id !== null ? (int) $article->editorial_content_kind_id : null;
|
||||
|
||||
return trim($this->workingTitle) !== trim((string) ($article->working_title ?? ''))
|
||||
|| trim($this->displayTitle) !== trim((string) ($article->display_title ?? ''))
|
||||
|| trim($this->teaser) !== trim((string) ($article->teaser ?? ''))
|
||||
|| trim($this->summary) !== trim((string) ($article->summary ?? ''))
|
||||
|| trim($this->descriptionText) !== trim((string) ($article->description ?? ''))
|
||||
|| trim($this->searchTerms) !== trim((string) ($article->search_terms ?? ''))
|
||||
|| $kind !== $storedKind;
|
||||
if ($kind !== $storedKind) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$stored = IdentityDimensionValue::query()
|
||||
->where('subject_type', $article->getMorphClass())
|
||||
->where('subject_id', $article->getKey())
|
||||
->where('origin', 'direkt')
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->map(fn ($id): int => (int) $id)
|
||||
->all();
|
||||
$current = array_map(intval(...), $this->dimensionIds);
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
|
||||
*/
|
||||
public function redaktionKopf(): array
|
||||
{
|
||||
return [
|
||||
'art' => 'Lizenzartikel',
|
||||
'fuer' => 'den Lizenzartikel',
|
||||
'liste' => 'Lizenzartikel',
|
||||
'zurueck' => 'Zurück zum Lizenzartikel',
|
||||
'typ' => null,
|
||||
'umfang' => '„Redaktion speichern“ sichert die eigenen Texte, Präsentationsmedien und Einordnung dieses Lizenzartikels. Leere Angaben übernehmen weiter die fachliche Quelle. Stand, Preis und Rechte bleiben unverändert.',
|
||||
];
|
||||
}
|
||||
|
||||
public function redaktionTitel(): string
|
||||
{
|
||||
foreach ([$this->displayTitle, $this->workingTitle] as $title) {
|
||||
if (trim($title) !== '') {
|
||||
return trim($title);
|
||||
}
|
||||
}
|
||||
|
||||
$profile = $this->editorialProfile('artikel');
|
||||
|
||||
return (string) ($profile->value('display_title') ?? $this->getRecord()->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function redaktionFelder(): array
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$source = app(EditorialProfileReader::class)->sourceOf($article);
|
||||
$sourceTitle = $source !== null ? $this->sourceTitle($source) : null;
|
||||
$stored = fn (string $column): string => (string) ($article->getAttribute($column) ?? '');
|
||||
$quelle = fn (string $column): ?array => $sourceTitle === null ? null : [
|
||||
'titel' => $sourceTitle,
|
||||
'wert' => (string) ($source->getAttribute($column) ?? ''),
|
||||
];
|
||||
|
||||
return [
|
||||
['id' => 'arbeitstitel', 'label' => 'Interner Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'hilfe' => 'Nur in der Verwaltung sichtbar.'],
|
||||
['id' => 'anzeigename', 'label' => 'Name', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'quelle' => $quelle('display_title')],
|
||||
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser'), 'quelle' => $quelle('teaser')],
|
||||
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 4, 'stored' => $stored('summary'), 'quelle' => $quelle('summary')],
|
||||
['id' => 'beschreibung', 'label' => 'Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 6, 'stored' => $stored('description'), 'quelle' => $quelle('description')],
|
||||
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'quelle' => $quelle('search_terms')],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{titel: string, art: string, fuer: string, url: ?string}|null
|
||||
*/
|
||||
public function redaktionQuelle(): ?array
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$source = app(EditorialProfileReader::class)->sourceOf($article);
|
||||
|
||||
if ($source === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$url = match (true) {
|
||||
$source instanceof Composition => EditorialCatalog::editUrl($source),
|
||||
$source instanceof ContentElement => ContentElementResource::getUrl('view', ['record' => $source]),
|
||||
default => null,
|
||||
};
|
||||
|
||||
return [
|
||||
'titel' => $this->sourceTitle($source),
|
||||
'art' => $source instanceof ContentElement ? 'Medium' : ($source instanceof Composition && $source->kind === CompositionKind::Kurs ? 'Programm' : 'Modul'),
|
||||
'fuer' => 'diesen Lizenzartikel',
|
||||
'url' => $url,
|
||||
];
|
||||
}
|
||||
|
||||
public function redaktionOhneQuelle(): string
|
||||
{
|
||||
return 'Keine eindeutige fachliche Quelle. Es wird nichts aus einem Modul, Programm oder Medium übernommen.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{model: string, options: array<int|string, string>, hilfe: string}
|
||||
*/
|
||||
public function einordnungArt(): array
|
||||
{
|
||||
return [
|
||||
'model' => 'kindId',
|
||||
'options' => EditorialContentKind::selectOptions(),
|
||||
'hilfe' => 'Die Einordnung des Artikels ändert weder die Quelle noch den Preis.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{legend: string, model: string, values: list<array{id: int, label: string}>}>
|
||||
*/
|
||||
public function einordnungGruppen(): array
|
||||
{
|
||||
return array_map(fn (array $group): array => [
|
||||
'legend' => $group['label'],
|
||||
'model' => 'dimensionIds',
|
||||
'values' => $group['values'],
|
||||
], $this->licenseDimensionGroups());
|
||||
}
|
||||
|
||||
private function sourceTitle(Model $source): string
|
||||
{
|
||||
$title = $source->getAttribute('display_title') ?: ($source->getAttribute('working_title') ?? $source->getAttribute('designation'));
|
||||
|
||||
return (string) $title;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,56 +309,63 @@ private function fillLicenseEditorial(): void
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->schema([
|
||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
Textarea::make('classification')->label('Einordnung')->required()
|
||||
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
[$type, $id] = explode(':', $data['root'], 2);
|
||||
$root = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
$article,
|
||||
$root,
|
||||
$data['classification'],
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
$offers = $report['offers'] ?? [];
|
||||
return [];
|
||||
}
|
||||
|
||||
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
||||
.', Inhaber: '.($report['holders'] ?? 0)
|
||||
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||
$this->refreshRecord();
|
||||
}),
|
||||
Action::make('withdraw')
|
||||
->label('Stand zurückziehen')
|
||||
->schema([
|
||||
Textarea::make('reason')->label('Begründung')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
$result = app(ArticleService::class)->withdraw($this->getRecord(), $data['reason']);
|
||||
$current = $result['fallback_number'] === null
|
||||
? 'Es gibt keinen früheren Stand.'
|
||||
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
||||
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
||||
public function releaseAction(): Action
|
||||
{
|
||||
return Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->schema([
|
||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
Textarea::make('classification')->label('Einordnung')->required()
|
||||
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
[$type, $id] = explode(':', $data['root'], 2);
|
||||
$root = $type === 'composition'
|
||||
? CompositionVersion::query()->findOrFail($id)
|
||||
: ContentElementVersion::query()->findOrFail($id);
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
$article,
|
||||
$root,
|
||||
$data['classification'],
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
$offers = $report['offers'] ?? [];
|
||||
|
||||
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
||||
}, 'Der Stand ist zurückgezogen.');
|
||||
$this->refreshRecord();
|
||||
}),
|
||||
];
|
||||
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
||||
.', Inhaber: '.($report['holders'] ?? 0)
|
||||
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
public function withdrawAction(): Action
|
||||
{
|
||||
return Action::make('withdraw')
|
||||
->label('Stand zurückziehen')
|
||||
->schema([
|
||||
Textarea::make('reason')->label('Begründung')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
$result = app(ArticleService::class)->withdraw($this->getRecord(), $data['reason']);
|
||||
$current = $result['fallback_number'] === null
|
||||
? 'Es gibt keinen früheren Stand.'
|
||||
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
||||
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
||||
|
||||
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
||||
}, 'Der Stand ist zurückgezogen.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
private function refreshRecord(): void
|
||||
|
||||
Reference in new issue
Block a user