Baue den Redaktionsmanager auf gemeinsame Bausteine um.
CI Feature / test (push) Successful in 56s

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:
LarsandClaude Opus 5.5 committed 2026-11-19 22:46:43 +01:00
1 parent 41658d98dd
commit e1fd59491c
44 files changed
+3917 -2173

No files matched your search

+218 -1
View File
@@ -6,6 +6,7 @@
use App\Domain\Media\WebsiteMedia;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/**
* Präsentationsmedien sind Referenzen auf Inhaltselemente.
@@ -60,6 +61,215 @@ public function rows(Model $subject): array
return $rows;
}
/**
* Gespeicherte Zuordnungen als bearbeitbarer Arbeitsstand, nach Rolle und Position geordnet.
*
* @return list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}>
*/
public function staged(Model $subject): array
{
$assignments = PresentationAssignment::query()
->with('role')
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->get()
->sortBy(fn (PresentationAssignment $row): string => sprintf('%05d-%05d-%08d', (int) $row->role?->sort_order, (int) $row->position, (int) $row->id))
->values();
$rows = [];
foreach ($assignments as $assignment) {
$rows[] = [
'key' => 'a'.$assignment->id,
'id' => (int) $assignment->id,
'role' => (string) $assignment->role?->slug,
'element_id' => (int) $assignment->content_element_id,
'source' => $assignment->source_version_id !== null ? (int) $assignment->source_version_id : null,
];
}
return $rows;
}
/**
* Anzeigezeilen für einen Arbeitsstand, gruppiert nach Rolle. Liest nur, schreibt nichts.
*
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
* @return list<array{role: string, label: string, multiple: bool, ordered: bool, rows: list<array<string, mixed>>}>
*/
public function describe(array $staged): array
{
$roles = PresentationRole::query()->orderBy('sort_order')->get()->keyBy('slug');
$elements = ContentElement::query()
->with('editorialContentKind')
->whereIn('id', array_values(array_unique(array_map(fn (array $row): int => (int) $row['element_id'], $staged))))
->get()
->keyBy('id');
$sources = ContentElementVersion::query()
->whereIn('id', array_values(array_filter(array_map(fn (array $row): ?int => $row['source'] ?? null, $staged))))
->get()
->keyBy('id');
$groups = [];
foreach ($roles as $slug => $role) {
$rows = array_values(array_filter($staged, fn (array $row): bool => $row['role'] === $slug));
if ($rows === []) {
continue;
}
$described = [];
foreach ($rows as $row) {
$element = $elements->get((int) $row['element_id']);
$released = $element instanceof ContentElement && $this->website->present($element) !== null;
$source = $row['source'] !== null ? $sources->get((int) $row['source']) : null;
$described[] = [
'key' => $row['key'],
'id' => $row['id'],
'element_id' => (int) $row['element_id'],
'title' => $element instanceof ContentElement
? (string) ($element->display_title ?: $element->working_title)
: 'Medium fehlt',
'image' => $element instanceof ContentElement
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
: null,
'kind' => $element?->editorialContentKind?->label,
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
'released' => $released,
'release_label' => $released ? 'Für die Website freigegeben' : 'Nicht für die Website freigegeben',
'binding' => $source instanceof ContentElementVersion ? $this->bindingFor($source) : null,
'new' => $row['id'] === null,
];
}
$groups[] = [
'role' => (string) $slug,
'label' => PresentationRole::displayLabel((string) $slug, (string) $role->label),
'multiple' => (bool) $role->multiple,
'ordered' => (bool) $role->ordered,
'rows' => $described,
];
}
return $groups;
}
/**
* Prüft, ob ein Medium im Arbeitsstand einer Rolle zugeordnet werden darf. Liefert den Ablehnungsgrund oder null.
*/
public function refusal(Model $subject, string $roleSlug, int $elementId): ?string
{
$role = PresentationRole::query()->where('slug', $roleSlug)->first();
$element = ContentElement::query()->find($elementId);
if (! $role instanceof PresentationRole || ! $element instanceof ContentElement) {
return 'Rolle oder Medium fehlt.';
}
if ($element->archived_at !== null) {
return 'Ein archiviertes Medium wird nicht zugeordnet.';
}
if ($subject instanceof ContentElement && (int) $subject->getKey() === (int) $element->id) {
return 'Ein Medium kann nicht seine eigene Präsentation sein.';
}
return null;
}
/**
* Schreibt einen Arbeitsstand: entfernte Zuordnungen lösen, neue anlegen, Bindung und Reihenfolge je Rolle setzen.
* Medien, Fassungen und Website-Freigaben bleiben unberührt.
*
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
*/
public function commit(Model $subject, array $staged, ?User $actor = null): void
{
$roles = PresentationRole::query()->get()->keyBy('slug');
$seen = [];
foreach ($staged as $row) {
$role = $roles->get($row['role']);
if (! $role instanceof PresentationRole) {
throw new DomainRuleException('Diese Rolle gibt es nicht.');
}
$refusal = $this->refusal($subject, $row['role'], (int) $row['element_id']);
if ($refusal !== null) {
throw new DomainRuleException($refusal);
}
$pair = $row['role'].':'.$row['element_id'];
if (isset($seen[$pair])) {
throw new DomainRuleException('Ein Medium steht in derselben Rolle nur einmal.');
}
$seen[$pair] = true;
$count = count(array_filter($staged, fn (array $other): bool => $other['role'] === $row['role']));
if (! $role->multiple && $count > 1) {
throw new DomainRuleException($role->label.' hat nur eine Zuordnung.');
}
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
$this->checkedSource($subject, $element, $row['source']);
}
DB::transaction(function () use ($subject, $staged, $roles, $actor): void {
$existing = PresentationAssignment::query()
->with(['role', 'element'])
->where('subject_type', $subject->getMorphClass())
->where('subject_id', $subject->getKey())
->get()
->keyBy('id');
$kept = array_filter(array_map(fn (array $row): ?int => $row['id'], $staged));
foreach ($existing as $id => $assignment) {
if (! in_array((int) $id, $kept, true)) {
$this->record($subject, ($assignment->role?->label ?? 'Präsentation').': '.($assignment->element?->working_title ?? ''), null, $actor);
$assignment->delete();
}
}
$positions = [];
foreach ($staged as $row) {
$role = $roles->get($row['role']);
$position = $positions[$row['role']] = ($positions[$row['role']] ?? 0) + 1;
$assignment = $row['id'] !== null ? $existing->get($row['id']) : null;
if ($assignment instanceof PresentationAssignment) {
$changed = (int) $assignment->position !== $position
|| (int) ($assignment->source_version_id ?? 0) !== (int) ($row['source'] ?? 0);
$assignment->position = $position;
$assignment->source_version_id = $row['source'];
if ($changed) {
$assignment->save();
}
continue;
}
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
PresentationAssignment::query()->create([
'subject_type' => $subject->getMorphClass(),
'subject_id' => $subject->getKey(),
'content_element_id' => $element->id,
'presentation_role_id' => $role->id,
'position' => $position,
'source_version_id' => $row['source'],
]);
$this->record($subject, null, $role->label.': '.$element->working_title, $actor);
}
});
}
public function assign(Model $subject, string $roleSlug, int $elementId, ?int $sourceVersionId, ?User $actor = null): string
{
$role = PresentationRole::query()->where('slug', $roleSlug)->first();
@@ -242,7 +452,14 @@ private function binding(PresentationAssignment $assignment): ?array
return null;
}
$version = $assignment->sourceVersion;
return $this->bindingFor($assignment->sourceVersion);
}
/**
* @return array{label: string, stale: bool}
*/
private function bindingFor(ContentElementVersion $version): array
{
$latestId = ContentElementVersion::query()
->where('content_element_id', $version->content_element_id)
->where('status', ContentVersionStatus::Bereit)
+16
View File
@@ -41,4 +41,20 @@ public static function selectOptions(): array
{
return static::query()->orderBy('sort_order')->pluck('label', 'slug')->all();
}
/**
* Kurze Bezeichnung für Überschriften und Auswahl in der Verwaltung.
*/
public static function displayLabel(string $slug, string $label): string
{
return match ($slug) {
'titelbild' => 'Titelbild',
'titelbild_alternativ' => 'Alternative Titelbilder',
'trailer' => 'Trailer',
'vorschauclip' => 'Vorschauclips',
'interview' => 'Interviews',
'galerie' => 'Galerie',
default => $label,
};
}
}
@@ -19,11 +19,13 @@
use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\IdentityProfile;
use App\Domain\Catalog\StructureNode;
use App\Domain\Cms\Catalog\PublicMaterialReader;
use App\Domain\Cms\Catalog\PublicCatalogReader;
use App\Domain\Cms\Widgets\RenderContext;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\EditorialCatalog;
use App\Filament\Support\ManagesEditorialSurface;
use App\Filament\Support\MediumForm;
use App\Filament\Support\WidgetEditor;
use App\Http\Controllers\ContentPreviewController;
use App\Jobs\DeriveCompositionFrame;
use App\Jobs\DeriveThumbnail;
@@ -87,22 +89,6 @@ abstract class EditComposition extends EditRecord
public string $panel = 'angaben';
public bool $pickerOpen = false;
public string $pickerPurpose = 'aufbau';
public string $pickerQuery = '';
public string $pickerKind = 'alle';
public string $pickerLayout = 'liste';
public string $pickerDimension = '';
public string $pickerSelected = '';
public string $pickerInspected = '';
public bool $textOpen = false;
public bool $releaseArmed = false;
@@ -139,7 +125,7 @@ abstract class EditComposition extends EditRecord
public bool $moduleOpen = false;
public string $moduleTab = 'beschreibung';
public string $moduleTab = 'didaktik';
public bool $partOpen = false;
@@ -182,24 +168,11 @@ public function mount(int|string $record): void
}
}
public function getHeading(): string|Htmlable|null
public function getTitle(): string|Htmlable
{
if ($this->redaktionOpen) {
return null;
}
$title = trim((string) $this->getRecord()->display_title) !== '' ? (string) $this->getRecord()->display_title : (string) $this->getRecord()->designation;
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->designation);
return $title !== '' ? $title : parent::getHeading();
}
public function getSubheading(): string|Htmlable|null
{
if ($this->redaktionOpen) {
return null;
}
return $this->hostKind()->deskExplanation().' '.$this->statusSentence();
return $title !== '' ? $title : $this->hostLabel();
}
public function getMaxContentWidth(): Width|string|null
@@ -214,47 +187,53 @@ protected function mutateFormDataBeforeFill(array $data): array
protected function getHeaderActions(): array
{
if ($this->redaktionOpen) {
return [];
}
return [];
}
return [
Action::make('preview')
->label('Vorschau für Trainer')
->url(fn (): ?string => $this->previewUrl())
->openUrlInNewTab()
->visible(fn (): bool => $this->previewUrl() !== null),
Action::make('displayRelease')
->label('In Mitgliederbibliothek anzeigen')
->requiresConfirmation()
->modalHeading('In der Mitgliederbibliothek anzeigen')
->modalDescription('Sichtbar wird die zuletzt übernommene Fassung. Das ist keine Website-Veröffentlichung und kein aktives Angebot. Eine frühere Fassung bleibt unverändert. Ungespeicherte Änderungen am Aufbau sind nicht Teil dieser Freigabe.')
->visible(function (): bool {
$version = $this->currentReadyVersion();
public function displayReleaseAction(): Action
{
return Action::make('displayRelease')
->label('In Mitgliederbibliothek anzeigen')
->requiresConfirmation()
->modalHeading('In der Mitgliederbibliothek anzeigen')
->modalDescription('Sichtbar wird die zuletzt übernommene Fassung. Das ist keine Website-Veröffentlichung und kein aktives Angebot. Eine frühere Fassung bleibt unverändert. Ungespeicherte Änderungen am Aufbau sind nicht Teil dieser Freigabe.')
->visible(function (): bool {
$version = $this->currentReadyVersion();
return $version !== null && ! app(CompositionDisplayRelease::class)->isReleased($version);
})
->action(function (): void {
$this->releaseDisplay();
}),
Action::make('displayRevoke')
->label('Aus Mitgliederbibliothek ausblenden')
->color('danger')
->requiresConfirmation()
->modalDescription('Die Fassung verschwindet aus der Mitgliederbibliothek. Der fachliche Inhalt bleibt gespeichert. Website und Angebot sind davon unabhängig.')
->visible(function (): bool {
$version = $this->currentReadyVersion();
return $version !== null && ! app(CompositionDisplayRelease::class)->isReleased($version);
})
->action(function (): void {
$this->releaseDisplay();
});
}
return $version !== null && app(CompositionDisplayRelease::class)->isReleased($version);
})
->action(function (): void {
$version = $this->currentReadyVersion();
$actor = $this->actor();
abort_unless($version !== null && $actor instanceof User, 403);
app(CompositionDisplayRelease::class)->revoke($version, $actor);
$this->feedback = 'Die Fassung ist aus der Mitgliederbibliothek ausgeblendet. Der Inhalt bleibt gespeichert.';
}),
];
public function displayRevokeAction(): Action
{
return Action::make('displayRevoke')
->label('Aus Mitgliederbibliothek ausblenden')
->color('danger')
->requiresConfirmation()
->modalHeading('Aus der Mitgliederbibliothek ausblenden')
->modalDescription('Die Fassung verschwindet aus der Mitgliederbibliothek. Der fachliche Inhalt bleibt gespeichert. Website und Angebot sind davon unabhängig.')
->visible(function (): bool {
$version = $this->currentReadyVersion();
return $version !== null && app(CompositionDisplayRelease::class)->isReleased($version);
})
->action(function (): void {
$version = $this->currentReadyVersion();
$actor = $this->actor();
abort_unless($version !== null && $actor instanceof User, 403);
app(CompositionDisplayRelease::class)->revoke($version, $actor);
$this->feedback = 'Die Fassung ist aus der Mitgliederbibliothek ausgeblendet. Der Inhalt bleibt gespeichert.';
});
}
public function isInLibrary(): bool
{
$version = $this->currentReadyVersion();
return $version !== null && app(CompositionDisplayRelease::class)->isReleased($version);
}
public function hostKind(): CompositionKind
@@ -336,58 +315,158 @@ public function openPicker(): void
$this->closePart();
}
$this->pickerPurpose = 'aufbau';
$this->pickerOpen = true;
$this->textOpen = false;
$this->pickerSelected = '';
$this->pickerInspected = '';
$this->resetPicker('aufbau');
$this->pickerKind = 'alle';
}
public function openRedaktion(): void
/**
* Schließt die Dialoge des Aufbaus, ohne deren offene Eingaben zu verwerfen.
*/
protected function redaktionWillOpen(): void
{
$this->moduleOpen = false;
$this->partOpen = false;
$this->textOpen = false;
$this->releaseArmed = false;
}
protected function saveRedaktionTexte(): bool
{
$this->guardEditorial();
$this->moduleOpen = false;
$this->moduleSnapshot = [];
$this->partOpen = false;
$this->pickerOpen = false;
$this->textOpen = false;
$this->redaktionOpen = true;
$this->redaktionTab = 'texte';
}
public function closeRedaktion(): void
{
$this->redaktionOpen = false;
$this->pickerOpen = false;
$this->replacingAssignment = null;
$this->presentationInspect = '';
}
if (trim($this->designation) === '') {
$this->deskFeedback = 'Der Name fehlt. Er bezeichnet den Eintrag in der Verwaltung.';
$this->redaktionFehlerFeld = 'designation';
public function saveRedaktion(): void
{
if (! $this->persistPresentation()) {
return;
return false;
}
$this->feedback = 'Die Redaktion ist gespeichert. Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert.';
return $this->persistRedaktion();
}
public function redaktionUnsaved(): bool
protected function redaktionSavedMessage(): string
{
$this->feedback = 'Die Redaktion ist gespeichert. Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert.';
return $this->feedback;
}
protected function resetRedaktionTexte(): void
{
$this->fillRedaktion();
}
/**
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
*/
public function redaktionKopf(): array
{
$program = $this->isProgram();
return [
'art' => $this->hostLabel(),
'fuer' => $program ? 'das Programm' : 'das Modul',
'liste' => $program ? 'Programme' : 'Module',
'zurueck' => 'Zurück zum Aufbau',
'typ' => null,
'umfang' => '„Redaktion speichern“ sichert Name, Texte, Präsentationsmedien und Einordnung. Aufbau, Lernziel, Zeit und Fassungen bleiben unverändert; offene Änderungen am Aufbau bleiben offen.',
];
}
public function redaktionTitel(): string
{
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->designation);
return $title !== '' ? $title : $this->hostLabel();
}
/**
* @return list<array<string, mixed>>
*/
public function redaktionFelder(): array
{
/** @var Composition $record */
$record = $this->getRecord();
$stored = fn (string $column): string => (string) ($record->getAttribute($column) ?? '');
return [
['id' => 'name', 'label' => 'Name in der Verwaltung', 'model' => 'designation', 'kind' => 'text', 'stored' => $stored('designation'), 'required' => true, 'hilfe' => 'Pflichtangabe. Erscheint in Listen der Verwaltung.'],
['id' => 'titel', 'label' => 'Titel', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Namen.'],
['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')],
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'description', 'kind' => 'textarea', 'rows' => 8, 'stored' => $stored('description'), 'hilfe' => 'Beschreibt das Angebot. Kein Lehrtext und kein Lernziel.'],
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'],
];
}
public function redaktionTexteHinweis(): string
{
return 'Lernziel, Zeit und Material gehören zum fachlichen Stand. Sie stehen im Aufbau unter „Didaktik und Katalogbild“ und entstehen mit der nächsten Fassung.';
}
/**
* @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->dimensionGroups());
}
/**
* @return array{html: string, stand: string}|null
*/
public function redaktionAusgabe(): ?array
{
$subject = app(PublicCatalogReader::class)->subject($this->getRecord()->getKey(), true);
if ($subject === null) {
return null;
}
$card = view('widgets.premium_card', [
'subject' => $subject,
'context' => RenderContext::preview(),
'cardStyle' => $subject->style ?? 'program',
'imageUrl' => null,
'alt' => '',
'focus' => ['x' => 50, 'y' => 45],
'format' => 'landscape',
'fit' => 'cover',
'headingTag' => 'h3',
'show' => ['summary' => true, 'kind' => true, 'meta' => true, 'action' => true],
'actionLabel' => 'Ansehen',
'note' => null,
'stacked' => false,
])->render();
return [
'html' => view('filament.cms.widget-live-preview', [
'html' => $card,
'stylesheets' => WidgetEditor::previewStylesheets(),
'width' => 640,
'bodyClass' => '',
'caption' => 'Website-Karte bei 640 px, wie im öffentlichen Auftritt.',
])->render(),
'stand' => $this->redaktionOffen()
? 'Gezeigt wird der gespeicherte Stand. Deine ungespeicherten Änderungen erscheinen erst nach „Redaktion speichern“.'
: 'Gezeigt wird der gespeicherte Stand der Redaktion.',
];
}
protected function pickerExceptId(): int
{
return (int) $this->getRecord()->getKey();
}
public function einordnungUnsaved(): bool
{
/** @var Composition $record */
$record = $this->getRecord()->fresh() ?? $this->getRecord();
$text = trim($this->designation) !== trim((string) $record->designation)
|| trim($this->displayTitle) !== trim((string) ($record->display_title ?? ''))
|| trim($this->teaser) !== trim((string) ($record->teaser ?? ''))
|| trim($this->summary) !== trim((string) ($record->summary ?? ''))
|| trim($this->description) !== trim((string) ($record->description ?? ''))
|| trim($this->searchTerms) !== trim((string) ($record->search_terms ?? ''))
|| trim($this->thumbnailAlt) !== trim((string) ($record->thumbnail_alt ?? ''));
if ($text) {
return true;
}
$stored = IdentityDimensionValue::query()
->where('subject_type', $record->getMorphClass())
->where('subject_id', $record->getKey())
@@ -402,174 +481,6 @@ public function redaktionUnsaved(): bool
return $stored !== $current;
}
public function openPresentationPicker(): void
{
$this->guardEditorial();
if ($this->partOpen) {
$this->closePart();
}
$this->pickerPurpose = 'praesentation';
$this->pickerOpen = true;
$this->moduleOpen = false;
$this->textOpen = false;
$this->pickerSelected = '';
$this->pickerInspected = '';
}
public function assignFromPicker(string $target): void
{
$this->guardEditorial();
if (preg_match('/^medium:(\d+)$/', $target, $mediumMatch) === 1) {
$element = ContentElement::query()->find((int) $mediumMatch[1]);
if (! $element instanceof ContentElement
|| $element->archived_at !== null
|| ! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
$this->deskFeedback = 'Dieses Präsentationsmedium ist nicht verfügbar.';
return;
}
$this->rememberAssignment($element->id, null);
$this->pickerOpen = false;
$this->pickerPurpose = 'aufbau';
$this->pickerSelected = '';
return;
}
if (preg_match('/^element:(\d+)$/', $target, $match) !== 1) {
$this->deskFeedback = 'Präsentationsmedien sind Medien aus dem Bestand. Ein Modul bleibt Bestandteil des Aufbaus.';
return;
}
$version = ContentElementVersion::query()->find((int) $match[1]);
if (! $version instanceof ContentElementVersion) {
$this->deskFeedback = 'Dieses Medium ist nicht verfügbar.';
return;
}
$this->rememberAssignment((int) $version->content_element_id, $target);
$this->pickerOpen = false;
$this->pickerPurpose = 'aufbau';
$this->pickerSelected = '';
}
public function closePicker(): void
{
$this->pickerOpen = false;
$this->pickerSelected = '';
$this->pickerInspected = '';
$this->replacingAssignment = null;
}
public function inspectPicker(string $target, bool $mark = false): void
{
$this->pickerInspected = $target;
if ($mark) {
$this->pickerSelected = $target;
}
}
/**
* @return array{items: list<array<string, string|null>>, more: bool}
*/
public function pickerResult(): array
{
if (! $this->pickerOpen) {
return ['items' => [], 'more' => false];
}
if ($this->pickerPurpose === 'praesentation') {
return app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery);
}
return app(EditorialCatalog::class)->browse(
$this->pickerQuery,
$this->pickerKind,
$this->pickerDimension,
(int) $this->getRecord()->getKey(),
);
}
/**
* @return array<string, string|null>|null
*/
public function pickerDetail(): ?array
{
$target = $this->pickerInspected !== '' ? $this->pickerInspected : $this->pickerSelected;
if ($target === '') {
return null;
}
$row = app(EditorialCatalog::class)->rowForTarget(
$target,
(int) $this->getRecord()->getKey(),
allowDraft: true,
);
if ($row === null) {
return null;
}
$row['playback'] = null;
if (preg_match('/^element:(\d+)$/', (string) $row['target'], $match) === 1) {
$version = ContentElementVersion::query()->with('element.editorialContentKind')->find($match[1]);
$row['playback'] = $version instanceof ContentElementVersion
? app(ContentPreviewController::class)->playback($version)
: null;
if ($version?->element !== null) {
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($version->element);
}
}
return $row;
}
/**
* @return list<array{target: string, label: string, current: bool}>
*/
public function pickerVersions(): array
{
$detail = $this->pickerDetail();
if ($detail === null) {
return [];
}
$options = app(EditorialCatalog::class)->alternatives(
(string) ($detail['identity'] ?? ''),
(int) $this->getRecord()->getKey(),
);
if ($options === []) {
return [];
}
$current = $options[array_key_last($options)]['target'];
return array_map(
fn (array $option): array => $option + ['current' => $option['target'] === $current],
$options,
);
}
public function pickerMatches(string $identity): bool
{
$detail = $this->pickerDetail();
return $detail !== null && ($detail['identity'] ?? '') === $identity;
}
public function openText(): void
{
$this->pickerOpen = false;
@@ -673,8 +584,8 @@ public function discardDraft(): void
$record = $this->getRecord();
app(EditorialWorkingDraft::class)->clear($record);
$this->releaseArmed = false;
$this->loadEditor();
$this->feedback = 'Der Entwurf ist verworfen. Eine freigegebene Fassung bleibt unverändert.';
$this->loadAufbau();
$this->feedback = 'Der Entwurf ist verworfen. Eine freigegebene Fassung bleibt unverändert. Offene Eingaben der Redaktion bleiben erhalten.';
}
public function editorStatus(): string
@@ -1150,7 +1061,7 @@ public function startModule(): void
public function saveDisplay(): void
{
if (! $this->persistPresentation()) {
if (! $this->persistRedaktion()) {
return;
}
@@ -1160,18 +1071,11 @@ public function saveDisplay(): void
public function openModule(): void
{
$this->moduleSnapshot = [
'designation' => $this->designation,
'displayTitle' => $this->displayTitle,
'teaser' => $this->teaser,
'summary' => $this->summary,
'searchTerms' => $this->searchTerms,
'description' => $this->description,
'learningGoal' => $this->learningGoal,
'durationMinutes' => $this->durationMinutes,
'materialNote' => $this->materialNote,
'revisionNote' => $this->revisionNote,
'thumbnailAlt' => $this->thumbnailAlt,
'dimensionIds' => $this->dimensionIds,
'imageMode' => $this->imageMode,
'imagePick' => $this->imagePick,
'frameVersionId' => $this->frameVersionId,
@@ -1180,7 +1084,7 @@ public function openModule(): void
$this->pickerOpen = false;
$this->partOpen = false;
$this->textOpen = false;
$this->moduleTab = 'beschreibung';
$this->moduleTab = in_array($this->moduleTab, ['didaktik', 'titelbild'], true) ? $this->moduleTab : 'didaktik';
$this->frameFilmChoices = $this->frameFilms();
$films = $this->frameFilmChoices;
$this->imageMode = $films === [] ? 'bestand' : 'film';
@@ -1203,6 +1107,9 @@ public function closeModule(): void
$this->previewUpload = null;
}
/**
* Übernimmt Didaktik und Katalogbild. Texte, Name und Einordnung gehören zur Redaktion und werden hier nicht gespeichert.
*/
public function saveModule(): void
{
if ($this->minutes($this->durationMinutes) === false) {
@@ -1211,19 +1118,16 @@ public function saveModule(): void
return;
}
if (! $this->persistPresentation()) {
return;
}
/** @var Composition $record */
$record = $this->getRecord();
app(IdentityProfile::class)->fill($record, ['thumbnail_alt' => trim($this->thumbnailAlt)], $this->actor());
$record->refresh();
$image = $this->applyChosenImage();
if ($image === false) {
return;
}
/** @var Composition $record */
$record = $this->getRecord();
if ($this->needsRevision() || app(EditorialWorkingDraft::class)->read($record) !== null) {
$this->persistDraft();
}
@@ -1232,7 +1136,7 @@ public function saveModule(): void
$this->moduleSnapshot = [];
$this->previewUpload = null;
$this->imagePick = '';
$this->feedback = trim('Die Angaben sind übernommen. Es entsteht keine neue Fassung.'.($image === '' ? '' : ' '.$image));
$this->feedback = trim('Didaktik und Katalogbild sind übernommen. Es entsteht keine neue Fassung.'.($image === '' ? '' : ' '.$image));
}
public function openPart(int $index): void
@@ -1728,22 +1632,25 @@ public function selectedMember(): ?array
}
protected function loadEditor(): void
{
$this->fillRedaktion();
$this->loadAufbau();
}
/**
* Liest die Angaben der Redaktion (Name, Texte, Einordnung) aus dem gespeicherten Stand.
*/
protected function fillRedaktion(): void
{
/** @var Composition $composition */
$composition = $this->getRecord();
$composition->refresh();
$version = $this->currentReadyVersion();
$this->designation = $composition->designation;
$this->displayTitle = (string) ($composition->display_title ?? '');
$this->teaser = (string) ($composition->teaser ?? '');
$this->summary = (string) ($composition->summary ?? '');
$this->searchTerms = (string) ($composition->search_terms ?? '');
$this->description = (string) ($composition->description ?? '');
$this->thumbnailPath = $composition->thumbnail_path;
$this->thumbnailAlt = (string) ($composition->thumbnail_alt ?? '');
$this->thumbnailError = $composition->thumbnail_error;
$this->thumbnailSource = $composition->thumbnail_source;
$this->imageCaptionText = $this->captionFor($composition->thumbnail_source);
$this->dimensionIds = IdentityDimensionValue::query()
->where('subject_type', $composition->getMorphClass())
->where('subject_id', $composition->id)
@@ -1751,6 +1658,22 @@ protected function loadEditor(): void
->pluck('editorial_dimension_value_id')
->map(fn (mixed $id): string => (string) (int) $id)
->all();
}
/**
* Liest Aufbau, Didaktik und Katalogbild aus Entwurf oder letzter freigegebener Fassung.
*/
protected function loadAufbau(): void
{
/** @var Composition $composition */
$composition = $this->getRecord();
$composition->refresh();
$version = $this->currentReadyVersion();
$this->thumbnailPath = $composition->thumbnail_path;
$this->thumbnailAlt = (string) ($composition->thumbnail_alt ?? '');
$this->thumbnailError = $composition->thumbnail_error;
$this->thumbnailSource = $composition->thumbnail_source;
$this->imageCaptionText = $this->captionFor($composition->thumbnail_source);
$this->catalogScope = match ($this->hostKind()) {
CompositionKind::Kurs => 'module',
CompositionKind::Uebung => 'medien',
@@ -1968,7 +1891,10 @@ protected function syncDimensions(Composition $composition, array $ids): void
app(IdentityDimension::class)->replaceOffered($composition, $ids);
}
protected function persistPresentation(): bool
/**
* Schreibt Name, Texte und Einordnung. Aufbau, Didaktik, Katalogbild und Fassungen bleiben unberührt.
*/
protected function persistRedaktion(): bool
{
/** @var Composition $record */
$record = $this->getRecord();
@@ -1987,7 +1913,6 @@ protected function persistPresentation(): bool
'summary' => $this->summary,
'search_terms' => $this->searchTerms,
'description' => $this->description,
'thumbnail_alt' => $this->thumbnailAlt,
], $this->actor());
$this->syncDimensions($record, array_map(intval(...), $this->dimensionIds));
$record->refresh();
@@ -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.';
}
/**
@@ -9,9 +9,7 @@
use App\Filament\Support\CatalogReading;
use App\Models\User;
use Filament\Facades\Filament;
use Filament\Infolists\Components\TextEntry;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
@@ -54,16 +52,13 @@ public static function getViewAuthorizationResponse(Model $record): Response
public static function infolist(Schema $schema): Schema
{
return $schema->components([
Section::make('Aktueller Stand')->schema([
TextEntry::make('stand')->hiddenLabel()->listWithLineBreaks()
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleStand($record)),
]),
Section::make('Pakete und Angebote')->description('Wo dieser Artikel lizenziert wird.')->schema([
TextEntry::make('context')->hiddenLabel()->listWithLineBreaks()
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleContext($record)),
]),
View::make('filament.editorial.license-desk'),
return $schema->columns(1)->components([
View::make('filament.editorial.license-desk')
->viewData(fn (LicenseArticle $record): array => [
'stand' => app(CatalogReading::class)->articleStand($record),
'kontext' => app(CatalogReading::class)->articleContext($record),
])
->columnSpanFull(),
]);
}
@@ -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
+16 -3
View File
@@ -398,9 +398,21 @@ public function browse(string $query, string $kind, string $dimension, int $exce
*
* @return array{items: list<array<string, string|null>>, more: bool}
*/
public function presentationBrowse(string $query): array
public function presentationBrowse(string $query, string $kind = 'alle'): array
{
$catalog = $this->browse($query, 'alle', '', 0, elementsOnly: true);
$catalog = $this->browse($query, $kind, '', 0, elementsOnly: true);
$outputs = match ($kind) {
'bild' => ['bild'],
'film' => ['film'],
'audio' => ['audio'],
'dokument' => [],
default => ['bild', 'film', 'audio'],
};
// Reine Texte sind Lehrinhalt oder Beschreibung, keine Präsentationsmedien.
$catalog['items'] = array_values(array_filter(
$catalog['items'],
fn (array $item): bool => ($item['output'] ?? '') !== 'text',
));
$seen = [];
foreach ($catalog['items'] as $item) {
@@ -413,7 +425,7 @@ public function presentationBrowse(string $query): array
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
$elements = ContentElement::query()
->with('editorialContentKind')
->whereIn('output_class', ['bild', 'film', 'audio'])
->whereIn('output_class', $outputs)
->whereNull('archived_at')
->whereDoesntHave('versions')
->where(function ($builder): void {
@@ -558,6 +570,7 @@ private function constrainElement($builder, string $query, string $like, string
'film' => ['film'],
'text' => ['text'],
'bild' => ['bild'],
'audio' => ['audio'],
'dokument' => ['pdf', 'document'],
default => null,
};
File diff suppressed because it is too large. Load diff
@@ -69,7 +69,7 @@ public function panel(Panel $panel): Panel
])
->renderHook(
PanelsRenderHook::STYLES_AFTER,
fn (): string => view('filament.cms.styles')->render(),
fn (): string => view('filament.cms.styles')->render().view('filament.verwaltung.styles')->render(),
)
->renderHook(
PanelsRenderHook::BODY_END,