Ordne Übungsabschnitte im Medienbestand ein und filtere Materialarten mehrfach
- Medium anlegen: Pflichtfeld Fachliche Materialart (serverseitig geprüft) - Materialart Übungsabschnitt (automatisch) für Abschnitte im Übungseditor und aus Shinkan, mit Verweis auf die Übung - Medienmanager: Checkboxen statt Dropdown, Start ohne Übungsabschnitte, persönlicher Standard je Konto - Zuordnung des Bestands nur bei belegter Herkunft; Übungsabschnitte nie öffentlich Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
99122ddfee
commit
ad581cb545
29 files changed
+1321
-25
No files matched your search
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
@@ -29,7 +30,12 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
];
|
||||
|
||||
if ($creating) {
|
||||
$fields[] = Select::make('shape')->label('Was ist das?')->options([
|
||||
$fields[] = Select::make('editorial_content_kind_id')
|
||||
->label('Fachliche Materialart')
|
||||
->options(fn (): array => app(EditorialVocabulary::class)->kindOptions('medium'))
|
||||
->required()
|
||||
->helperText('Die redaktionelle Einordnung, zum Beispiel Merkblatt. Sie steht in der Medienliste und lässt sich dort filtern. Die technische Art wählst du darunter.');
|
||||
$fields[] = Select::make('shape')->label('Technische Art')->options([
|
||||
'film' => 'Film',
|
||||
'audio' => 'Hörstück',
|
||||
'bild' => 'Bild',
|
||||
@@ -95,6 +101,7 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
{
|
||||
$service = app(ContentService::class);
|
||||
[$kind, $output] = self::shape($data['shape'] ?? null);
|
||||
$kindId = self::contentKindId($data);
|
||||
$incoming = null;
|
||||
|
||||
if ($output !== 'text') {
|
||||
@@ -123,6 +130,8 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
}
|
||||
|
||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||
$element->editorial_content_kind_id = $kindId;
|
||||
$element->save();
|
||||
self::remember($element, $data);
|
||||
|
||||
if ($output === 'text') {
|
||||
@@ -155,6 +164,28 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
return $element->fresh() ?? $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die fachliche Materialart ist beim Anlegen Pflicht und muss für Medien zulässig und aktiv sein.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
private static function contentKindId(array $data): int
|
||||
{
|
||||
$id = $data['editorial_content_kind_id'] ?? null;
|
||||
|
||||
if (! filled($id) || ! ctype_digit((string) $id)) {
|
||||
throw new DomainRuleException('Die fachliche Materialart fehlt.');
|
||||
}
|
||||
|
||||
$error = app(EditorialVocabulary::class)->kindError('medium', (int) $id, null);
|
||||
|
||||
if ($error !== null) {
|
||||
throw new DomainRuleException($error);
|
||||
}
|
||||
|
||||
return (int) $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user