Paket 2: konfigurierbare Inhaltsart an Identitaet
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7820bececb
commit
1a2b1298b5
8 files changed
+233
-1
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Composition extends Model
|
||||
@@ -10,6 +11,7 @@ class Composition extends Model
|
||||
protected $fillable = [
|
||||
'designation',
|
||||
'kind',
|
||||
'editorial_content_kind_id',
|
||||
'archived_at',
|
||||
];
|
||||
|
||||
@@ -21,6 +23,11 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function editorialContentKind(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EditorialContentKind::class);
|
||||
}
|
||||
|
||||
public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(CompositionVersion::class);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ContentElement extends Model
|
||||
'output_class',
|
||||
'working_title',
|
||||
'description',
|
||||
'editorial_content_kind_id',
|
||||
'archived_at',
|
||||
];
|
||||
|
||||
@@ -23,6 +25,11 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function editorialContentKind(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EditorialContentKind::class);
|
||||
}
|
||||
|
||||
public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(ContentElementVersion::class);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class EditorialContentKind extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'label',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
public function compositions(): HasMany
|
||||
{
|
||||
return $this->hasMany(Composition::class);
|
||||
}
|
||||
|
||||
public function contentElements(): HasMany
|
||||
{
|
||||
return $this->hasMany(ContentElement::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function selectOptions(): array
|
||||
{
|
||||
return static::query()->orderBy('sort_order')->pluck('label', 'id')->all();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
@@ -44,6 +45,11 @@ public function form(Schema $schema): Schema
|
||||
TextInput::make('designation')->label('Bezeichnung')->required(),
|
||||
Select::make('kind')->label('Art')->options(CompositionKind::options())->required()
|
||||
->helperText('Übung, Kurs und fachliche Kombination sind verschiedene Zusammenstellungen. Die Art lässt sich hier ändern.'),
|
||||
Select::make('editorial_content_kind_id')
|
||||
->label('Inhaltsart')
|
||||
->options(fn (): array => EditorialContentKind::selectOptions())
|
||||
->nullable()
|
||||
->helperText('Optional für Bibliothek und Website. Ändert weder die technische Art noch eine Fassung.'),
|
||||
Placeholder::make('history')->label('Aktuelle Fassung')->content(function (): HtmlString {
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
@@ -110,6 +116,7 @@ protected function mutateFormDataBeforeFill(array $data): array
|
||||
return [
|
||||
'designation' => $composition->designation,
|
||||
'kind' => $kind instanceof CompositionKind ? $kind->value : $kind,
|
||||
'editorial_content_kind_id' => $composition->editorial_content_kind_id,
|
||||
'members' => $members,
|
||||
'note' => null,
|
||||
];
|
||||
@@ -125,6 +132,9 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
$kind = CompositionKind::from($data['kind']);
|
||||
$record->designation = trim((string) $data['designation']);
|
||||
$record->kind = $kind;
|
||||
$record->editorial_content_kind_id = filled($data['editorial_content_kind_id'] ?? null)
|
||||
? (int) $data['editorial_content_kind_id']
|
||||
: null;
|
||||
$record->save();
|
||||
|
||||
$members = [];
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
@@ -16,6 +17,7 @@
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
@@ -47,6 +49,11 @@ public function form(Schema $schema): Schema
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
Textarea::make('description')->label('Beschreibung')->rows(4)
|
||||
->helperText('Gilt für das Medium, nicht für eine einzelne Fassung.'),
|
||||
Select::make('editorial_content_kind_id')
|
||||
->label('Inhaltsart')
|
||||
->options(fn (): array => EditorialContentKind::selectOptions())
|
||||
->nullable()
|
||||
->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'),
|
||||
CheckboxList::make('pillars')
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
|
||||
@@ -34,7 +34,18 @@ public function kindLabel(LicenseArticle $article): ?string
|
||||
return null;
|
||||
}
|
||||
|
||||
$release->loadMissing('rootCompositionVersion.composition');
|
||||
$release->loadMissing([
|
||||
'rootCompositionVersion.composition.editorialContentKind',
|
||||
'rootElementVersion.element.editorialContentKind',
|
||||
]);
|
||||
|
||||
$editorial = $release->rootCompositionVersion?->composition?->editorialContentKind?->label
|
||||
?? $release->rootElementVersion?->element?->editorialContentKind?->label;
|
||||
|
||||
if ($editorial !== null) {
|
||||
return $editorial;
|
||||
}
|
||||
|
||||
$kind = $release->rootCompositionVersion?->composition?->kind;
|
||||
|
||||
return $kind instanceof CompositionKind ? $kind->label() : null;
|
||||
|
||||
Reference in new issue
Block a user