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
@@ -6,10 +6,13 @@
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\WebsiteImageUsage;
|
||||
@@ -91,18 +94,16 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
public string $editorialFeedback = '';
|
||||
|
||||
public int $versionsBeforeSave = 0;
|
||||
|
||||
public string $previewWidth = '640';
|
||||
|
||||
public string $previewSurface = 'website';
|
||||
|
||||
public string $pickerQuery = '';
|
||||
|
||||
public string $pickerContext = 'modul';
|
||||
|
||||
public string $pickerLayout = 'kacheln';
|
||||
|
||||
public string $pickerSelected = '';
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
parent::mount($record);
|
||||
@@ -113,33 +114,40 @@ public function mount(int|string $record): void
|
||||
$this->fassung = $requested;
|
||||
}
|
||||
|
||||
$bereich = (string) request()->query('bereich', 'beschreibung');
|
||||
$this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'praesentation', 'verwendung', 'vorschau'], true)
|
||||
? $bereich
|
||||
: 'beschreibung';
|
||||
$bereich = (string) request()->query('bereich', 'inhalt');
|
||||
$this->bereich = $this->normalBereich($bereich);
|
||||
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
|
||||
$this->fillEditorial();
|
||||
$this->syncBodyDraft();
|
||||
|
||||
if (in_array($bereich, ['praesentation', 'redaktion'], true) && $this->canEditEditorial()) {
|
||||
$this->openRedaktion($bereich === 'praesentation' ? 'medien' : 'texte');
|
||||
}
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable|null
|
||||
public function updatedBereich(string $value): void
|
||||
{
|
||||
if ($this->redaktionOpen) {
|
||||
return null;
|
||||
}
|
||||
$this->bereich = $this->normalBereich($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereiche des Medieneditors. Die früheren Werte „beschreibung“ und „praesentation“ führen zur Website-Ansicht,
|
||||
* weil Texte und Präsentationsmedien in der gemeinsamen Redaktion bearbeitet werden.
|
||||
*/
|
||||
public function normalBereich(string $value): string
|
||||
{
|
||||
return match ($value) {
|
||||
'inhalt', 'fassungen', 'verwendung', 'vorschau', 'website' => $value,
|
||||
'beschreibung', 'praesentation', 'redaktion' => 'website',
|
||||
default => 'inhalt',
|
||||
};
|
||||
}
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return (string) $this->getRecord()->working_title;
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
if ($this->redaktionOpen) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'Texte und Vorschaubild ändern keine Fassung. Eine neue Datei oder ein geänderter Lehrtext braucht eine neue Fassung.';
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
@@ -148,14 +156,15 @@ public function getMaxContentWidth(): Width|string|null
|
||||
public function infolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
View::make('filament.media.viewer')->viewData(fn (): array => $this->viewerData()),
|
||||
]);
|
||||
View::make('filament.media.viewer')->viewData(fn (): array => $this->viewerData())->columnSpanFull(),
|
||||
])->columns(1);
|
||||
}
|
||||
|
||||
public function showVersion(int $version): void
|
||||
{
|
||||
abort_unless($this->ownedVersion($version) instanceof ContentElementVersion, 404);
|
||||
$this->fassung = $version;
|
||||
$this->bereich = 'inhalt';
|
||||
$this->syncBodyDraft();
|
||||
}
|
||||
|
||||
@@ -320,53 +329,64 @@ public function deactivateAction(): Action
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
if ($this->redaktionOpen) {
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
Action::make('releaseVersion')
|
||||
->label('Fassung freigeben')
|
||||
->modalHeading('Fassung freigeben')
|
||||
->modalDescription('Diese Fassung wird freigegeben. Sie erscheint dadurch nicht in der Mitgliederbibliothek, nicht auf der Website und nicht in einem Angebot. Eine deaktivierte Fassung bleibt unverändert.')
|
||||
->modalSubmitActionLabel('Freigeben')
|
||||
->visible(function (): bool {
|
||||
public function releaseVersionAction(): Action
|
||||
{
|
||||
return Action::make('releaseVersion')
|
||||
->label('Fassung freigeben')
|
||||
->modalHeading('Fassung freigeben')
|
||||
->modalDescription('Diese Fassung wird freigegeben. Sie erscheint dadurch nicht in der Mitgliederbibliothek, nicht auf der Website und nicht in einem Angebot. Eine deaktivierte Fassung bleibt unverändert.')
|
||||
->modalSubmitActionLabel('Freigeben')
|
||||
->visible(function (): bool {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return ContentElementResource::editor()
|
||||
&& $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
|
||||
})
|
||||
->action(function (array $arguments): void {
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
$this->report(function () use ($arguments): string {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$versionId = (int) ($arguments['version'] ?? 0);
|
||||
$version = $versionId > 0
|
||||
? $this->ownedVersion($versionId)
|
||||
: $element->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
|
||||
abort_unless($version instanceof ContentElementVersion, 404);
|
||||
$released = app(ContentService::class)->releaseElementVersion($version);
|
||||
|
||||
return 'Fassung '.$released->number.' ist freigegeben.';
|
||||
}, 'Die Fassung ist freigegeben.');
|
||||
$this->getRecord()->unsetRelation('versions');
|
||||
});
|
||||
}
|
||||
|
||||
public function reviseAction(): Action
|
||||
{
|
||||
return Action::make('revise')
|
||||
->label('Neue Fassung anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema(fn (): array => ElementRevision::fields($this->getRecord()))
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return ContentElementResource::editor()
|
||||
&& $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
|
||||
})
|
||||
->action(function (array $arguments): void {
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
$this->report(function () use ($arguments): string {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$versionId = (int) ($arguments['version'] ?? 0);
|
||||
$version = $versionId > 0
|
||||
? $this->ownedVersion($versionId)
|
||||
: $element->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
|
||||
abort_unless($version instanceof ContentElementVersion, 404);
|
||||
$released = app(ContentService::class)->releaseElementVersion($version);
|
||||
return ElementRevision::publish($element, $data);
|
||||
}, 'Die neue Fassung ist angelegt.');
|
||||
$this->getRecord()->unsetRelation('versions');
|
||||
});
|
||||
}
|
||||
|
||||
return 'Fassung '.$released->number.' ist freigegeben.';
|
||||
}, 'Die Fassung ist freigegeben.');
|
||||
$this->getRecord()->unsetRelation('versions');
|
||||
}),
|
||||
Action::make('revise')
|
||||
->label('Neue Fassung anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema(fn (): array => ElementRevision::fields($this->getRecord()))
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
public function hasDraftVersion(): bool
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return ElementRevision::publish($element, $data);
|
||||
}, 'Die neue Fassung ist angelegt.');
|
||||
$this->getRecord()->unsetRelation('versions');
|
||||
}),
|
||||
];
|
||||
return $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -457,7 +477,15 @@ private function ownedVersion(int $id): ?ContentElementVersion
|
||||
return $element->versions()->whereKey($id)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert die Redaktion: Texte, Einordnung, Präsentationsmedien und Abweichungen. Datei und Fassungen bleiben.
|
||||
*/
|
||||
public function saveEditorial(): void
|
||||
{
|
||||
$this->saveRedaktion();
|
||||
}
|
||||
|
||||
protected function saveRedaktionTexte(): bool
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
@@ -466,12 +494,13 @@ public function saveEditorial(): void
|
||||
$title = trim($this->workingTitle);
|
||||
|
||||
if ($title === '') {
|
||||
$this->editorialFeedback = 'Der Arbeitstitel fehlt.';
|
||||
$this->deskFeedback = 'Der Arbeitstitel fehlt. Er bezeichnet das Medium in der Verwaltung.';
|
||||
$this->redaktionFehlerFeld = 'workingTitle';
|
||||
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
$versions = $element->versions()->count();
|
||||
$this->versionsBeforeSave = $element->versions()->count();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'working_title' => $title,
|
||||
'display_title' => $this->displayTitle,
|
||||
@@ -483,7 +512,6 @@ public function saveEditorial(): void
|
||||
'license_note' => $this->licenseNote,
|
||||
'website_credit' => $this->websiteCredit,
|
||||
'website_alt' => $this->websiteAlt,
|
||||
'thumbnail_alt' => $this->thumbnailAlt,
|
||||
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
||||
], auth()->user());
|
||||
app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds));
|
||||
@@ -491,31 +519,34 @@ public function saveEditorial(): void
|
||||
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
$this->editorialFeedback = $element->versions()->count() === $versions
|
||||
? 'Gespeichert. Es gibt keine neue Fassung.'
|
||||
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
||||
$this->deskFeedback = $this->editorialFeedback;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function redaktionUnsaved(): bool
|
||||
protected function redaktionSavedMessage(): string
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$this->editorialFeedback = $element->versions()->count() === $this->versionsBeforeSave
|
||||
? 'Gespeichert. Es gibt keine neue Fassung.'
|
||||
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
||||
|
||||
return $this->editorialFeedback.' Datei, Inhaltsfassung und Website-Freigabe bleiben unverändert.';
|
||||
}
|
||||
|
||||
protected function resetRedaktionTexte(): void
|
||||
{
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
public function einordnungUnsaved(): bool
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord()->fresh() ?? $this->getRecord();
|
||||
$kind = filled($this->kindId) ? (int) $this->kindId : null;
|
||||
$storedKind = $element->editorial_content_kind_id !== null ? (int) $element->editorial_content_kind_id : null;
|
||||
$text = trim($this->workingTitle) !== trim((string) $element->working_title)
|
||||
|| trim($this->displayTitle) !== trim((string) ($element->display_title ?? ''))
|
||||
|| trim($this->teaser) !== trim((string) ($element->teaser ?? ''))
|
||||
|| trim($this->summary) !== trim((string) ($element->summary ?? ''))
|
||||
|| trim($this->searchTerms) !== trim((string) ($element->search_terms ?? ''))
|
||||
|| trim($this->descriptionText) !== trim((string) ($element->description ?? ''))
|
||||
|| trim($this->usageNote) !== trim((string) ($element->usage_note ?? ''))
|
||||
|| trim($this->licenseNote) !== trim((string) ($element->license_note ?? ''))
|
||||
|| trim($this->websiteCredit) !== trim((string) ($element->website_credit ?? ''))
|
||||
|| trim($this->websiteAlt) !== trim((string) ($element->website_alt ?? ''))
|
||||
|| $kind !== $storedKind;
|
||||
|
||||
if ($text) {
|
||||
if ($kind !== $storedKind) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -542,20 +573,112 @@ public function redaktionUnsaved(): bool
|
||||
return $stored !== $current;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
|
||||
*/
|
||||
public function redaktionKopf(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return [
|
||||
'art' => 'Medium',
|
||||
'fuer' => 'das Medium',
|
||||
'liste' => 'Medien',
|
||||
'zurueck' => 'Zurück zur Medienbearbeitung',
|
||||
'typ' => $element->editorialContentKind?->label ?? PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||
'umfang' => '„Redaktion speichern“ sichert Texte, Präsentationsmedien und Einordnung dieses Mediums. Verwendende Ansichten übernehmen die Angaben. Datei, Inhaltsfassung und Website-Freigabe bleiben unverändert.',
|
||||
];
|
||||
}
|
||||
|
||||
public function redaktionTitel(): string
|
||||
{
|
||||
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle);
|
||||
|
||||
return $title !== '' ? $title : (string) $this->getRecord()->working_title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function redaktionFelder(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$stored = fn (string $column): string => (string) ($element->getAttribute($column) ?? '');
|
||||
|
||||
return [
|
||||
['id' => 'arbeitstitel', 'label' => 'Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'required' => true, 'hilfe' => 'Bezeichnung in der Verwaltung. Pflichtangabe.'],
|
||||
['id' => 'anzeigename', 'label' => 'Anzeigename', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Arbeitstitel.'],
|
||||
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')],
|
||||
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 3, 'stored' => $stored('summary'), 'hilfe' => 'Erscheint auf Website- und Bibliothekskarten.'],
|
||||
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 8, 'stored' => $stored('description'), 'hilfe' => 'Bleibt in der Verwaltung und in Detailansichten. Kein Lehrtext.'],
|
||||
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'],
|
||||
['id' => 'einsatz', 'label' => 'Hinweise für den Einsatz', 'model' => 'usageNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('usage_note')],
|
||||
['id' => 'lizenz', 'label' => 'Interner Lizenzvermerk', 'model' => 'licenseNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('license_note'), 'hilfe' => 'Nur intern sichtbar.'],
|
||||
['id' => 'quelle', 'label' => 'Quellenzeile für die Website', 'model' => 'websiteCredit', 'kind' => 'textarea', 'rows' => 2, 'gruppe' => 'weitere', 'stored' => $stored('website_credit')],
|
||||
['id' => 'alt', 'label' => 'Alternativtext für die Website', 'model' => 'websiteAlt', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('website_alt'), 'hilfe' => 'Beschreibt das Bild für Menschen, die es nicht sehen.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{model: string, options: array<int|string, string>, hilfe: string}
|
||||
*/
|
||||
public function einordnungArt(): array
|
||||
{
|
||||
return [
|
||||
'model' => 'kindId',
|
||||
'options' => EditorialContentKind::selectOptions(),
|
||||
'hilfe' => 'Fachliche Materialart, unabhängig von der Dateiart.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{legend: string, model: string, values: list<array{id: int, label: string}>}>
|
||||
*/
|
||||
public function einordnungGruppen(): array
|
||||
{
|
||||
$groups = [[
|
||||
'legend' => 'Fachliche Säulen',
|
||||
'model' => 'pillarIds',
|
||||
'values' => Pillar::query()->orderBy('name')->get(['id', 'name'])
|
||||
->map(fn (Pillar $pillar): array => ['id' => (int) $pillar->id, 'label' => (string) $pillar->name])->all(),
|
||||
]];
|
||||
|
||||
foreach (EditorialDimension::forSubject($this->getRecord()) as $dimension) {
|
||||
$groups[] = [
|
||||
'legend' => (string) $dimension->label,
|
||||
'model' => 'dimensionIds',
|
||||
'values' => collect($dimension->values)->map(fn ($value): array => ['id' => (int) $value->id, 'label' => (string) $value->label])->all(),
|
||||
];
|
||||
}
|
||||
|
||||
return array_values(array_filter($groups, fn (array $group): bool => $group['values'] !== []));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{view: string, stand: string}
|
||||
*/
|
||||
public function redaktionAusgabe(): ?array
|
||||
{
|
||||
return [
|
||||
'view' => 'filament.media.preview-frame',
|
||||
'stand' => 'Website- und Bibliothekskarte mit deinen aktuellen Eingaben, auch den noch nicht gespeicherten.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt das Medium für die Website frei. Quellenzeile und Alternativtext gelten im gespeicherten Stand der Redaktion;
|
||||
* offene Eingaben in der Redaktion werden dabei weder gespeichert noch zurückgesetzt.
|
||||
*/
|
||||
public function releaseForWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'website_credit' => $this->websiteCredit,
|
||||
'website_alt' => $this->websiteAlt,
|
||||
], auth()->user());
|
||||
$element->refresh();
|
||||
$this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user());
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
public function withdrawWebsite(): void
|
||||
@@ -566,7 +689,18 @@ public function withdrawWebsite(): void
|
||||
$element = $this->getRecord();
|
||||
$this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user());
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
public function saveThumbnailAlt(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
app(IdentityProfile::class)->fill($element, ['thumbnail_alt' => trim($this->thumbnailAlt)], auth()->user());
|
||||
$element->refresh();
|
||||
$this->thumbnailAlt = (string) ($element->thumbnail_alt ?? '');
|
||||
$this->pictureFeedback = 'Der Alternativtext des Vorschaubilds ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user