Mache die Inhaltsverwaltung fuer die Redaktion bedienbar
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9b52181be1
commit
d6ff881e4e
10 files changed
+371
-49
No files matched your search
@@ -2,17 +2,24 @@
|
||||
|
||||
namespace App\Filament\Resources\Compositions\Pages;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionMember;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
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\StructureNode;
|
||||
use App\Filament\Resources\Combinations\CombinationResource;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||
@@ -21,6 +28,8 @@
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -50,6 +59,12 @@ public function form(Schema $schema): Schema
|
||||
TextInput::make('display_title')->label('Anzeigetitel')
|
||||
->helperText('Erscheint in der Bibliothek. Leer lässt die Bezeichnung stehen.'),
|
||||
Textarea::make('summary')->label('Kurzbeschreibung')->rows(3),
|
||||
Textarea::make('learning_goal')->label('Lernziel')->rows(2)
|
||||
->helperText('Gehört zur Fassung. Eine Änderung legt eine neue Fassung an.'),
|
||||
TextInput::make('duration_minutes')->label('Zeitbedarf in Minuten')->numeric()->minValue(1),
|
||||
Textarea::make('material_note')->label('Materialbedarf')->rows(2),
|
||||
Placeholder::make('status')->label('Stand')->content(fn (): HtmlString => new HtmlString(e($this->statusText()))),
|
||||
Placeholder::make('outline')->label('Gliederung der aktuellen Fassung')->content(fn (): HtmlString => new HtmlString($this->outlineHtml())),
|
||||
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')
|
||||
@@ -66,11 +81,25 @@ public function form(Schema $schema): Schema
|
||||
->where('nested_composition_version_id', $version->id)
|
||||
->with('compositionVersion.composition')
|
||||
->get()
|
||||
->map(fn (CompositionMember $member): string => ($member->compositionVersion->composition->designation ?? 'Programm').' · '.$member->role)
|
||||
->map(fn (CompositionMember $member): string => ($member->compositionVersion->composition->designation ?? 'Programm').', Rolle '.$member->role)
|
||||
->all();
|
||||
$articles = ArticleRelease::query()
|
||||
->where('root_composition_version_id', $version->id)
|
||||
->with('article')
|
||||
->get()
|
||||
->map(fn (ArticleRelease $release): string => 'Lizenzartikel '.$release->article->code.', Stand '.$release->number)
|
||||
->all();
|
||||
$lines = [...$lines, ...$articles];
|
||||
|
||||
return new HtmlString($lines === [] ? 'In keiner anderen Fassung enthalten.' : e(implode(' · ', $lines)));
|
||||
return new HtmlString($lines === [] ? 'In keinem anderen Programm und in keinem Lizenzartikel.' : implode('<br>', array_map(e(...), $lines)));
|
||||
}),
|
||||
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
|
||||
->options(fn (): array => self::dimensionOptions())
|
||||
->columns(1)
|
||||
->helperText('Wirkt auf die Suche in der Bibliothek und legt keine neue Fassung an.'),
|
||||
FileUpload::make('thumbnail_upload')->label('Vorschaubild')
|
||||
->disk('cms_incoming')->directory('vorschau')->visibility('private')->image()
|
||||
->helperText('Ersetzt nur das Bild der Karte. Die Fassung und die Dateien bleiben unverändert.'),
|
||||
Placeholder::make('history')->label('Aktuelle Fassung')->content(function (): HtmlString {
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
@@ -89,8 +118,9 @@ public function form(Schema $schema): Schema
|
||||
->label('Bausteine der neuen Fassung')
|
||||
->schema([
|
||||
TextInput::make('role')->label('Rolle')->placeholder('Film, Merkblatt, Übung')->required(),
|
||||
Select::make('target')->label('Fassung')->required()->searchable()
|
||||
->options(fn (): array => CatalogOptions::assignmentTargets($this->getRecord()->getKey())),
|
||||
Select::make('target')->label('Vorhandener Inhalt')->required()->searchable()
|
||||
->options(fn (): array => CatalogOptions::assignmentTargets($this->getRecord()->getKey()))
|
||||
->helperText('Titel, Inhaltsart und Fassungsnummer. Es wird genau diese Fassung verwendet.'),
|
||||
])
|
||||
->minItems(1)
|
||||
->reorderable()
|
||||
@@ -177,6 +207,15 @@ protected function mutateFormDataBeforeFill(array $data): array
|
||||
'summary' => $composition->summary,
|
||||
'kind' => $kind instanceof CompositionKind ? $kind->value : $kind,
|
||||
'editorial_content_kind_id' => $composition->editorial_content_kind_id,
|
||||
'learning_goal' => $version?->learning_goal,
|
||||
'duration_minutes' => $version?->duration_minutes,
|
||||
'material_note' => $version?->material_note,
|
||||
'dimension_ids' => IdentityDimensionValue::query()
|
||||
->where('subject_type', $composition->getMorphClass())
|
||||
->where('subject_id', $composition->id)
|
||||
->where('origin', 'direkt')
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->all(),
|
||||
'members' => $members,
|
||||
'note' => null,
|
||||
];
|
||||
@@ -196,10 +235,20 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
'summary' => $data['summary'] ?? null,
|
||||
], auth()->user());
|
||||
$record->kind = $kind;
|
||||
$record->editorial_content_kind_id = filled($data['editorial_content_kind_id'] ?? null)
|
||||
? (int) $data['editorial_content_kind_id']
|
||||
: null;
|
||||
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;
|
||||
}
|
||||
if (is_string($data['thumbnail_upload'] ?? null) && $data['thumbnail_upload'] !== '') {
|
||||
$record->thumbnail_path = $data['thumbnail_upload'];
|
||||
$record->thumbnail_error = null;
|
||||
$record->thumbnail_alt = $record->designation;
|
||||
}
|
||||
$record->save();
|
||||
if (array_key_exists('dimension_ids', $data)) {
|
||||
$this->syncDimensions($record, array_map(intval(...), $data['dimension_ids'] ?? []));
|
||||
}
|
||||
|
||||
$members = [];
|
||||
|
||||
@@ -216,14 +265,21 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
}
|
||||
|
||||
$note = is_string($data['note'] ?? null) ? trim($data['note']) : '';
|
||||
$current = $this->currentReadyVersion();
|
||||
$didactic = [
|
||||
'learning_goal' => $this->blankToNull(array_key_exists('learning_goal', $data) ? $data['learning_goal'] : $current?->learning_goal),
|
||||
'duration_minutes' => $this->minutes(array_key_exists('duration_minutes', $data) ? $data['duration_minutes'] : $current?->duration_minutes),
|
||||
'material_note' => $this->blankToNull(array_key_exists('material_note', $data) ? $data['material_note'] : $current?->material_note),
|
||||
];
|
||||
|
||||
if ($note !== '' || ! $this->sameMembers($record, $members)) {
|
||||
if ($note !== '' || ! $this->sameMembers($record, $members) || $this->didacticChanged($current, $didactic)) {
|
||||
$actor = Filament::auth()->user();
|
||||
app(ContentService::class)->publishComposition(
|
||||
$record,
|
||||
$members,
|
||||
$actor instanceof User ? $actor : null,
|
||||
$note !== '' ? $note : null,
|
||||
$didactic,
|
||||
);
|
||||
$this->savedTitle = 'Die neue Fassung ist veröffentlicht. Die bisherige Fassung bleibt erhalten.';
|
||||
} else {
|
||||
@@ -303,4 +359,118 @@ private function sameMembers(Composition $composition, array $members): bool
|
||||
|
||||
return $current === $next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{learning_goal: mixed, duration_minutes: mixed, material_note: mixed} $didactic
|
||||
*/
|
||||
private function didacticChanged(?CompositionVersion $version, array $didactic): bool
|
||||
{
|
||||
if ($version === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$storedMinutes = $version->duration_minutes === null ? null : (int) $version->duration_minutes;
|
||||
|
||||
return $version->learning_goal !== $didactic['learning_goal']
|
||||
|| $version->material_note !== $didactic['material_note']
|
||||
|| $storedMinutes !== $didactic['duration_minutes'];
|
||||
}
|
||||
|
||||
private function minutes(mixed $value): ?int
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
private function blankToNull(mixed $value): ?string
|
||||
{
|
||||
if (! is_string($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$value = trim($value);
|
||||
|
||||
return $value === '' ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $ids
|
||||
*/
|
||||
private function syncDimensions(Composition $composition, array $ids): void
|
||||
{
|
||||
IdentityDimensionValue::query()
|
||||
->where('subject_type', $composition->getMorphClass())
|
||||
->where('subject_id', $composition->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($composition, $value, 'direkt');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private static function dimensionOptions(): 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;
|
||||
}
|
||||
|
||||
private function statusText(): string
|
||||
{
|
||||
/** @var Composition $composition */
|
||||
$composition = $this->getRecord();
|
||||
$version = $this->currentReadyVersion();
|
||||
|
||||
if ($version === null) {
|
||||
return 'Noch keine technisch bereite Fassung. Speichern legt die erste Fassung an.';
|
||||
}
|
||||
|
||||
$released = app(CompositionDisplayRelease::class)->isReleased($version);
|
||||
$older = $composition->versions()->where('number', '<', $version->number)->orderBy('number')->pluck('number')->all();
|
||||
$history = $older === [] ? 'Es gibt keine ältere Fassung.' : 'Ältere Fassungen: '.implode(', ', $older).'.';
|
||||
|
||||
return 'Fassung '.$version->number.' ist technisch bereit. '
|
||||
.($released ? 'Sie ist zur Anzeige freigegeben. ' : 'Sie ist noch nicht zur Anzeige freigegeben. ')
|
||||
.$history;
|
||||
}
|
||||
|
||||
private function outlineHtml(): string
|
||||
{
|
||||
$version = $this->currentReadyVersion();
|
||||
|
||||
if ($version === null) {
|
||||
return 'Die Gliederung erscheint, sobald eine Fassung bereit ist.';
|
||||
}
|
||||
|
||||
$lines = [];
|
||||
$this->outlineLines(app(CompositionStructureReader::class)->tree($version), 0, $lines);
|
||||
|
||||
return $lines === [] ? 'Diese Fassung hat noch keine Bestandteile.' : implode('<br>', array_map(e(...), $lines));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<StructureNode> $nodes
|
||||
* @param list<string> $lines
|
||||
*/
|
||||
private function outlineLines(array $nodes, int $depth, array &$lines): void
|
||||
{
|
||||
foreach ($nodes as $node) {
|
||||
$lines[] = str_repeat('– ', $depth).$node->role.': '.$node->title;
|
||||
$this->outlineLines($node->children, $depth + 1, $lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
@@ -26,7 +27,11 @@ protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label($this->kind()->createLabel())
|
||||
->label(match ($this->kind()) {
|
||||
CompositionKind::Kurs => 'Programm anlegen',
|
||||
CompositionKind::Uebung => 'Modul anlegen',
|
||||
default => $this->kind()->createLabel(),
|
||||
})
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('designation')->label('Bezeichnung')->required(),
|
||||
@@ -35,6 +40,16 @@ protected function getHeaderActions(): array
|
||||
$composition = null;
|
||||
$this->report(function () use ($data, &$composition): void {
|
||||
$composition = app(ContentService::class)->createComposition($data['designation'], $this->kind());
|
||||
$slug = match ($this->kind()) {
|
||||
CompositionKind::Kurs => 'programm',
|
||||
CompositionKind::Uebung => 'modul',
|
||||
default => null,
|
||||
};
|
||||
$editorial = $slug === null ? null : EditorialContentKind::query()->where('slug', $slug)->first();
|
||||
if ($editorial !== null) {
|
||||
$composition->editorial_content_kind_id = $editorial->id;
|
||||
$composition->save();
|
||||
}
|
||||
}, $this->kind()->label().' ist angelegt.');
|
||||
|
||||
if ($composition !== null) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -31,32 +31,30 @@ protected function getHeaderActions(): array
|
||||
->label('Medium anlegen')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
Select::make('kind')->label('Art')->options([
|
||||
TextInput::make('working_title')->label('Titel')->required(),
|
||||
Select::make('shape')->label('Was ist das?')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Audio',
|
||||
'audio' => 'Hörstück',
|
||||
'bild' => 'Bild',
|
||||
'pdf' => 'PDF',
|
||||
'document' => 'Dokument',
|
||||
'text' => 'Text',
|
||||
'aufgabe' => 'Aufgabe',
|
||||
])->required(),
|
||||
Select::make('output_class')->label('Ausgabeklasse')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Audio',
|
||||
'bild' => 'Bild',
|
||||
'pdf' => 'PDF',
|
||||
'text' => 'Text',
|
||||
])->required(),
|
||||
Textarea::make('body')->label('Text'),
|
||||
EditContentElement::uploadField(),
|
||||
TextInput::make('decision_seconds')->label('Entscheidungsmarke in Sekunden')->numeric()->minValue(0),
|
||||
TextInput::make('change_note')->label('Änderungsnotiz'),
|
||||
])->required()->live(),
|
||||
Textarea::make('body')->label('Text')->visible(fn ($get): bool => $get('shape') === 'text'),
|
||||
EditContentElement::uploadField()->visible(fn ($get): bool => $get('shape') !== 'text'),
|
||||
TextInput::make('change_note')->label('Notiz zur ersten Fassung'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$element = null;
|
||||
$this->report(function () use ($data, &$element): void {
|
||||
$service = app(ContentService::class);
|
||||
$element = $service->createElement($data['kind'], $data['output_class'], $data['working_title']);
|
||||
[$kind, $output] = match ($data['shape']) {
|
||||
'audio' => ['audio', 'audio'],
|
||||
'bild' => ['bild', 'bild'],
|
||||
'document' => ['dokument', 'document'],
|
||||
'text' => ['text', 'text'],
|
||||
default => ['film', 'film'],
|
||||
};
|
||||
$element = $service->createElement($kind, $output, $data['working_title']);
|
||||
$metadata = [];
|
||||
$incoming = IncomingFile::store($data['incoming'] ?? null);
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ class CourseResource extends CompositionKindResource
|
||||
{
|
||||
protected static ?string $slug = 'kurse';
|
||||
|
||||
protected static ?string $navigationLabel = 'Kurse';
|
||||
protected static ?string $navigationLabel = 'Programme';
|
||||
|
||||
protected static ?string $modelLabel = 'Kurs';
|
||||
protected static ?string $modelLabel = 'Programm';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Kurse';
|
||||
protected static ?string $pluralModelLabel = 'Programme';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ class ExerciseResource extends CompositionKindResource
|
||||
{
|
||||
protected static ?string $slug = 'uebungen';
|
||||
|
||||
protected static ?string $navigationLabel = 'Übungen';
|
||||
protected static ?string $navigationLabel = 'Module';
|
||||
|
||||
protected static ?string $modelLabel = 'Übung';
|
||||
protected static ?string $modelLabel = 'Modul';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Übungen';
|
||||
protected static ?string $pluralModelLabel = 'Module';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Offers\Pages;
|
||||
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
@@ -34,6 +35,18 @@ protected function getHeaderActions(): array
|
||||
])->required(),
|
||||
TextInput::make('price_cents')->label('Preis in Cent')->numeric()
|
||||
->helperText('Nur bei einem Kauf. 500 bedeutet 5,00 €.'),
|
||||
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
|
||||
->options(function (): array {
|
||||
return CompositionVersion::query()
|
||||
->where('status', 'bereit')
|
||||
->with('composition.editorialContentKind')
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->mapWithKeys(fn (CompositionVersion $version): array => [$version->id => CatalogOptions::compositionLabel($version)])
|
||||
->all();
|
||||
})
|
||||
->searchable()
|
||||
->helperText('Wenn gewählt, lässt sich die Fassung nur aktivieren, wenn jeder Bestandteil in den Artikeln enthalten ist.'),
|
||||
Repeater::make('lines')->label('Positionen')->schema([
|
||||
Select::make('kind')->label('Ziel')->options([
|
||||
'article' => 'Lizenzartikel',
|
||||
@@ -65,6 +78,7 @@ protected function getHeaderActions(): array
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'],
|
||||
'holder_kind' => 'person',
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
}, 'Die Angebotsfassung ist aktiv.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
|
||||
@@ -34,11 +34,13 @@ protected function getHeaderActions(): array
|
||||
'institutionell' => 'Institutionell',
|
||||
])->required(),
|
||||
CheckboxList::make('capabilities')->label('Fähigkeiten')->options([
|
||||
'film:streamen' => 'Film streamen',
|
||||
'film:ansehen' => 'Film ansehen',
|
||||
'audio:streamen' => 'Audio streamen',
|
||||
'film:streamen' => 'Film ansehen',
|
||||
'film:laden' => 'Film herunterladen',
|
||||
'audio:streamen' => 'Hörstück ansehen',
|
||||
'document:ansehen' => 'Dokument ansehen',
|
||||
'document:laden' => 'Dokument herunterladen',
|
||||
'pdf:ansehen' => 'PDF ansehen',
|
||||
'pdf:laden' => 'PDF laden',
|
||||
'pdf:laden' => 'PDF herunterladen',
|
||||
'text:ansehen' => 'Text ansehen',
|
||||
'bild:ansehen' => 'Bild ansehen',
|
||||
])->required(),
|
||||
|
||||
@@ -30,23 +30,57 @@ public static function elements(): array
|
||||
*/
|
||||
public static function assignmentTargets(?int $exceptCompositionId = null): array
|
||||
{
|
||||
$options = [];
|
||||
$media = [];
|
||||
$structures = [];
|
||||
|
||||
foreach (ContentElementVersion::query()->where('status', ContentVersionStatus::Bereit)->with('element')->orderBy('id')->get() as $version) {
|
||||
$options['element:'.$version->id] = 'Medium: '.$version->element->working_title.' · Fassung '.$version->number;
|
||||
foreach (ContentElementVersion::query()->where('status', ContentVersionStatus::Bereit)->with('element.editorialContentKind')->orderBy('id')->get() as $version) {
|
||||
$media['element:'.$version->id] = self::elementLabel($version);
|
||||
}
|
||||
|
||||
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition')->orderBy('id')->get() as $version) {
|
||||
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition.editorialContentKind')->orderBy('id')->get() as $version) {
|
||||
if ($exceptCompositionId !== null && (int) $version->composition_id === $exceptCompositionId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$kind = $version->composition->kind;
|
||||
$label = $kind instanceof CompositionKind ? $kind->label() : 'Zusammenstellung';
|
||||
$options['composition:'.$version->id] = $label.': '.$version->composition->designation.' · Fassung '.$version->number;
|
||||
$structures['composition:'.$version->id] = self::compositionLabel($version);
|
||||
}
|
||||
|
||||
return $options;
|
||||
return array_filter([
|
||||
'Medien und Dokumente' => $media,
|
||||
'Module und Programme' => $structures,
|
||||
]);
|
||||
}
|
||||
|
||||
public static function elementLabel(ContentElementVersion $version): string
|
||||
{
|
||||
$kind = $version->element->editorialContentKind?->label;
|
||||
$kind = $kind ?: self::outputLabel((string) $version->element->output_class);
|
||||
|
||||
return $version->element->working_title.', '.$kind.', Fassung '.$version->number;
|
||||
}
|
||||
|
||||
public static function compositionLabel(CompositionVersion $version): string
|
||||
{
|
||||
$editorial = $version->composition->editorialContentKind?->label;
|
||||
$technical = $version->composition->kind;
|
||||
$kind = $editorial ?: ($technical instanceof CompositionKind ? $technical->label() : 'Zusammenstellung');
|
||||
$title = filled($version->composition->display_title)
|
||||
? $version->composition->display_title
|
||||
: $version->composition->designation;
|
||||
|
||||
return $title.', '.$kind.', Fassung '.$version->number;
|
||||
}
|
||||
|
||||
private static function outputLabel(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'film' => 'Film',
|
||||
'audio' => 'Hörstück',
|
||||
'bild' => 'Bild',
|
||||
'document', 'pdf' => 'Dokument',
|
||||
'text' => 'Text',
|
||||
default => 'Medium',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,12 +90,12 @@ public static function readyTargets(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (ContentElementVersion::query()->where('status', ContentVersionStatus::Bereit)->with('element')->orderBy('id')->get() as $version) {
|
||||
$options['element:'.$version->id] = $version->element->working_title.' · Fassung '.$version->number;
|
||||
foreach (ContentElementVersion::query()->where('status', ContentVersionStatus::Bereit)->with('element.editorialContentKind')->orderBy('id')->get() as $version) {
|
||||
$options['element:'.$version->id] = self::elementLabel($version);
|
||||
}
|
||||
|
||||
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition')->orderBy('id')->get() as $version) {
|
||||
$options['composition:'.$version->id] = $version->composition->designation.' · Fassung '.$version->number;
|
||||
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition.editorialContentKind')->orderBy('id')->get() as $version) {
|
||||
$options['composition:'.$version->id] = self::compositionLabel($version);
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
||||
Reference in new issue
Block a user