Mache die Inhaltsverwaltung fuer die Redaktion bedienbar
Deploy Test / test (push) Successful in 18s
Deploy Test / deploy (push) Successful in 22s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-16 08:59:30 +01:00
1 parent 9b52181be1
commit d6ff881e4e
10 files changed
+371 -49

No files matched your search

@@ -2,13 +2,19 @@
namespace App\Filament\Resources\ContentElements\Pages;
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\EditorialDimension;
use App\Domain\Catalog\EditorialDimensionValue;
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\Catalog\ReleaseContent;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Filament\Support\ElementRevision;
use App\Filament\Support\MediaUploadLimit;
@@ -58,6 +64,43 @@ public function form(Schema $schema): Schema
->options(fn (): array => EditorialContentKind::selectOptions())
->nullable()
->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'),
Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString {
/** @var ContentElement $element */
$element = $this->getRecord();
$versionIds = $element->versions()->pluck('id');
$compositionIds = [];
foreach ($element->versions as $version) {
$compositionIds = [...$compositionIds, ...app(ContentService::class)->containingCompositionIds($version)];
}
$names = Composition::query()->whereIn('id', array_unique($compositionIds))->orderBy('designation')->pluck('designation')->all();
$articles = ReleaseContent::query()
->whereIn('content_element_version_id', $versionIds)
->with('release.article')
->get()
->map(fn (ReleaseContent $content): string => 'Lizenzartikel '.($content->release->article->code ?? ''))
->unique()
->all();
$lines = [...array_map(fn (string $name): string => 'Enthalten in '.$name, $names), ...$articles];
return new HtmlString($lines === [] ? 'Noch in keinem Modul, Programm oder Lizenzartikel.' : implode('<br>', array_map(e(...), $lines)));
}),
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
->options(function (): array {
$options = [];
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
foreach ($dimension->values as $value) {
$options[$value->id] = $dimension->label.': '.$value->label;
}
}
return $options;
})
->helperText('Wirkt auf die Suche und legt keine neue Fassung an.'),
FileUpload::make('thumbnail_upload')->label('Vorschaubild')
->disk('cms_incoming')->directory('vorschau')->visibility('private')->image()
->helperText('Nur die Karte. Die Inhaltsfassung bleibt unverändert.'),
CheckboxList::make('pillars')
->label('Fachliche Säulen')
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all())
@@ -128,6 +171,13 @@ protected function mutateFormDataBeforeFill(array $data): array
'display_title' => $this->getRecord()->display_title,
'description' => $this->getRecord()->description,
'summary' => $this->getRecord()->summary,
'editorial_content_kind_id' => $this->getRecord()->editorial_content_kind_id,
'dimension_ids' => IdentityDimensionValue::query()
->where('subject_type', $this->getRecord()->getMorphClass())
->where('subject_id', $this->getRecord()->id)
->where('origin', 'direkt')
->pluck('editorial_dimension_value_id')
->all(),
'pillars' => $this->getRecord()->pillars()->pluck('pillars.id')->all(),
];
}
@@ -144,6 +194,30 @@ protected function handleRecordUpdate(Model $record, array $data): Model
'display_title' => $data['display_title'] ?? null,
'summary' => $data['summary'] ?? null,
], auth()->user());
if (array_key_exists('editorial_content_kind_id', $data)) {
$record->editorial_content_kind_id = filled($data['editorial_content_kind_id'] ?? null)
? (int) $data['editorial_content_kind_id']
: null;
$record->save();
}
if (is_string($data['thumbnail_upload'] ?? null) && $data['thumbnail_upload'] !== '') {
$record->thumbnail_path = $data['thumbnail_upload'];
$record->thumbnail_error = null;
$record->thumbnail_alt = $record->working_title;
$record->save();
}
if (array_key_exists('dimension_ids', $data)) {
$ids = array_map(intval(...), $data['dimension_ids'] ?? []);
IdentityDimensionValue::query()
->where('subject_type', $record->getMorphClass())
->where('subject_id', $record->id)
->where('origin', 'direkt')
->whereNotIn('editorial_dimension_value_id', $ids === [] ? [0] : $ids)
->delete();
foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) {
app(IdentityDimension::class)->assign($record, $value, 'direkt');
}
}
app(PillarService::class)->assign($record, array_map(intval(...), $data['pillars'] ?? []));
} catch (DomainRuleException $exception) {
Notification::make()->title($exception->getMessage())->danger()->send();