Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa79143910 | ||
|
|
3f81781607 | ||
|
|
5bd72dedab | ||
|
|
7e7019b717 | ||
|
|
61c7c5c3d3 | ||
|
|
edfe743d7d | ||
|
|
a5466896aa | ||
|
|
d03fcfceaf | ||
|
|
63b42b366c | ||
|
|
0492133201 | ||
|
|
23978d26da | ||
|
|
41bf9a0220 | ||
|
|
380a3013c7 |
No files matched your search
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt für vorhandene Bilder die kleineren Fassungen an (docs/architektur/bildvarianten.md). Neue Bilder bekommen sie beim
|
||||||
|
* Ableiten; dieser Befehl holt den Bestand nach. Die Arbeit macht die Warteschlange (nur sie darf in derived/ und public/
|
||||||
|
* schreiben); mit --now läuft sie hier im Prozess, den man dafür im Queue-Container startet.
|
||||||
|
*/
|
||||||
|
class DeriveMediaVariants extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'media:varianten {--now : Sofort hier ausführen statt in die Warteschlange zu legen} {--pretend : Nur zählen}';
|
||||||
|
|
||||||
|
protected $description = 'Legt für vorhandene Vorschaubilder und freigegebene Website-Bilder die kleineren Fassungen an';
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$derived = Storage::disk('media_derived');
|
||||||
|
$paths = [];
|
||||||
|
|
||||||
|
foreach ([ContentElement::query(), Composition::query()] as $query) {
|
||||||
|
$query->where('thumbnail_path', 'like', 'vorschau/%')
|
||||||
|
->pluck('thumbnail_path')
|
||||||
|
->each(function (mixed $path) use (&$paths): void {
|
||||||
|
if (is_string($path)) {
|
||||||
|
$paths[$path] = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$missing = array_values(array_filter(
|
||||||
|
array_keys($paths),
|
||||||
|
fn (string $path): bool => ! str_contains($path, '..')
|
||||||
|
&& ! $derived->exists(ImageVariants::path($path, 'klein'))
|
||||||
|
&& $derived->exists($path),
|
||||||
|
));
|
||||||
|
|
||||||
|
$websiteIds = ContentElement::query()
|
||||||
|
->where('output_class', 'bild')
|
||||||
|
->whereNotNull('website_released_at')
|
||||||
|
->whereNotNull('website_public_path')
|
||||||
|
->pluck('id')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$this->info(count($missing).' Vorschaubilder ohne Fassungen, '.count($websiteIds).' freigegebene Website-Bilder.');
|
||||||
|
|
||||||
|
if ($this->option('pretend')) {
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($missing as $path) {
|
||||||
|
$this->option('now') ? DeriveImageVariants::dispatchSync($path) : DeriveImageVariants::dispatch($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($websiteIds as $id) {
|
||||||
|
$this->option('now') ? DeriveWebsiteVariants::dispatchSync((int) $id) : DeriveWebsiteVariants::dispatch((int) $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info($this->option('now') ? 'Fassungen angelegt.' : 'In die Warteschlange gelegt.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@ public function rows(Model $subject): array
|
|||||||
? (string) ($element->display_title ?: $element->working_title)
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
: 'Medium fehlt',
|
: 'Medium fehlt',
|
||||||
'image' => $element instanceof ContentElement
|
'image' => $element instanceof ContentElement
|
||||||
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'kind' => $element?->editorialContentKind?->label,
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
@@ -134,7 +134,7 @@ public function describe(array $staged): array
|
|||||||
? (string) ($element->display_title ?: $element->working_title)
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
: 'Medium fehlt',
|
: 'Medium fehlt',
|
||||||
'image' => $element instanceof ContentElement
|
'image' => $element instanceof ContentElement
|
||||||
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'kind' => $element?->editorialContentKind?->label,
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public static function previewUrl(?string $target): ?string
|
|||||||
return route('website.media', $element);
|
return route('website.media', $element);
|
||||||
}
|
}
|
||||||
|
|
||||||
return app(EditorialCatalog::class)->cardUrl('element', $element->id, $element->thumbnail_path);
|
return app(EditorialCatalog::class)->cardUrl('element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
|||||||
notice: $notice,
|
notice: $notice,
|
||||||
visual: 'catalog',
|
visual: 'catalog',
|
||||||
visualLabel: $kind,
|
visualLabel: $kind,
|
||||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at) : null,
|
||||||
missing: $missing,
|
missing: $missing,
|
||||||
texts: $texts,
|
texts: $texts,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null;
|
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path, 'mittel', $shown->updated_at) : null;
|
||||||
|
|
||||||
return new CardSubject(
|
return new CardSubject(
|
||||||
title: $title,
|
title: $title,
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Überträgt einen Abschnitt auf eine andere Seite: als Kopie (neue Kennungen) oder als Verschiebung (Kennungen
|
||||||
|
* bleiben). Die Zielseite erhält eine neue, unveröffentlichte Revision; veröffentlicht wird nichts. Das Entfernen
|
||||||
|
* aus der Quellseite beim Verschieben ist Sache des Aufrufers (Seiteneditor), weil dort der Arbeitsstand liegt.
|
||||||
|
*/
|
||||||
|
class SectionTransfer
|
||||||
|
{
|
||||||
|
public const START = 'start';
|
||||||
|
|
||||||
|
public const END = 'end';
|
||||||
|
|
||||||
|
public function __construct(private readonly PageService $pages, private readonly PageSections $sections) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abschnitte, die der Editor der Seite zeigt (Entwurf vor Veröffentlichung).
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function sectionsOf(Page $page): array
|
||||||
|
{
|
||||||
|
return ($page->latestRevision ?? $page->publishedRevision)?->sections() ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wählbare Positionen auf der Zielseite: Anfang, Ende und hinter jedem vorhandenen Abschnitt.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function positions(Page $target): array
|
||||||
|
{
|
||||||
|
$sections = $this->sectionsOf($target);
|
||||||
|
|
||||||
|
if ($sections === []) {
|
||||||
|
return [self::END => 'Als ersten Abschnitt einfügen (die Seite hat noch keinen)'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = [self::START => 'Am Anfang der Seite', self::END => 'Am Ende der Seite'];
|
||||||
|
|
||||||
|
foreach ($sections as $index => $section) {
|
||||||
|
$options['after:'.($index + 1)] = 'Hinter Abschnitt '.($index + 1).': '.$this->label($section);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name des Abschnitts, sonst die erste Überschrift darin, sonst das Raster.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section
|
||||||
|
*/
|
||||||
|
public function label(array $section): string
|
||||||
|
{
|
||||||
|
$name = PageSections::cleanName($section['name'] ?? null);
|
||||||
|
|
||||||
|
if ($name !== null) {
|
||||||
|
return Str::limit($name, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((array) ($section['slots'] ?? []) as $widget) {
|
||||||
|
$data = is_array($widget) && is_array($widget['data'] ?? null) ? $widget['data'] : [];
|
||||||
|
|
||||||
|
foreach (['heading', 'title', 'headline'] as $field) {
|
||||||
|
if (is_string($data[$field] ?? null) && trim(strip_tags($data[$field])) !== '') {
|
||||||
|
return Str::limit(trim(strip_tags($data[$field])), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'ohne Namen';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt den Abschnitt auf der Zielseite ein. Wirft eine ValidationException, wenn die Zielseite damit ungültig
|
||||||
|
* würde (zu viele Abschnitte oder Widgets); dann ist nichts geschrieben.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section Abschnitt im Modell (wie PageSections::read liefert)
|
||||||
|
* @return array{revision: PageRevision, position: int, anchor: ?string, anchorChanged: bool}
|
||||||
|
*/
|
||||||
|
public function insert(Page $target, array $section, string $position, bool $fresh, ?User $author): array
|
||||||
|
{
|
||||||
|
$plan = $this->plan($target, $section, $position, $fresh);
|
||||||
|
$revision = ($target->latestRevision ?? $target->publishedRevision);
|
||||||
|
|
||||||
|
$saved = $this->pages->saveRevision($target, $plan['content'], $revision?->seo_title, $revision?->seo_description, $author);
|
||||||
|
$target->unsetRelation('latestRevision');
|
||||||
|
|
||||||
|
return ['revision' => $saved, 'position' => $plan['position'], 'anchor' => $plan['anchor'], 'anchorChanged' => $plan['anchorChanged']];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft, ob die Zielseite mit dem Abschnitt gültig bleibt, ohne zu schreiben.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section
|
||||||
|
* @return array{content: list<array<string, mixed>>, position: int, anchor: ?string, anchorChanged: bool}
|
||||||
|
*/
|
||||||
|
public function plan(Page $target, array $section, string $position, bool $fresh): array
|
||||||
|
{
|
||||||
|
$existing = $this->sectionsOf($target);
|
||||||
|
|
||||||
|
if (count($existing) >= PageSections::MAX_SECTIONS) {
|
||||||
|
throw ValidationException::withMessages(['sections' => 'Eine Seite hat höchstens '.PageSections::MAX_SECTIONS.' Abschnitte. Die Zielseite ist voll.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fresh) {
|
||||||
|
$section['id'] = null;
|
||||||
|
$section['slots'] = array_map(fn ($widget) => is_array($widget) ? array_replace($widget, ['id' => null]) : $widget, array_values((array) ($section['slots'] ?? [])));
|
||||||
|
}
|
||||||
|
|
||||||
|
[$anchor, $changed] = $this->freeAnchor($section['anchor'] ?? null, $existing);
|
||||||
|
$section['anchor'] = $anchor;
|
||||||
|
|
||||||
|
$at = $this->index($position, count($existing));
|
||||||
|
array_splice($existing, $at, 0, [$section]);
|
||||||
|
|
||||||
|
// Prüft die ganze Zielseite (Abschnitts- und Widget-Höchstzahl, Regeln der Bausteine); Fehler bricht ab.
|
||||||
|
$this->sections->normalize($existing);
|
||||||
|
|
||||||
|
return ['content' => $existing, 'position' => $at + 1, 'anchor' => $anchor, 'anchorChanged' => $changed];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Sprungmarke bleibt, wenn sie auf der Zielseite frei ist; sonst wird sie mit „-2“, „-3“ … eindeutig gemacht.
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $existing
|
||||||
|
* @return array{0: ?string, 1: bool}
|
||||||
|
*/
|
||||||
|
private function freeAnchor(mixed $anchor, array $existing): array
|
||||||
|
{
|
||||||
|
$anchor = PageSections::cleanAnchor($anchor);
|
||||||
|
|
||||||
|
if ($anchor === null) {
|
||||||
|
return [null, false];
|
||||||
|
}
|
||||||
|
|
||||||
|
$taken = array_values(array_filter(array_map(fn (array $section): ?string => PageSections::cleanAnchor($section['anchor'] ?? null), $existing)));
|
||||||
|
|
||||||
|
if (PageSections::anchorProblem($anchor, $taken) === null) {
|
||||||
|
return [$anchor, false];
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($number = 2; $number <= 50; $number++) {
|
||||||
|
$suffix = '-'.$number;
|
||||||
|
$candidate = rtrim(substr($anchor, 0, PageSections::MAX_ANCHOR - strlen($suffix)), '-').$suffix;
|
||||||
|
|
||||||
|
if (PageSections::anchorProblem($candidate, $taken) === null) {
|
||||||
|
return [$candidate, true];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [null, true];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function index(string $position, int $count): int
|
||||||
|
{
|
||||||
|
if ($position === self::START) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^after:(\d+)$/', $position, $match) === 1) {
|
||||||
|
return max(0, min($count, (int) $match[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -364,13 +364,10 @@ private function normalizeLabels(array $section, string $prefix, array &$errors,
|
|||||||
|
|
||||||
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
||||||
$candidate = mb_strtolower(trim($rawAnchor));
|
$candidate = mb_strtolower(trim($rawAnchor));
|
||||||
|
$problem = self::anchorProblem($candidate, array_keys($seenAnchors));
|
||||||
|
|
||||||
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
if ($problem !== null) {
|
||||||
$errors["$prefix.anchor"] = ['Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.'];
|
$errors["$prefix.anchor"] = [$problem];
|
||||||
} elseif (in_array($candidate, self::RESERVED_ANCHORS, true) || str_starts_with($candidate, 'bereich-')) {
|
|
||||||
$errors["$prefix.anchor"] = ['Diese Sprungmarke ist im Seitengerüst schon vergeben. Bitte eine andere wählen.'];
|
|
||||||
} elseif (isset($seenAnchors[$candidate])) {
|
|
||||||
$errors["$prefix.anchor"] = ['Diese Sprungmarke gibt es auf der Seite schon. Jede Sprungmarke darf nur einmal vorkommen.'];
|
|
||||||
} else {
|
} else {
|
||||||
$seenAnchors[$candidate] = true;
|
$seenAnchors[$candidate] = true;
|
||||||
$anchor = $candidate;
|
$anchor = $candidate;
|
||||||
@@ -382,6 +379,29 @@ private function normalizeLabels(array $section, string $prefix, array &$errors,
|
|||||||
return [$name, $anchor];
|
return [$name, $anchor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warum eine Sprungmarke nicht zulässig ist (Form, reserviert, schon vergeben), sonst null. Gilt beim Speichern der
|
||||||
|
* Seite und im Einstellungsdialog des Abschnitts mit demselben Wortlaut.
|
||||||
|
*
|
||||||
|
* @param list<string|int> $taken Sprungmarken der übrigen Abschnitte
|
||||||
|
*/
|
||||||
|
public static function anchorProblem(string $candidate, array $taken): ?string
|
||||||
|
{
|
||||||
|
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
||||||
|
return 'Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($candidate, self::RESERVED_ANCHORS, true) || str_starts_with($candidate, 'bereich-')) {
|
||||||
|
return 'Diese Sprungmarke ist im Seitengerüst schon vergeben. Bitte eine andere wählen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($candidate, array_map('strval', $taken), true)) {
|
||||||
|
return 'Diese Sprungmarke gibt es auf der Seite schon. Jede Sprungmarke darf nur einmal vorkommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
||||||
public static function cleanName(mixed $value): ?string
|
public static function cleanName(mixed $value): ?string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
|||||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||||
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
||||||
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
|
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview, 1920) : null;
|
||||||
$hasImage = $imageUrl !== null;
|
$hasImage = $imageUrl !== null;
|
||||||
|
|
||||||
$classes = [
|
$classes = [
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public function elementId(mixed $value): ?int
|
|||||||
return is_int($id) ? $id : null;
|
return is_int($id) ? $id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function presentation(mixed $value): ?WebsitePresentation
|
public function presentation(mixed $value, ?ContentElement $loaded = null): ?WebsitePresentation
|
||||||
{
|
{
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
@@ -95,7 +95,8 @@ public function presentation(mixed $value): ?WebsitePresentation
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! array_key_exists($id, $this->presentations)) {
|
if (! array_key_exists($id, $this->presentations)) {
|
||||||
$this->presentations[$id] = $this->media->present($id) ?? false;
|
// Ein schon geladenes Medium wird weitergereicht (kein zweiter Zugriff je Eintrag in der Auswahl).
|
||||||
|
$this->presentations[$id] = $this->media->present($loaded?->getKey() === $id ? $loaded : $id) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->presentations[$id] ?: null;
|
return $this->presentations[$id] ?: null;
|
||||||
@@ -105,12 +106,12 @@ public function presentation(mixed $value): ?WebsitePresentation
|
|||||||
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
||||||
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
||||||
*/
|
*/
|
||||||
public function url(mixed $value, bool $preview = false): ?string
|
public function url(mixed $value, bool $preview = false, ?int $width = null): ?string
|
||||||
{
|
{
|
||||||
$presentation = $this->presentation($value);
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
if ($presentation !== null) {
|
if ($presentation !== null) {
|
||||||
return $presentation->kind === 'bild' ? $presentation->url : null;
|
return $presentation->kind === 'bild' ? $presentation->urlForWidth($width) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
@@ -122,7 +123,7 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
|
|
||||||
$element = ContentElement::query()->find($id);
|
$element = ContentElement::query()->find($id);
|
||||||
|
|
||||||
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
$legacy = self::normalize($value);
|
$legacy = self::normalize($value);
|
||||||
@@ -134,6 +135,14 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** `srcset` des freigegebenen Bildes (mehrere Breiten), sonst null. Für Hero, Bild mit Text, Karten. */
|
||||||
|
public function srcset(mixed $value): ?string
|
||||||
|
{
|
||||||
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
|
return $presentation !== null && $presentation->kind === 'bild' ? $presentation->srcset : null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
||||||
public function alt(mixed $value, mixed $override = null): string
|
public function alt(mixed $value, mixed $override = null): string
|
||||||
{
|
{
|
||||||
@@ -169,7 +178,7 @@ public function previewNotice(mixed $value, string $label = 'Das gewählte Bild'
|
|||||||
*
|
*
|
||||||
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
||||||
*/
|
*/
|
||||||
public function status(mixed $value): ?array
|
public function status(mixed $value, ?ContentElement $loaded = null): ?array
|
||||||
{
|
{
|
||||||
$value = self::normalize($value);
|
$value = self::normalize($value);
|
||||||
|
|
||||||
@@ -194,16 +203,16 @@ public function status(mixed $value): ?array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
$element = $loaded?->getKey() === $id ? $loaded : ContentElement::query()->with('editorialContentKind')->find($id);
|
||||||
|
|
||||||
if ($element === null) {
|
if ($element === null) {
|
||||||
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = (string) ($element->display_title ?: $element->working_title);
|
$title = (string) ($element->display_title ?: $element->working_title);
|
||||||
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
||||||
$public = $this->presentation($id) !== null;
|
$public = $this->presentation($id, $element) !== null;
|
||||||
|
|
||||||
$note = match (true) {
|
$note = match (true) {
|
||||||
$public => 'Für die Website freigegeben.',
|
$public => 'Für die Website freigegeben.',
|
||||||
@@ -292,7 +301,7 @@ public function options(?string $search = null, int $limit = 60): array
|
|||||||
$options = [];
|
$options = [];
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if (self::isSelectable($element)) {
|
if (self::isSelectable($element)) {
|
||||||
$options[$element->id] = $this->optionHtml($element->id);
|
$options[$element->id] = $this->optionHtml($element->id, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,9 +309,9 @@ public function options(?string $search = null, int $limit = 60): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
||||||
public function optionHtml(mixed $value): ?string
|
public function optionHtml(mixed $value, ?ContentElement $loaded = null): ?string
|
||||||
{
|
{
|
||||||
$status = $this->status($value);
|
$status = $this->status($value, $loaded);
|
||||||
|
|
||||||
if ($status === null) {
|
if ($status === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -315,7 +324,7 @@ public function optionHtml(mixed $value): ?string
|
|||||||
default => ['warn', 'Website: nicht freigegeben'],
|
default => ['warn', 'Website: nicht freigegeben'],
|
||||||
};
|
};
|
||||||
$thumb = $status['thumb'] !== null
|
$thumb = $status['thumb'] !== null
|
||||||
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy">'
|
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy" decoding="async">'
|
||||||
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
||||||
|
|
||||||
return '<span class="luf-media-option">'.$thumb
|
return '<span class="luf-media-option">'.$thumb
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
||||||
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
||||||
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||||
|
'imageSrcset' => $images->srcset($item['image'] ?? null),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||||
|
|||||||
@@ -250,6 +250,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
return [
|
return [
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
'imageUrl' => $images->url($image, $context->preview),
|
'imageUrl' => $images->url($image, $context->preview),
|
||||||
|
'imageSrcset' => $images->srcset($image),
|
||||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
|
|||||||
@@ -329,6 +329,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'imageUrl' => $imageUrl,
|
'imageUrl' => $imageUrl,
|
||||||
|
'imageSrcset' => $imageUrl === null ? null : $images->srcset($image),
|
||||||
'imageAlt' => $imageAlt,
|
'imageAlt' => $imageAlt,
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ public function schematic(): array
|
|||||||
public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mode' => ['compact' => 'Langes Formular', 'wizard' => 'Mehrstufiger Dialog'],
|
'mode' => ['compact' => 'Langes Formular', 'wizard' => 'Mehrstufig, Schritt für Schritt'],
|
||||||
'open' => ['inline' => 'Im Abschnitt', 'modal' => 'Als Dialog über der Seite'],
|
'open' => ['inline' => 'Im Abschnitt', 'modal' => 'Im Pop-up-Fenster über der Seite'],
|
||||||
'picker' => ['cards' => 'Karten', 'select' => 'Auswahlfeld'],
|
'picker' => ['cards' => 'Karten', 'select' => 'Auswahlfeld'],
|
||||||
'width' => ['normal' => 'Standard', 'narrow' => 'Schmal', 'wide' => 'Breit'],
|
'width' => ['normal' => 'Standard', 'narrow' => 'Schmal', 'wide' => 'Breit'],
|
||||||
'spacing' => ['normal' => 'Standard', 'compact' => 'Kompakt', 'airy' => 'Großzügig'],
|
'spacing' => ['normal' => 'Standard', 'compact' => 'Kompakt', 'airy' => 'Großzügig'],
|
||||||
@@ -97,13 +97,13 @@ public function settings(): array
|
|||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'mode' => ['Formularführung', 'Langes Formular: alle Bereiche stehen auf einer Seite, bedingte Felder erscheinen je nach Eingabe. Mehrstufiger Dialog: die Bereiche werden Schritt für Schritt mit Fortschrittsanzeige durchlaufen. Vorgabe: Langes Formular.'],
|
'mode' => ['Formularführung', 'Wie das Formular aufgebaut ist, nicht wo es steht. Langes Formular: alle Bereiche stehen untereinander, bedingte Felder erscheinen je nach Eingabe. Mehrstufig: die Bereiche werden Schritt für Schritt mit Fortschrittsanzeige durchlaufen. Ob das Formular im Abschnitt oder in einem Pop-up-Fenster erscheint, legt „Präsentation“ fest. Vorgabe: Langes Formular.'],
|
||||||
'open' => ['Präsentation', 'Im Abschnitt: das Formular steht direkt auf der Seite. Als Dialog: ein Button öffnet das Formular über der Seite; auf dem Smartphone füllt er den Bildschirm. Vorgabe: Im Abschnitt.'],
|
'open' => ['Präsentation', 'Wo das Formular erscheint, unabhängig von „Formularführung“. Im Abschnitt: das Formular steht direkt auf der Seite. Im Pop-up-Fenster: ein Button öffnet das Formular in einem Fenster über der Seite; auf dem Smartphone füllt es den Bildschirm. Vorgabe: Im Abschnitt.'],
|
||||||
'picker' => ['Auswahl des Anfragegrundes', 'Karten zeigen die Gründe mit Beschreibung nebeneinander, das Auswahlfeld braucht wenig Platz. Bei nur einem Grund entfällt die Auswahl. Vorgabe: Karten.'],
|
'picker' => ['Auswahl des Anfragegrundes', 'Karten zeigen die Gründe mit Beschreibung nebeneinander, das Auswahlfeld braucht wenig Platz. Bei nur einem Grund entfällt die Auswahl. Vorgabe: Karten.'],
|
||||||
'width' => ['Breite des Formulars', 'Vorgabe: Standard. Das Formular nutzt höchstens die Breite des Platzes.'],
|
'width' => ['Breite des Formulars', 'Vorgabe: Standard. Das Formular nutzt höchstens die Breite des Platzes.'],
|
||||||
'spacing' => ['Abstände', 'Abstand zwischen den Feldern. Vorgabe: Standard.'],
|
'spacing' => ['Abstände', 'Abstand zwischen den Feldern. Vorgabe: Standard.'],
|
||||||
'columns' => ['Anordnung der Felder', 'Automatisch: Felder gleicher Art (zum Beispiel Vor- und Nachname) stehen bei viel Platz nebeneinander. Vorgabe: Automatisch.'],
|
'columns' => ['Anordnung der Felder', 'Automatisch: Felder gleicher Art (zum Beispiel Vor- und Nachname) stehen bei viel Platz nebeneinander. Vorgabe: Automatisch.'],
|
||||||
'button' => ['Buttondarstellung', 'Gilt für den Button, der den Dialog öffnet, und für „Weiter“ und „Absenden“. Vorgabe: Gefüllt.'],
|
'button' => ['Buttondarstellung', 'Gilt für den Button, der das Pop-up-Fenster öffnet, und für „Weiter“ und „Absenden“. Vorgabe: Gefüllt.'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,8 +169,8 @@ public function dataFields(): array
|
|||||||
->itemLabel(fn (array $state): ?string => $state['label'] ?? null),
|
->itemLabel(fn (array $state): ?string => $state['label'] ?? null),
|
||||||
TextInput::make('question')->label('Frage zur Auswahl des Grundes')->maxLength(160)->placeholder('Worum geht es?')
|
TextInput::make('question')->label('Frage zur Auswahl des Grundes')->maxLength(160)->placeholder('Worum geht es?')
|
||||||
->helperText('Steht über der Auswahl, wenn mehr als ein Grund angeboten wird. Leer: „Worum geht es?“.'),
|
->helperText('Steht über der Auswahl, wenn mehr als ein Grund angeboten wird. Leer: „Worum geht es?“.'),
|
||||||
TextInput::make('open_label')->label('Beschriftung des Buttons (nur Dialog)')->maxLength(60)->placeholder('Anfrage stellen')
|
TextInput::make('open_label')->label('Beschriftung des Buttons (nur Pop-up-Fenster)')->maxLength(60)->placeholder('Anfrage stellen')
|
||||||
->helperText('Erscheint nur bei der Präsentation „Als Dialog über der Seite“.'),
|
->helperText('Erscheint nur bei der Präsentation „Im Pop-up-Fenster über der Seite“.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ public function summary(array $widget): string
|
|||||||
|
|
||||||
$labels = array_map(fn (array $reason): string => (string) ($reason['label'] ?? ''), $reasons);
|
$labels = array_map(fn (array $reason): string => (string) ($reason['label'] ?? ''), $reasons);
|
||||||
$mode = ($widget['settings']['mode'] ?? 'compact') === 'wizard' ? 'mehrstufig' : 'langes Formular';
|
$mode = ($widget['settings']['mode'] ?? 'compact') === 'wizard' ? 'mehrstufig' : 'langes Formular';
|
||||||
$open = ($widget['settings']['open'] ?? 'inline') === 'modal' ? 'Dialog' : 'im Abschnitt';
|
$open = ($widget['settings']['open'] ?? 'inline') === 'modal' ? 'Pop-up' : 'im Abschnitt';
|
||||||
|
|
||||||
return 'Anfrage: '.implode(', ', $labels).' ('.$mode.', '.$open.')';
|
return 'Anfrage: '.implode(', ', $labels).' ('.$mode.', '.$open.')';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ protected function filmFieldData(?ContentElement $film): array
|
|||||||
? route('content.website-frame', ['element' => $film])
|
? route('content.website-frame', ['element' => $film])
|
||||||
: null,
|
: null,
|
||||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path, 'mittel', $film->updated_at) : null,
|
||||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,6 +349,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
'clip' => $clip,
|
'clip' => $clip,
|
||||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||||
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||||
|
'imageSrcset' => app(WebsiteImage::class)->srcset($imageRef),
|
||||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
||||||
'focus' => PremiumFields::focus($data, 66, 45),
|
'focus' => PremiumFields::focus($data, 66, 45),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ protected function imageSourceFields(): array
|
|||||||
'composition' => $composition,
|
'composition' => $composition,
|
||||||
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
||||||
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
||||||
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at)
|
||||||
: null,
|
: null,
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Communication;
|
namespace App\Domain\Communication;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -271,6 +272,245 @@ public function persist(array $editor): array
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Beschriftungen der Wirkungen am Element, je Art des Ziels. */
|
||||||
|
public const EFFECT_LABELS = [
|
||||||
|
'step' => ['show' => 'Bereich nur anzeigen, wenn …', 'hide' => 'Bereich ausblenden, wenn …', 'skip' => 'Bereich überspringen, wenn …'],
|
||||||
|
'group' => ['show' => 'Teilbereich nur anzeigen, wenn …', 'hide' => 'Teilbereich ausblenden, wenn …'],
|
||||||
|
'field' => ['show' => 'Feld nur anzeigen, wenn …', 'hide' => 'Feld ausblenden, wenn …', 'require' => 'Pflichtfeld, wenn …'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Baumansicht für die Formularoberfläche (ADR-62): Ein Teilbereich trägt seine Felder selbst (items), die
|
||||||
|
* Ende-Markierung der flachen Ansicht entfällt. Die Umwandlung ist verlustfrei: fromTree(toTree(x)) liefert dieselbe
|
||||||
|
* Struktur, die persist() in denselben Entwurf überführt.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $view Ergebnis von expand()
|
||||||
|
* @return array{areas: list<array<string, mixed>>, rules: list<array<string, mixed>>}
|
||||||
|
*/
|
||||||
|
public static function toTree(array $view): array
|
||||||
|
{
|
||||||
|
$areas = [];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($view['areas'] ?? [])) as $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$items = [];
|
||||||
|
$section = null;
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $block) {
|
||||||
|
$block = is_array($block) ? $block : [];
|
||||||
|
$data = is_array($block['data'] ?? null) ? $block['data'] : [];
|
||||||
|
|
||||||
|
switch ((string) ($block['type'] ?? '')) {
|
||||||
|
case 'issue':
|
||||||
|
$section = null;
|
||||||
|
$items[] = ['kind' => 'issue', 'issues' => array_values(array_filter((array) ($data['issues'] ?? []), 'is_string'))];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'end':
|
||||||
|
$section = null;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'section':
|
||||||
|
$items[] = ['kind' => 'section', ...$data, 'items' => []];
|
||||||
|
$section = array_key_last($items);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'field':
|
||||||
|
if ($section !== null) {
|
||||||
|
$items[$section]['items'][] = ['kind' => 'field', ...$data];
|
||||||
|
} else {
|
||||||
|
$items[] = ['kind' => 'field', ...$data];
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$areas[] = [...Arr::except($area, ['items']), 'items' => $items];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['areas' => $areas, 'rules' => array_values((array) ($view['rules'] ?? []))];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Umkehrung von toTree(): die flache Ansicht, die persist() erwartet. Nach jedem Teilbereich steht eine
|
||||||
|
* Ende-Markierung, damit folgende Einzelfelder nicht in ihn fallen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $tree
|
||||||
|
* @return array{areas: list<array<string, mixed>>, rules: list<array<string, mixed>>}
|
||||||
|
*/
|
||||||
|
public static function fromTree(array $tree): array
|
||||||
|
{
|
||||||
|
$areas = [];
|
||||||
|
$field = fn (array $item): array => ['type' => 'field', 'data' => Arr::except($item, ['kind', '_id'])];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($tree['areas'] ?? [])) as $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$blocks = [];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $item) {
|
||||||
|
$item = is_array($item) ? $item : [];
|
||||||
|
|
||||||
|
switch ((string) ($item['kind'] ?? '')) {
|
||||||
|
case 'issue':
|
||||||
|
$blocks[] = ['type' => 'issue', 'data' => ['issues' => array_values(array_filter((array) ($item['issues'] ?? []), 'is_string'))]];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'section':
|
||||||
|
$blocks[] = ['type' => 'section', 'data' => Arr::except($item, ['kind', '_id', 'items'])];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($item['items'] ?? [])) as $inner) {
|
||||||
|
$blocks[] = $field(is_array($inner) ? $inner : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
$blocks[] = ['type' => 'end', 'data' => []];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'field':
|
||||||
|
$blocks[] = $field($item);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$areas[] = [...Arr::except($area, ['items', '_id']), 'items' => $blocks];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['areas' => $areas, 'rules' => array_values((array) ($tree['rules'] ?? []))];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft die Baumansicht vor dem Speichern. Was nur gekürzt oder ignoriert würde, wird hier benannt, damit die
|
||||||
|
* Verwaltung nichts stillschweigend verliert.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $tree
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function validateTree(array $tree): array
|
||||||
|
{
|
||||||
|
$errors = [];
|
||||||
|
$seen = [];
|
||||||
|
$issueQuestions = 0;
|
||||||
|
$limit = function (string $where, string $what, mixed $value, int $max) use (&$errors): void {
|
||||||
|
if (mb_strlen(trim((string) $value)) > $max) {
|
||||||
|
$errors[] = "$where: $what darf höchstens $max Zeichen lang sein.";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (array_values((array) ($tree['areas'] ?? [])) as $index => $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$title = trim((string) ($area['title'] ?? ''));
|
||||||
|
$where = 'Bereich '.($index + 1).($title !== '' ? ' „'.$title.'“' : '');
|
||||||
|
|
||||||
|
if ($title === '') {
|
||||||
|
$errors[] = "$where: Der Titel fehlt.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit($where, 'Der Titel', $title, 120);
|
||||||
|
$limit($where, 'Die Einleitung', $area['intro'] ?? '', 600);
|
||||||
|
|
||||||
|
$checkField = function (array $field) use (&$errors, &$seen, $where, $limit): void {
|
||||||
|
$label = trim((string) ($field['label'] ?? ''));
|
||||||
|
$name = $label !== '' ? '„'.$label.'“' : 'Ein Feld';
|
||||||
|
|
||||||
|
if ($label === '') {
|
||||||
|
$errors[] = "$where: Ein Feld hat keine Frage oder Beschriftung.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit($where, "Die Frage $name", $label, 200);
|
||||||
|
$limit($where, "Der Hilfetext von $name", $field['help'] ?? '', 600);
|
||||||
|
$type = FieldType::tryFrom((string) ($field['type'] ?? ''));
|
||||||
|
|
||||||
|
if ($type === null) {
|
||||||
|
$errors[] = "$where: Bei $name fehlt die Art der Antwort.";
|
||||||
|
} elseif ($type->hasOptions()) {
|
||||||
|
$options = array_filter((array) ($field['options'] ?? []), fn (mixed $option): bool => is_array($option) && trim((string) ($option['label'] ?? '')) !== '');
|
||||||
|
|
||||||
|
if ($options === []) {
|
||||||
|
$errors[] = "$where: Bei $name fehlen die Auswahlwerte.";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($options as $option) {
|
||||||
|
$limit($where, "Ein Auswahlwert von $name", $option['label'], 120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = (string) ($field['key'] ?? '');
|
||||||
|
|
||||||
|
if ($key !== '' && ! str_starts_with($key, 'tmp_')) {
|
||||||
|
if (isset($seen[$key])) {
|
||||||
|
$errors[] = "$where: $name steht mehrfach im Formular.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$seen[$key] = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $item) {
|
||||||
|
$item = is_array($item) ? $item : [];
|
||||||
|
|
||||||
|
if (($item['kind'] ?? null) === 'issue') {
|
||||||
|
$issueQuestions++;
|
||||||
|
} elseif (($item['kind'] ?? null) === 'section') {
|
||||||
|
$label = trim((string) ($item['label'] ?? ''));
|
||||||
|
|
||||||
|
if ($label === '') {
|
||||||
|
$errors[] = "$where: Ein Teilbereich hat keine Überschrift.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit($where, 'Die Überschrift eines Teilbereichs', $label, 200);
|
||||||
|
$limit($where, 'Die Erläuterung eines Teilbereichs', $item['description'] ?? '', 600);
|
||||||
|
|
||||||
|
foreach (array_values((array) ($item['items'] ?? [])) as $inner) {
|
||||||
|
$checkField(is_array($inner) ? $inner : []);
|
||||||
|
}
|
||||||
|
} elseif (($item['kind'] ?? null) === 'field') {
|
||||||
|
$checkField($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issueQuestions > 1) {
|
||||||
|
$errors[] = 'Die Frage nach dem Anliegen darf nur einmal im Formular vorkommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values(array_unique($errors));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahllisten für die Formularoberfläche: Feldarten, Verwendungen, Wirkungen, Vergleiche, Anliegen und die Felder
|
||||||
|
* des Katalogs mit Verwendung in anderen Formularen.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function clientConfig(?int $exceptTemplate = null): array
|
||||||
|
{
|
||||||
|
$usage = $this->usage($exceptTemplate);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'types' => array_map(fn (FieldType $type): array => ['value' => $type->value, 'label' => $type->label(), 'options' => $type->hasOptions(), 'control' => $type->canControl()], FieldType::cases()),
|
||||||
|
'purposes' => array_map(fn (FieldPurpose $purpose): array => ['value' => $purpose->value, 'label' => $purpose->label(), 'types' => array_map(fn (FieldType $type): string => $type->value, $purpose->types())], FieldPurpose::cases()),
|
||||||
|
'effects' => self::EFFECT_LABELS,
|
||||||
|
'operators' => TemplateCompiler::OPERATORS,
|
||||||
|
'issues' => InquiryIssue::tree(),
|
||||||
|
'catalog' => InquiryField::query()->offered()->orderBy('name')->get()->map(fn (InquiryField $field): array => [
|
||||||
|
'key' => $field->key,
|
||||||
|
'name' => $field->name,
|
||||||
|
'label' => $field->label,
|
||||||
|
'help' => $field->help,
|
||||||
|
'type' => $field->type->value,
|
||||||
|
'options' => $field->optionList(),
|
||||||
|
'purpose' => $field->purpose?->value,
|
||||||
|
'used_in' => implode(', ', $usage['fields'][$field->key] ?? []),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Eine neue Zeile in der Karteikarte der Bedingungen (leer: Standardwerte).
|
* Eine neue Zeile in der Karteikarte der Bedingungen (leer: Standardwerte).
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Größenstufen eines Bildes (docs/architektur/bildvarianten.md).
|
||||||
|
*
|
||||||
|
* Neben der Hauptdatei (`vorschau/element-12.jpg`, „voll“: bis 2400 px bei Bildern, 640 px sonst) liegen daneben
|
||||||
|
* kleinere JPEG-Fassungen, benannt nach der Hauptdatei (`element-12-klein.jpg`). Es gibt keine Spalte dafür: Die Hauptdatei
|
||||||
|
* bleibt `thumbnail_path`, die Fassungen folgen der Namensregel. Fehlt eine Fassung, gilt die Hauptdatei (kein Bruch bei
|
||||||
|
* Bestand, der noch nicht abgeleitet ist).
|
||||||
|
*
|
||||||
|
* Verwaltungsoberfläche (Disk `media_derived`):
|
||||||
|
* - `klein` 360 px: Auswahl, Listen, Karten (Anzeige bis etwa 180 px, doppelt für scharfe Bildschirme)
|
||||||
|
* - `mittel` 960 px: Detailansicht, Vorschau, Titelbild im Editor
|
||||||
|
* - voll: die Hauptdatei
|
||||||
|
*
|
||||||
|
* Website (Disk `media_public`, `website/{id}/datei-{breite}.jpg`): Breiten {@see self::PUBLIC_WIDTHS}, daneben die
|
||||||
|
* Hauptdatei `datei.jpg`. Eine Fassung entsteht nur, wenn die Quelle breiter ist (nie vergrößern).
|
||||||
|
*
|
||||||
|
* Geschrieben wird nur in der Warteschlange; der Web-Prozess liest.
|
||||||
|
*/
|
||||||
|
class ImageVariants
|
||||||
|
{
|
||||||
|
/** @var array<string, int> */
|
||||||
|
public const SIZES = ['klein' => 360, 'mittel' => 960];
|
||||||
|
|
||||||
|
/** @var list<int> */
|
||||||
|
public const PUBLIC_WIDTHS = [640, 1280, 1920];
|
||||||
|
|
||||||
|
private const QUALITY = 80;
|
||||||
|
|
||||||
|
public static function isSize(mixed $size): bool
|
||||||
|
{
|
||||||
|
return is_string($size) && array_key_exists($size, self::SIZES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isPublicWidth(mixed $width): bool
|
||||||
|
{
|
||||||
|
return is_int($width) && in_array($width, self::PUBLIC_WIDTHS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `vorschau/element-12.jpg` → `vorschau/element-12-klein.jpg` */
|
||||||
|
public static function path(string $base, string $size): string
|
||||||
|
{
|
||||||
|
$extension = pathinfo($base, PATHINFO_EXTENSION);
|
||||||
|
$stem = $extension === '' ? $base : substr($base, 0, -(strlen($extension) + 1));
|
||||||
|
|
||||||
|
return $stem.'-'.$size.'.jpg';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `website/12/datei.jpg` → `website/12/datei-640.jpg` */
|
||||||
|
public static function publicPath(string $base, int $width): string
|
||||||
|
{
|
||||||
|
return self::path($base, (string) $width);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pfad, der für die Größe ausgeliefert wird: die Fassung, wenn es sie gibt, sonst die Hauptdatei.
|
||||||
|
*/
|
||||||
|
public static function resolve(Filesystem $disk, string $base, ?string $size): string
|
||||||
|
{
|
||||||
|
if (! self::isSize($size)) {
|
||||||
|
return $base;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = self::path($base, (string) $size);
|
||||||
|
|
||||||
|
return $disk->exists($variant) ? $variant : $base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Fassungen der Verwaltungsoberfläche zur Hauptdatei an (Warteschlange). Ist die Quelle nicht breiter als die
|
||||||
|
* Stufe, entfällt die Fassung, und eine ältere wird entfernt.
|
||||||
|
*
|
||||||
|
* @return list<string> Pfade der geschriebenen Fassungen
|
||||||
|
*/
|
||||||
|
public static function generate(Filesystem $disk, string $base): array
|
||||||
|
{
|
||||||
|
$targets = [];
|
||||||
|
|
||||||
|
foreach (self::SIZES as $name => $width) {
|
||||||
|
$targets[self::path($base, $name)] = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::write($disk, $disk, $base, $targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Breiten für die Website neben der öffentlichen Hauptdatei an. Nur JPEG-Quellen: andere Formate (PNG, GIF,
|
||||||
|
* WebP) können Transparenz tragen, die ein JPEG nicht hält; sie bleiben unverändert.
|
||||||
|
*
|
||||||
|
* @return list<string> Pfade der geschriebenen Fassungen
|
||||||
|
*/
|
||||||
|
public static function generatePublic(Filesystem $source, Filesystem $target, string $sourcePath, string $publicBase): array
|
||||||
|
{
|
||||||
|
if (! in_array(strtolower(pathinfo($publicBase, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = [];
|
||||||
|
|
||||||
|
foreach (self::PUBLIC_WIDTHS as $width) {
|
||||||
|
$targets[self::publicPath($publicBase, $width)] = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::write($source, $target, $sourcePath, $targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Entfernt alle Fassungen zu einer öffentlichen Hauptdatei (Rücknahme, Ersatz). */
|
||||||
|
public static function deletePublic(Filesystem $disk, string $publicBase): void
|
||||||
|
{
|
||||||
|
foreach (self::PUBLIC_WIDTHS as $width) {
|
||||||
|
$disk->delete(self::publicPath($publicBase, $width));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, int> $targets Zielpfad → Breite
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function write(Filesystem $source, Filesystem $target, string $sourcePath, array $targets): array
|
||||||
|
{
|
||||||
|
if (! $source->exists($sourcePath)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = $source->get($sourcePath);
|
||||||
|
$image = is_string($bytes) && $bytes !== '' ? @imagecreatefromstring($bytes) : false;
|
||||||
|
|
||||||
|
if ($image === false) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$width = imagesx($image);
|
||||||
|
$height = imagesy($image);
|
||||||
|
$written = [];
|
||||||
|
|
||||||
|
foreach ($targets as $path => $targetWidth) {
|
||||||
|
if ($width <= $targetWidth) {
|
||||||
|
$target->delete($path);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$encoded = self::scaled($image, $width, $height, $targetWidth);
|
||||||
|
|
||||||
|
if ($encoded !== null && $target->put($path, $encoded)) {
|
||||||
|
$written[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagedestroy($image);
|
||||||
|
|
||||||
|
return $written;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function scaled(\GdImage $image, int $width, int $height, int $targetWidth): ?string
|
||||||
|
{
|
||||||
|
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
||||||
|
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||||
|
imagefill($canvas, 0, 0, (int) imagecolorallocate($canvas, 255, 255, 255));
|
||||||
|
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
||||||
|
imageinterlace($canvas, true);
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($canvas, null, self::QUALITY);
|
||||||
|
$bytes = ob_get_clean();
|
||||||
|
imagedestroy($canvas);
|
||||||
|
|
||||||
|
return is_string($bytes) && $bytes !== '' ? $bytes : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,6 +89,7 @@ public function place(ContentElement $element, string $incoming): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($element->output_class === 'bild') {
|
if ($element->output_class === 'bild') {
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $target);
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
$element->thumbnail_source = 'eigen';
|
$element->thumbnail_source = 'eigen';
|
||||||
} else {
|
} else {
|
||||||
@@ -97,6 +98,7 @@ public function place(ContentElement $element, string $incoming): void
|
|||||||
|
|
||||||
$element->thumbnail_error = null;
|
$element->thumbnail_error = null;
|
||||||
$element->save();
|
$element->save();
|
||||||
|
$element->touch();
|
||||||
Storage::disk('cms_incoming')->delete($incoming);
|
Storage::disk('cms_incoming')->delete($incoming);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ private function frame(ContentElement $element, ContentElementVersion $version,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageVariants::generate($disk, $target);
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
if (! filled($element->thumbnail_alt)) {
|
if (! filled($element->thumbnail_alt)) {
|
||||||
$element->thumbnail_alt = $element->working_title;
|
$element->thumbnail_alt = $element->working_title;
|
||||||
@@ -344,6 +345,7 @@ private function frame(ContentElement $element, ContentElementVersion $version,
|
|||||||
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
||||||
}
|
}
|
||||||
$element->save();
|
$element->save();
|
||||||
|
$element->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function still(ContentElement|Composition $subject, Filesystem $disk, string $file, string $name): void
|
private function still(ContentElement|Composition $subject, Filesystem $disk, string $file, string $name): void
|
||||||
@@ -388,6 +390,7 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$path = 'vorschau/'.$name.'.jpg';
|
$path = 'vorschau/'.$name.'.jpg';
|
||||||
Storage::disk('media_derived')->put($path, $bytes);
|
Storage::disk('media_derived')->put($path, $bytes);
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $path);
|
||||||
$subject->thumbnail_path = $path;
|
$subject->thumbnail_path = $path;
|
||||||
|
|
||||||
if (! filled($subject->thumbnail_alt)) {
|
if (! filled($subject->thumbnail_alt)) {
|
||||||
@@ -396,6 +399,9 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$subject->thumbnail_error = null;
|
$subject->thumbnail_error = null;
|
||||||
$subject->save();
|
$subject->save();
|
||||||
|
// Die Adresse trägt die Version (updated_at) und wird dauerhaft zwischengespeichert: Ein neu abgeleitetes Bild
|
||||||
|
// unter gleichem Pfad muss die Version ändern, auch wenn sonst nichts an der Zeile anders ist.
|
||||||
|
$subject->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rememberElement(ContentElement $element, string $source): void
|
private function rememberElement(ContentElement $element, string $source): void
|
||||||
|
|||||||
@@ -2,14 +2,37 @@
|
|||||||
|
|
||||||
namespace App\Domain\Media;
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
|
||||||
class ThumbnailRef
|
class ThumbnailRef
|
||||||
{
|
{
|
||||||
public static function url(string $route, string $kind, int $id, mixed $path): ?string
|
/**
|
||||||
|
* Adresse eines Vorschaubildes.
|
||||||
|
*
|
||||||
|
* @param string|null $size `klein` (Auswahl, Listen, Karten), `mittel` (Detail, Vorschau) oder null für die volle Datei
|
||||||
|
* @param CarbonInterface|int|string|null $version Stand des Bildes (zum Beispiel `updated_at`). Mit Version darf der Browser das Bild
|
||||||
|
* dauerhaft behalten; ohne Version fragt er jedes Mal nach (ETag).
|
||||||
|
*/
|
||||||
|
public static function url(string $route, string $kind, int $id, mixed $path, ?string $size = null, CarbonInterface|int|string|null $version = null): ?string
|
||||||
{
|
{
|
||||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return route($route, ['kind' => $kind, 'subject' => $id]);
|
$query = [];
|
||||||
|
|
||||||
|
if (ImageVariants::isSize($size)) {
|
||||||
|
$query['g'] = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version instanceof CarbonInterface) {
|
||||||
|
$version = $version->getTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version !== null && $version !== '') {
|
||||||
|
$query['v'] = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return route($route, ['kind' => $kind, 'subject' => $id] + $query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,37 @@ public function present(ContentElement|int $element): ?WebsitePresentation
|
|||||||
'audio' => 'audio',
|
'audio' => 'audio',
|
||||||
default => 'bild',
|
default => 'bild',
|
||||||
},
|
},
|
||||||
url: route('website.media', $element),
|
// Bilder tragen den Zeitpunkt der Freigabe in der Adresse (dauerhaft zwischenspeicherbar); Film und Hörstück bleiben unverändert.
|
||||||
|
url: $element->output_class === 'film' || $element->output_class === 'audio'
|
||||||
|
? route('website.media', $element)
|
||||||
|
: route('website.media', ['element' => $element, 'v' => $element->website_released_at->getTimestamp()]),
|
||||||
|
srcset: $this->srcset($element, $path),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `srcset` eines freigegebenen JPEG-Bildes: die Breiten aus {@see ImageVariants::PUBLIC_WIDTHS} und die volle Datei.
|
||||||
|
* Fehlt eine Breite noch (Bestand), liefert die Adresse die volle Datei und stößt das Anlegen an; die Beschreibung bleibt
|
||||||
|
* dann ungenau, das Bild aber richtig. PNG, GIF und WebP bleiben ohne Fassungen (Transparenz).
|
||||||
|
*/
|
||||||
|
private function srcset(ContentElement $element, string $path): ?string
|
||||||
|
{
|
||||||
|
if ($element->output_class !== 'bild' || ! in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $element->website_released_at->getTimestamp();
|
||||||
|
$entries = [];
|
||||||
|
|
||||||
|
foreach (ImageVariants::PUBLIC_WIDTHS as $width) {
|
||||||
|
$entries[] = route('website.media', ['element' => $element, 'w' => $width, 'v' => $version]).' '.$width.'w';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entries[] = route('website.media', ['element' => $element, 'v' => $version]).' 2400w';
|
||||||
|
|
||||||
|
return implode(', ', $entries);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,5 +15,19 @@ public function __construct(
|
|||||||
public readonly ?string $credit,
|
public readonly ?string $credit,
|
||||||
public readonly string $kind,
|
public readonly string $kind,
|
||||||
public readonly string $url,
|
public readonly string $url,
|
||||||
|
/** Bildadressen in mehreren Breiten für `srcset` (nur Bilder, deren Breiten die Warteschlange anlegt), sonst null. */
|
||||||
|
public readonly ?string $srcset = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adresse in einer der Breiten aus {@see ImageVariants::PUBLIC_WIDTHS}; ohne Breiten (oder bei anderer Breite) die volle Datei.
|
||||||
|
*/
|
||||||
|
public function urlForWidth(?int $width): string
|
||||||
|
{
|
||||||
|
if ($width === null || $this->srcset === null || ! ImageVariants::isPublicWidth($width)) {
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->url.(str_contains($this->url, '?') ? '&' : '?').'w='.$width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ class InquiryTemplateResource extends CommunicationResource
|
|||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components(TemplateEditor::schema());
|
return $schema->components(TemplateEditor::schema($schema->getRecord()?->getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
|
|||||||
@@ -140,16 +140,35 @@ protected function archiveBlocked(): ?string
|
|||||||
|
|
||||||
protected function mutateFormDataBeforeFill(array $data): array
|
protected function mutateFormDataBeforeFill(array $data): array
|
||||||
{
|
{
|
||||||
$data['editor'] = app(FormEditor::class)->expand((array) ($data['draft'] ?? []), $this->getRecord()->getKey());
|
$tree = FormEditor::toTree(app(FormEditor::class)->expand((array) ($data['draft'] ?? []), $this->getRecord()->getKey()));
|
||||||
|
|
||||||
|
// Die Formularansicht führt den Baum im Browser und übergibt ihn als Text; die weiteren Regeln bleiben eine Liste.
|
||||||
|
$data['editor'] = ['rules' => $tree['rules']];
|
||||||
|
$data['editor_json'] = json_encode(['areas' => $tree['areas']], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mutateFormDataBeforeSave(array $data): array
|
protected function mutateFormDataBeforeSave(array $data): array
|
||||||
{
|
{
|
||||||
|
$editor = app(FormEditor::class);
|
||||||
|
$tree = json_decode((string) ($data['editor_json'] ?? ''), true);
|
||||||
|
|
||||||
|
if (! is_array($tree)) {
|
||||||
|
$this->failEditor(['Der Aufbau konnte nicht gelesen werden. Bitte lade die Seite neu und versuche es noch einmal.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = $editor->validateTree($tree);
|
||||||
|
|
||||||
|
if ($errors !== []) {
|
||||||
|
$this->failEditor($errors);
|
||||||
|
}
|
||||||
|
|
||||||
// Der Editor schreibt neue und geänderte Felder und Teilbereiche in den Katalog und liefert den Entwurf.
|
// Der Editor schreibt neue und geänderte Felder und Teilbereiche in den Katalog und liefert den Entwurf.
|
||||||
$saved = app(FormEditor::class)->persist((array) ($data['editor'] ?? []));
|
$view = FormEditor::fromTree($tree);
|
||||||
unset($data['editor']);
|
$view['rules'] = (array) ($data['editor']['rules'] ?? []);
|
||||||
|
$saved = $editor->persist($view);
|
||||||
|
unset($data['editor'], $data['editor_json']);
|
||||||
|
|
||||||
$data['draft'] = TemplateDraft::clean([
|
$data['draft'] = TemplateDraft::clean([
|
||||||
'texts' => (array) ($data['draft']['texts'] ?? []),
|
'texts' => (array) ($data['draft']['texts'] ?? []),
|
||||||
@@ -161,6 +180,17 @@ protected function mutateFormDataBeforeSave(array $data): array
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $messages
|
||||||
|
* @return never
|
||||||
|
*/
|
||||||
|
private function failEditor(array $messages): void
|
||||||
|
{
|
||||||
|
Notification::make()->title('Das Formular ist noch nicht vollständig')->body(implode("\n", array_map(fn (string $line): string => '• '.$line, $messages)))->danger()->persistent()->send();
|
||||||
|
|
||||||
|
throw ValidationException::withMessages(['data.editor_json' => $messages]);
|
||||||
|
}
|
||||||
|
|
||||||
protected function afterSave(): void
|
protected function afterSave(): void
|
||||||
{
|
{
|
||||||
// Neue Felder und Teilbereiche tragen jetzt ihre festen Kennungen. Ohne neues Laden würde ein zweites Speichern sie doppelt anlegen.
|
// Neue Felder und Teilbereiche tragen jetzt ihre festen Kennungen. Ohne neues Laden würde ein zweites Speichern sie doppelt anlegen.
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public function form(Schema $schema): Schema
|
|||||||
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
||||||
/** @var ContentElement $element */
|
/** @var ContentElement $element */
|
||||||
$element = $this->getRecord();
|
$element = $this->getRecord();
|
||||||
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
$caption = match ($element->thumbnail_source) {
|
$caption = match ($element->thumbnail_source) {
|
||||||
'eigen' => 'Eigenes Vorschaubild.',
|
'eigen' => 'Eigenes Vorschaubild.',
|
||||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ private function viewerData(): array
|
|||||||
&& $element->output_class === 'text'
|
&& $element->output_class === 'text'
|
||||||
&& $shown->status !== ContentVersionStatus::Gesperrt,
|
&& $shown->status !== ContentVersionStatus::Gesperrt,
|
||||||
'bodyCommitted' => $committed,
|
'bodyCommitted' => $committed,
|
||||||
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at),
|
||||||
'pictureCaption' => $this->pictureCaption($element),
|
'pictureCaption' => $this->pictureCaption($element),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -1076,7 +1076,7 @@ public function previewHtml(): string
|
|||||||
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||||
'hide_status' => true,
|
'hide_status' => true,
|
||||||
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
||||||
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at),
|
||||||
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ protected function catalogRows(): array
|
|||||||
'titel' => $title,
|
'titel' => $title,
|
||||||
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
||||||
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
||||||
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path) : null,
|
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path, 'klein', $cover->updated_at) : null,
|
||||||
'symbol' => 'dokument',
|
'symbol' => 'dokument',
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'chips' => $chips,
|
'chips' => $chips,
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
use App\Domain\Catalog\PillarService;
|
use App\Domain\Catalog\PillarService;
|
||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
|
use App\Domain\Cms\SectionTransfer;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
use App\Filament\Support\ChoosesLinkTargets;
|
use App\Filament\Support\ChoosesLinkTargets;
|
||||||
use App\Filament\Support\ChoosesWebsiteImages;
|
use App\Filament\Support\ChoosesWebsiteImages;
|
||||||
@@ -176,6 +178,11 @@ public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotificat
|
|||||||
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
||||||
$this->showFailingSection(array_keys($exception->errors()));
|
$this->showFailingSection(array_keys($exception->errors()));
|
||||||
|
|
||||||
|
// Name und Sprungmarke stehen im Einstellungsdialog; die Meldung am Abschnitt führt dorthin. Hierher scrollen.
|
||||||
|
if (preg_match('/data\.sections\.[^.]+\.(name|anchor)(\.|\s|$)/', $keys) === 1) {
|
||||||
|
$this->js("requestAnimationFrame(() => requestAnimationFrame(() => document.querySelector('[data-abschnitt-fehler]')?.scrollIntoView({ block: 'center' })))");
|
||||||
|
}
|
||||||
|
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,6 +243,103 @@ public function saveFromBlock(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abschnitt auf eine andere Seite kopieren oder verschieben (Schalter im Abschnittskopf). Der Abschnitt stammt aus
|
||||||
|
* dem Arbeitsstand dieser Seite. Die Zielseite erhält eine neue Entwurfsrevision. Beim Verschieben wird er danach
|
||||||
|
* aus dem Arbeitsstand entfernt und die Seite als Entwurf gespeichert. Geprüft wird vor dem ersten Schreiben:
|
||||||
|
* scheitert eine Seite, bleibt beides unverändert.
|
||||||
|
*/
|
||||||
|
public function transferSection(string $key, int $targetId, string $position, bool $move): void
|
||||||
|
{
|
||||||
|
$this->forceRender();
|
||||||
|
$raw = is_array($this->data['sections'] ?? null) ? $this->data['sections'] : [];
|
||||||
|
$target = Page::query()->find($targetId);
|
||||||
|
|
||||||
|
if (! isset($raw[$key]) || $target === null || $target->is($this->record)) {
|
||||||
|
Notification::make()->title('Zielseite oder Abschnitt nicht gefunden')->danger()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
abort_unless(auth()->user()?->can('update', $target) ?? false, 403);
|
||||||
|
|
||||||
|
// Der Arbeitsstand in der Form wie beim Speichern (formatierte Texte als HTML, Leeres entfernt).
|
||||||
|
try {
|
||||||
|
$state = $this->form->getState()['sections'] ?? [];
|
||||||
|
} catch (ValidationException) {
|
||||||
|
Notification::make()->title($move ? 'Abschnitt nicht verschoben' : 'Abschnitt nicht kopiert')->body('Auf dieser Seite gibt es noch Eingabefehler. Bitte zuerst beheben.')->danger()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die Schlüssel des Formulars gehen beim Aufbereiten verloren; die Reihenfolge bleibt.
|
||||||
|
$index = array_search($key, array_map('strval', array_keys($raw)), true);
|
||||||
|
$items = array_values(is_array($state) ? $state : []);
|
||||||
|
|
||||||
|
if ($index === false || ! isset($items[$index])) {
|
||||||
|
Notification::make()->title('Zielseite oder Abschnitt nicht gefunden')->danger()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transfer = app(SectionTransfer::class);
|
||||||
|
$section = SectionEditor::fromEditorState([$items[$index]])[0] ?? [];
|
||||||
|
$remaining = $items;
|
||||||
|
unset($remaining[$index]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$transfer->plan($target, $section, $position, ! $move);
|
||||||
|
|
||||||
|
if ($move) {
|
||||||
|
// Die Quellseite muss ohne den Abschnitt gültig bleiben, sonst wird nichts geschrieben.
|
||||||
|
app(PageSections::class)->normalize(SectionEditor::fromEditorState($remaining));
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $transfer->insert($target, $section, $position, ! $move, auth()->user());
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
Notification::make()
|
||||||
|
->title($move ? 'Abschnitt nicht verschoben' : 'Abschnitt nicht kopiert')
|
||||||
|
->body(collect($exception->errors())->flatten()->first() ?? 'Die Seite wäre danach ungültig.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($move) {
|
||||||
|
unset($raw[$key]);
|
||||||
|
$this->data['sections'] = $raw;
|
||||||
|
// Der Kontext „Abschnitt gestalten“ merkt sich eine Position, die sich durch das Entfernen verschiebt.
|
||||||
|
$this->abschnitt = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
foreach ($exception->errors() as $errorKey => $messages) {
|
||||||
|
foreach ((array) $messages as $message) {
|
||||||
|
$this->addError($errorKey, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Notification::make()->title('Auf der Zielseite eingefügt, hier nicht gespeichert')->body('Bitte die markierten Fehler beheben und „Entwurf speichern“ wählen; sonst steht der Abschnitt auf beiden Seiten.')->warning()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchorNote = match (true) {
|
||||||
|
! $result['anchorChanged'] => '',
|
||||||
|
$result['anchor'] !== null => ' Die Sprungmarke war dort vergeben und heißt jetzt „'.$result['anchor'].'“.',
|
||||||
|
default => ' Die Sprungmarke war dort vergeben; der Abschnitt hat keine mehr.',
|
||||||
|
};
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title($move ? 'Abschnitt verschoben' : 'Abschnitt kopiert')
|
||||||
|
->body('Als Abschnitt '.$result['position'].' auf '.$target->path.' eingefügt (Entwurf, noch nicht veröffentlicht).'.$anchorNote)
|
||||||
|
->success()
|
||||||
|
->actions([Action::make('open')->label('Zielseite öffnen')->url(PageResource::getUrl('edit', ['record' => $target]))->button()])
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -18,12 +18,14 @@
|
|||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
use App\Domain\Catalog\OfferStatus;
|
||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Filament\Resources\Combinations\CombinationResource;
|
use App\Filament\Resources\Combinations\CombinationResource;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\Courses\CourseResource;
|
use App\Filament\Resources\Courses\CourseResource;
|
||||||
use App\Filament\Resources\Documents\DocumentResource;
|
use App\Filament\Resources\Documents\DocumentResource;
|
||||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||||
use App\Filament\Resources\Practices\PracticeResource;
|
use App\Filament\Resources\Practices\PracticeResource;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -115,7 +117,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'usage_note' => (string) ($element->usage_note ?? ''),
|
'usage_note' => (string) ($element->usage_note ?? ''),
|
||||||
'license_note' => (string) ($element->license_note ?? ''),
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path),
|
'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at),
|
||||||
'version_label' => match ($version->status) {
|
'version_label' => match ($version->status) {
|
||||||
ContentVersionStatus::Entwurf => 'Entwurf',
|
ContentVersionStatus::Entwurf => 'Entwurf',
|
||||||
ContentVersionStatus::Gesperrt => 'deaktiviert',
|
ContentVersionStatus::Gesperrt => 'deaktiviert',
|
||||||
@@ -163,7 +165,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'kind' => $kind,
|
'kind' => $kind,
|
||||||
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
||||||
'tone' => $this->tone('', $kind),
|
'tone' => $this->tone('', $kind),
|
||||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at),
|
||||||
'version_label' => $version->status === ContentVersionStatus::Gesperrt
|
'version_label' => $version->status === ContentVersionStatus::Gesperrt
|
||||||
? 'deaktiviert'
|
? 'deaktiviert'
|
||||||
: 'Fassung '.$version->number,
|
: 'Fassung '.$version->number,
|
||||||
@@ -198,7 +200,7 @@ private function draftCompositionRow(int $compositionId, int $exceptCompositionI
|
|||||||
'kind' => $kind,
|
'kind' => $kind,
|
||||||
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
||||||
'tone' => $this->tone('', $kind),
|
'tone' => $this->tone('', $kind),
|
||||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at),
|
||||||
'version_label' => 'Entwurf',
|
'version_label' => 'Entwurf',
|
||||||
'identity' => 'zusammenstellung:'.$composition->id,
|
'identity' => 'zusammenstellung:'.$composition->id,
|
||||||
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
||||||
@@ -524,7 +526,7 @@ private function rowForPresentationMedium(int $id): ?array
|
|||||||
'license_note' => (string) ($element->license_note ?? ''),
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
'image' => $element->output_class === 'bild'
|
'image' => $element->output_class === 'bild'
|
||||||
? $this->cardUrl('element', $element->id, $element->thumbnail_path)
|
? $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'version_label' => 'Ohne Inhaltsfassung',
|
'version_label' => 'Ohne Inhaltsfassung',
|
||||||
'committed' => false,
|
'committed' => false,
|
||||||
@@ -548,13 +550,9 @@ public function tone(string $outputClass, string $kindLabel): string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cardUrl(string $kind, int $id, ?string $path): ?string
|
public function cardUrl(string $kind, int $id, ?string $path, ?string $size = null, CarbonInterface|int|string|null $version = null): ?string
|
||||||
{
|
{
|
||||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
return ThumbnailRef::url('editorial.card', $kind, $id, $path, $size, $version);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -891,7 +889,7 @@ public function filmPictures(array $members): array
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
|
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
|
|
||||||
if ($image === null || isset($pictures[$element->id])) {
|
if ($image === null || isset($pictures[$element->id])) {
|
||||||
continue;
|
continue;
|
||||||
@@ -933,7 +931,7 @@ public function mediaPictures(string $query): array
|
|||||||
->limit(12)
|
->limit(12)
|
||||||
->get()
|
->get()
|
||||||
->map(function (ContentElement $element): ?array {
|
->map(function (ContentElement $element): ?array {
|
||||||
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
|
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
|
|
||||||
if ($image === null) {
|
if ($image === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -957,7 +955,7 @@ public function mediaPictures(string $query): array
|
|||||||
*/
|
*/
|
||||||
public function cover(Composition $composition, array $members): array
|
public function cover(Composition $composition, array $members): array
|
||||||
{
|
{
|
||||||
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path);
|
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at);
|
||||||
|
|
||||||
if ($own !== null) {
|
if ($own !== null) {
|
||||||
return ['url' => $own, 'note' => null, 'own' => true];
|
return ['url' => $own, 'note' => null, 'own' => true];
|
||||||
@@ -970,7 +968,7 @@ public function cover(Composition $composition, array $members): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt'),
|
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt', 'mittel'),
|
||||||
'note' => $picture['note'],
|
'note' => $picture['note'],
|
||||||
'own' => false,
|
'own' => false,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
|||||||
'description' => $description === '' ? null : $description,
|
'description' => $description === '' ? null : $description,
|
||||||
'usageNote' => $usageNote === '' ? null : $usageNote,
|
'usageNote' => $usageNote === '' ? null : $usageNote,
|
||||||
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
||||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at),
|
||||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||||
'imageNote' => $this->imageNote($element),
|
'imageNote' => $this->imageNote($element),
|
||||||
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Domain\Cms\Sections\SectionStyle;
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
|
use Closure;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Components\Utilities\Set;
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -70,6 +73,11 @@ public static function repeater(string $name = 'sections'): Repeater
|
|||||||
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
||||||
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
||||||
->extraItemActions([
|
->extraItemActions([
|
||||||
|
// Name, Sprungmarke und Sichtbarkeit: im Dialog statt als Eingabeblock in jedem Abschnitt.
|
||||||
|
self::settingsAction(),
|
||||||
|
// Auf eine andere Seite kopieren oder verschieben (Dialog mit Zielseite und Position).
|
||||||
|
SectionTransferActions::copy(),
|
||||||
|
SectionTransferActions::move(),
|
||||||
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
||||||
Action::make('gestalten')
|
Action::make('gestalten')
|
||||||
->label('Abschnitt gestalten')
|
->label('Abschnitt gestalten')
|
||||||
@@ -93,7 +101,11 @@ private static function sectionSchema(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Hidden::make('id'),
|
Hidden::make('id'),
|
||||||
self::labelSection(),
|
// Name, Sprungmarke und Sichtbarkeit werden im Einstellungsdialog geändert; der Zustand bleibt am Abschnitt.
|
||||||
|
Hidden::make('name'),
|
||||||
|
Hidden::make('anchor'),
|
||||||
|
Hidden::make('hidden'),
|
||||||
|
View::make('filament.cms.abschnitt-meldung')->columnSpanFull(),
|
||||||
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
||||||
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
||||||
Section::make('Raster und Breite')
|
Section::make('Raster und Breite')
|
||||||
@@ -158,22 +170,60 @@ private static function sectionSchema(): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name, Sprungmarke und Sichtbarkeit: stehen im Seitenaufbau am Abschnitt, damit man sie beim Ordnen der Seite sieht.
|
* Einstellungsdialog des Abschnitts: Name, Sprungmarke und Sichtbarkeit. „Übernehmen“ ändert nur den Seitenentwurf
|
||||||
|
* (gespeichert wird mit „Entwurf speichern“); Abbrechen, Schließen und Esc verwerfen die Eingaben des Dialogs.
|
||||||
*/
|
*/
|
||||||
private static function labelSection(): Section
|
private static function settingsAction(): Action
|
||||||
{
|
{
|
||||||
return Section::make('Name, Sprungmarke und Sichtbarkeit')
|
return Action::make('einstellungen')
|
||||||
->columnSpanFull()
|
->label('Abschnitt-Einstellungen: Name, Sprungmarke und Sichtbarkeit')
|
||||||
->compact()
|
->tooltip('Name, Sprungmarke und Sichtbarkeit')
|
||||||
->collapsible()
|
->icon('heroicon-o-cog-6-tooth')
|
||||||
->collapsed(fn (Get $get): bool => blank($get('name')) && blank($get('anchor')) && ! $get('hidden'))
|
->iconButton()
|
||||||
->extraAttributes(['class' => 'luf-abschnitt-bezeichnung'])
|
->color('gray')
|
||||||
->schema([
|
->extraAttributes(['data-luf-einstellungen' => ''])
|
||||||
|
->modalWidth(Width::Large)
|
||||||
|
->modalHeading(fn (array $arguments, Repeater $component): string => 'Abschnitt '.self::position($component->getRawState(), (string) ($arguments['item'] ?? '')).': Einstellungen')
|
||||||
|
->modalDescription('„Übernehmen“ ändert den Seitenentwurf; gespeichert wird mit „Entwurf speichern“. Abbrechen, Schließen und Esc verwerfen die Änderungen.')
|
||||||
|
->modalSubmitActionLabel('Übernehmen')
|
||||||
|
->modalCancelActionLabel('Abbrechen')
|
||||||
|
->fillForm(fn (array $arguments, Repeater $component): array => self::settingsOf($component->getRawState(), (string) ($arguments['item'] ?? '')))
|
||||||
|
->schema(fn (array $arguments, Repeater $component): array => self::settingsFields(self::otherAnchors($component->getRawState(), (string) ($arguments['item'] ?? ''))))
|
||||||
|
->action(function (array $data, array $arguments, Repeater $component): void {
|
||||||
|
$item = (string) ($arguments['item'] ?? '');
|
||||||
|
$state = $component->getRawState();
|
||||||
|
|
||||||
|
if (! is_array($state) || ! isset($state[$item]) || ! is_array($state[$item])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nur diese drei Angaben des Abschnitts ändern sich; Raster, Gestaltung und Bausteine bleiben unberührt.
|
||||||
|
$state[$item]['name'] = filled($data['name'] ?? null) ? trim((string) $data['name']) : null;
|
||||||
|
$state[$item]['anchor'] = self::slugAnchor($data['anchor'] ?? null);
|
||||||
|
$state[$item]['hidden'] = (bool) ($data['hidden'] ?? false);
|
||||||
|
|
||||||
|
$component->rawState($state);
|
||||||
|
$component->callAfterStateUpdated();
|
||||||
|
$livewire = $component->getLivewire();
|
||||||
|
|
||||||
|
// Nach einer Dialogaktion rendert Filament sonst nur den Dialog neu; Kopf und Zusammenfassung blieben alt.
|
||||||
|
if (method_exists($livewire, 'forceRender')) {
|
||||||
|
$livewire->forceRender();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<Hidden|TextInput|Toggle>
|
||||||
|
*/
|
||||||
|
private static function settingsFields(array $takenAnchors): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
TextInput::make('name')
|
TextInput::make('name')
|
||||||
->label('Name des Abschnitts')
|
->label('Name des Abschnitts')
|
||||||
->placeholder('Zum Beispiel „Kursübersicht“')
|
->placeholder('Zum Beispiel „Kursübersicht“')
|
||||||
->maxLength(PageSections::MAX_NAME)
|
->maxLength(PageSections::MAX_NAME)
|
||||||
->live(onBlur: true)
|
->autofocus()
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Nur zur Orientierung im Seitenaufbau und in der Linkauswahl. Der Name erscheint nie auf der Website.')
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Nur zur Orientierung im Seitenaufbau und in der Linkauswahl. Der Name erscheint nie auf der Website.')
|
||||||
->hintColor('gray'),
|
->hintColor('gray'),
|
||||||
TextInput::make('anchor')
|
TextInput::make('anchor')
|
||||||
@@ -185,6 +235,15 @@ private static function labelSection(): Section
|
|||||||
->afterStateUpdated(function (?string $state, Set $set): void {
|
->afterStateUpdated(function (?string $state, Set $set): void {
|
||||||
$set('anchor', filled($state) ? Str::slug($state, '-', 'de') : null);
|
$set('anchor', filled($state) ? Str::slug($state, '-', 'de') : null);
|
||||||
})
|
})
|
||||||
|
->rules([
|
||||||
|
fn (): Closure => function (string $attribute, mixed $value, Closure $fail) use ($takenAnchors): void {
|
||||||
|
$problem = PageSections::anchorProblem((string) self::slugAnchor($value), $takenAnchors);
|
||||||
|
|
||||||
|
if ($problem !== null) {
|
||||||
|
$fail($problem);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
->suffixAction(Action::make('anchorFromName')
|
->suffixAction(Action::make('anchorFromName')
|
||||||
->label('Sprungmarke aus dem Namen vorschlagen')
|
->label('Sprungmarke aus dem Namen vorschlagen')
|
||||||
->icon('heroicon-o-sparkles')
|
->icon('heroicon-o-sparkles')
|
||||||
@@ -195,12 +254,64 @@ private static function labelSection(): Section
|
|||||||
->helperText(fn (Get $get, $livewire): ?string => self::anchorLinkText($get('anchor'), $livewire)),
|
->helperText(fn (Get $get, $livewire): ?string => self::anchorLinkText($get('anchor'), $livewire)),
|
||||||
Toggle::make('hidden')
|
Toggle::make('hidden')
|
||||||
->label('Auf der Website ausblenden')
|
->label('Auf der Website ausblenden')
|
||||||
->live()
|
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Der Abschnitt bleibt im Entwurf erhalten, erscheint aber nicht auf der Website. Auch eine Sprungmarke dieses Abschnitts führt dann ins Leere. In der Seitenvorschau steht an seiner Stelle ein Hinweis.')
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Der Abschnitt bleibt im Entwurf erhalten, erscheint aber nicht auf der Website. Auch eine Sprungmarke dieses Abschnitts führt dann ins Leere. In der Seitenvorschau steht an seiner Stelle ein Hinweis.')
|
||||||
->hintColor('gray')
|
->hintColor('gray'),
|
||||||
->columnSpanFull(),
|
];
|
||||||
])
|
}
|
||||||
->columns(['default' => 1, 'md' => 2]);
|
|
||||||
|
/**
|
||||||
|
* Sprungmarke in die zulässige Form bringen (wie beim Verlassen des Feldes); leer ergibt null.
|
||||||
|
*/
|
||||||
|
private static function slugAnchor(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($value) || trim($value) === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$slug = Str::limit(Str::slug($value, '-', 'de'), PageSections::MAX_ANCHOR, '');
|
||||||
|
|
||||||
|
return $slug === '' ? null : $slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{name: ?string, anchor: ?string, hidden: bool}
|
||||||
|
*/
|
||||||
|
private static function settingsOf(mixed $state, string $item): array
|
||||||
|
{
|
||||||
|
$section = is_array($state) && is_array($state[$item] ?? null) ? $state[$item] : [];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => is_string($section['name'] ?? null) ? $section['name'] : null,
|
||||||
|
'anchor' => is_string($section['anchor'] ?? null) ? $section['anchor'] : null,
|
||||||
|
'hidden' => (bool) ($section['hidden'] ?? false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken der anderen Abschnitte (auch ungespeicherte): Eine Marke gibt es je Seite nur einmal.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function otherAnchors(mixed $state, string $item): array
|
||||||
|
{
|
||||||
|
$anchors = [];
|
||||||
|
|
||||||
|
foreach (is_array($state) ? $state : [] as $key => $section) {
|
||||||
|
if ((string) $key === $item || ! is_array($section) || ! is_string($section['anchor'] ?? null) || trim($section['anchor']) === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchors[] = mb_strtolower(trim($section['anchor']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $anchors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function position(mixed $state, string $item): int
|
||||||
|
{
|
||||||
|
$index = array_search($item, array_map('strval', array_keys(is_array($state) ? $state : [])), true);
|
||||||
|
|
||||||
|
return $index === false ? 1 : $index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\SectionTransfer;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\Repeater;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schalter im Abschnittskopf: Abschnitt auf eine andere Seite kopieren oder verschieben. Beide öffnen einen kleinen
|
||||||
|
* Dialog mit Zielseite und Position; die Arbeit erledigt EditPage::transferSection.
|
||||||
|
*/
|
||||||
|
class SectionTransferActions
|
||||||
|
{
|
||||||
|
public static function copy(): Action
|
||||||
|
{
|
||||||
|
return self::base('auf_seite_kopieren', false)
|
||||||
|
->label('Abschnitt auf eine andere Seite kopieren')
|
||||||
|
->tooltip('Auf andere Seite kopieren')
|
||||||
|
->icon('heroicon-o-document-plus')
|
||||||
|
->modalSubmitActionLabel('Kopieren')
|
||||||
|
->modalDescription('Der Abschnitt bleibt hier erhalten. Auf der Zielseite entsteht ein neuer Abschnitt mit gleichem Inhalt und gleichen Einstellungen. Die Zielseite erhält einen neuen Entwurf; veröffentlicht wird nichts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function move(): Action
|
||||||
|
{
|
||||||
|
return self::base('auf_seite_verschieben', true)
|
||||||
|
->label('Abschnitt auf eine andere Seite verschieben')
|
||||||
|
->tooltip('Auf andere Seite verschieben')
|
||||||
|
->icon('heroicon-o-arrow-right-circle')
|
||||||
|
->modalSubmitActionLabel('Verschieben')
|
||||||
|
->modalDescription('Der Abschnitt wird auf die Zielseite gesetzt und von dieser Seite entfernt. Beide Seiten werden als Entwurf gespeichert, auch übrige offene Änderungen dieser Seite. Veröffentlicht wird nichts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function base(string $name, bool $move): Action
|
||||||
|
{
|
||||||
|
return Action::make($name)
|
||||||
|
->iconButton()
|
||||||
|
->color('gray')
|
||||||
|
->extraAttributes(['data-luf-uebertragen' => $move ? 'verschieben' : 'kopieren'])
|
||||||
|
->visible(fn ($livewire): bool => is_object($livewire) && method_exists($livewire, 'transferSection'))
|
||||||
|
->modalWidth(Width::Large)
|
||||||
|
->modalHeading(fn (array $arguments, Repeater $component): string => 'Abschnitt '.self::number($component, $arguments).($move ? ' auf eine andere Seite verschieben' : ' auf eine andere Seite kopieren'))
|
||||||
|
->modalCancelActionLabel('Abbrechen')
|
||||||
|
->schema(fn ($livewire): array => [
|
||||||
|
Select::make('page')
|
||||||
|
->label('Zielseite')
|
||||||
|
->placeholder('Seite wählen')
|
||||||
|
->options(fn (): array => self::pageOptions($livewire))
|
||||||
|
->searchable()
|
||||||
|
->required()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn (Set $set) => $set('position', SectionTransfer::END)),
|
||||||
|
Select::make('position')
|
||||||
|
->label('Position auf der Zielseite')
|
||||||
|
->options(fn (Get $get): array => self::positionOptions($get('page')))
|
||||||
|
->default(SectionTransfer::END)
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->required()
|
||||||
|
->disabled(fn (Get $get): bool => blank($get('page'))),
|
||||||
|
])
|
||||||
|
->action(function (array $data, array $arguments, Repeater $component) use ($move): void {
|
||||||
|
$component->getLivewire()->transferSection((string) ($arguments['item'] ?? ''), (int) ($data['page'] ?? 0), (string) ($data['position'] ?? SectionTransfer::END), $move);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seiten außer der geöffneten, nach Pfad; der Titel hilft beim Erkennen.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
private static function pageOptions(mixed $livewire): array
|
||||||
|
{
|
||||||
|
$current = is_object($livewire) && is_object($livewire->record ?? null) ? $livewire->record->getKey() : null;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return Page::query()
|
||||||
|
->with(['latestRevision', 'publishedRevision'])
|
||||||
|
->when($current !== null, fn ($query) => $query->whereKeyNot($current))
|
||||||
|
->orderBy('path')
|
||||||
|
->get()
|
||||||
|
->filter(fn (Page $page): bool => $user?->can('update', $page) ?? false)
|
||||||
|
->mapWithKeys(function (Page $page): array {
|
||||||
|
$title = ($page->latestRevision ?? $page->publishedRevision)?->contentTitle();
|
||||||
|
|
||||||
|
return [$page->getKey() => $page->path.(filled($title) ? ' – '.$title : '')];
|
||||||
|
})
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function positionOptions(mixed $pageId): array
|
||||||
|
{
|
||||||
|
$page = filled($pageId) ? Page::query()->with(['latestRevision', 'publishedRevision'])->find($pageId) : null;
|
||||||
|
|
||||||
|
return $page === null ? [SectionTransfer::END => 'Am Ende der Seite'] : app(SectionTransfer::class)->positions($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function number(Repeater $component, array $arguments): int
|
||||||
|
{
|
||||||
|
$keys = array_map('strval', array_keys((array) $component->getRawState()));
|
||||||
|
$index = array_search((string) ($arguments['item'] ?? ''), $keys, true);
|
||||||
|
|
||||||
|
return $index === false ? 1 : $index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,29 +2,24 @@
|
|||||||
|
|
||||||
namespace App\Filament\Support;
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
use App\Domain\Communication\FieldPurpose;
|
|
||||||
use App\Domain\Communication\FieldType;
|
use App\Domain\Communication\FieldType;
|
||||||
use App\Domain\Communication\FormEditor;
|
use App\Domain\Communication\FormEditor;
|
||||||
use App\Domain\Communication\FormTexts;
|
use App\Domain\Communication\FormTexts;
|
||||||
use App\Domain\Communication\InquiryField;
|
use App\Domain\Communication\InquiryField;
|
||||||
use App\Domain\Communication\InquiryIssue;
|
use App\Domain\Communication\InquiryIssue;
|
||||||
use App\Domain\Communication\TemplateCompiler;
|
use App\Domain\Communication\TemplateCompiler;
|
||||||
use Filament\Forms\Components\Builder;
|
|
||||||
use Filament\Forms\Components\Builder\Block;
|
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\ViewField;
|
||||||
use Filament\Schemas\Components\Component;
|
use Filament\Schemas\Components\Component;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Components\Tabs;
|
use Filament\Schemas\Components\Tabs;
|
||||||
use Filament\Schemas\Components\Tabs\Tab;
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
use Filament\Schemas\Components\Text;
|
use Filament\Schemas\Components\Text;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Components\Utilities\Set;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formular-Editor (ADR-61): ein Formular wird an einer Stelle bearbeitet. Es besteht aus Bereichen (im mehrstufigen Dialog
|
* Formular-Editor (ADR-61): ein Formular wird an einer Stelle bearbeitet. Es besteht aus Bereichen (im mehrstufigen Dialog
|
||||||
@@ -34,23 +29,17 @@
|
|||||||
*/
|
*/
|
||||||
final class TemplateEditor
|
final class TemplateEditor
|
||||||
{
|
{
|
||||||
private const EFFECT_LABELS = [
|
|
||||||
'step' => ['show' => 'Bereich nur anzeigen, wenn …', 'hide' => 'Bereich ausblenden, wenn …', 'skip' => 'Bereich überspringen, wenn …'],
|
|
||||||
'group' => ['show' => 'Teilbereich nur anzeigen, wenn …', 'hide' => 'Teilbereich ausblenden, wenn …'],
|
|
||||||
'field' => ['show' => 'Feld nur anzeigen, wenn …', 'hide' => 'Feld ausblenden, wenn …', 'require' => 'Pflichtfeld, wenn …'],
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list<Component>
|
* @return list<Component>
|
||||||
*/
|
*/
|
||||||
public static function schema(): array
|
public static function schema(?int $templateId = null): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
TextInput::make('name')->label('Name des Formulars')->required()->maxLength(120)
|
TextInput::make('name')->label('Name des Formulars')->required()->maxLength(120)
|
||||||
->helperText('So heißt das Formular in der Verwaltung und in der Auswahl des Widgets „Anfrage“.'),
|
->helperText('So heißt das Formular in der Verwaltung und in der Auswahl des Widgets „Anfrage“.'),
|
||||||
Textarea::make('description')->label('Beschreibung (nur Verwaltung)')->rows(2)->maxLength(400),
|
Textarea::make('description')->label('Beschreibung (nur Verwaltung)')->rows(2)->maxLength(400),
|
||||||
Tabs::make('vorlage')->persistTabInQueryString('bereich')->tabs([
|
Tabs::make('vorlage')->persistTabInQueryString('bereich')->columnSpanFull()->tabs([
|
||||||
Tab::make('Aufbau')->icon('heroicon-o-queue-list')->schema(self::structure()),
|
Tab::make('Aufbau')->icon('heroicon-o-queue-list')->schema(self::structure($templateId)),
|
||||||
Tab::make('Texte')->icon('heroicon-o-chat-bubble-bottom-center-text')->schema(self::texts()),
|
Tab::make('Texte')->icon('heroicon-o-chat-bubble-bottom-center-text')->schema(self::texts()),
|
||||||
Tab::make('Weitere Regeln')->icon('heroicon-o-adjustments-horizontal')->schema(self::rules()),
|
Tab::make('Weitere Regeln')->icon('heroicon-o-adjustments-horizontal')->schema(self::rules()),
|
||||||
]),
|
]),
|
||||||
@@ -58,175 +47,23 @@ public static function schema(): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Der Aufbau ist eine eigene Formularansicht (resources/views/filament/communication/form-editor.blade.php). Sie führt
|
||||||
|
* den Baum aus Bereichen, Teilbereichen und Feldern im Browser und übergibt ihn beim Speichern als Text (editor_json);
|
||||||
|
* FormEditor prüft und speichert ihn.
|
||||||
|
*
|
||||||
* @return list<Component>
|
* @return list<Component>
|
||||||
*/
|
*/
|
||||||
private static function structure(): array
|
private static function structure(?int $templateId): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Text::make('Ein Formular besteht aus Bereichen. Im mehrstufigen Dialog ist jeder Bereich ein Schritt, im langen Formular stehen alle Bereiche untereinander. In einem Bereich legst du Felder an; ein Teilbereich fasst Felder unter einer Überschrift zusammen. Bedingungen stehen direkt am Feld oder Bereich. Neue Felder und Auswahlwerte stehen in Bedingungen zur Verfügung, sobald das Formular einmal gespeichert ist.'),
|
ViewField::make('editor_json')
|
||||||
Repeater::make('editor.areas')
|
->hiddenLabel()
|
||||||
->label('Bereiche')
|
->view('filament.communication.form-editor')
|
||||||
->schema([
|
->viewData(['config' => app(FormEditor::class)->clientConfig($templateId)])
|
||||||
Hidden::make('key')->default(fn (): string => 's'.Str::lower(Str::random(6))),
|
->columnSpanFull(),
|
||||||
TextInput::make('title')->label('Titel des Bereichs')->required()->maxLength(120)->live(onBlur: true)
|
|
||||||
->helperText('Im mehrstufigen Dialog die Überschrift des Schritts.'),
|
|
||||||
Textarea::make('intro')->label('Einleitung (optional)')->rows(2)->maxLength(600),
|
|
||||||
self::condition('step'),
|
|
||||||
Builder::make('items')
|
|
||||||
->label('Inhalt des Bereichs')
|
|
||||||
->blocks(self::blocks())
|
|
||||||
->addActionLabel('Feld oder Teilbereich hinzufügen')
|
|
||||||
->blockPickerColumns(2)
|
|
||||||
->blockNumbers(false)
|
|
||||||
->reorderableWithButtons()
|
|
||||||
->collapsible()
|
|
||||||
->live(),
|
|
||||||
])
|
|
||||||
->reorderableWithButtons()
|
|
||||||
->collapsible()
|
|
||||||
->addActionLabel('Bereich hinzufügen')
|
|
||||||
->live()
|
|
||||||
->itemLabel(fn (array $state): string => (($state['title'] ?? '') ?: 'Neuer Bereich').(filled($state['cond']['effect'] ?? null) ? ' · mit Bedingung' : '')),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<Block>
|
|
||||||
*/
|
|
||||||
private static function blocks(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
Block::make('field')
|
|
||||||
->label(fn (?array $state): string => $state === null ? 'Feld' : 'Feld: '.(($state['label'] ?? '') ?: 'neu').self::fieldBadges($state))
|
|
||||||
->icon('heroicon-o-pencil-square')
|
|
||||||
->schema([
|
|
||||||
Hidden::make('key')->default(fn (): string => FormEditor::temporaryKey()),
|
|
||||||
Hidden::make('name'),
|
|
||||||
Hidden::make('used_in'),
|
|
||||||
Select::make('pick')->label('Vorhandenes Feld verwenden (optional)')->searchable()->live()->dehydrated(false)
|
|
||||||
->options(fn ($livewire): array => self::catalogFields((array) ($livewire->data['editor'] ?? [])))
|
|
||||||
->placeholder('Neues Feld anlegen')
|
|
||||||
->visible(fn (Get $get): bool => str_starts_with((string) $get('key'), 'tmp_'))
|
|
||||||
->afterStateUpdated(function ($state, Set $set): void {
|
|
||||||
$field = filled($state) ? InquiryField::query()->where('key', $state)->first() : null;
|
|
||||||
|
|
||||||
if ($field === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$set('key', $field->key);
|
|
||||||
$set('name', $field->name);
|
|
||||||
$set('label', $field->label);
|
|
||||||
$set('help', $field->help);
|
|
||||||
$set('type', $field->type->value);
|
|
||||||
$set('options', $field->optionList());
|
|
||||||
$set('purpose', $field->purpose?->value);
|
|
||||||
$set('pick', null);
|
|
||||||
})
|
|
||||||
->helperText('Felder wie „E-Mail-Adresse“ lassen sich in mehreren Formularen verwenden.'),
|
|
||||||
TextInput::make('label')->label('Frage oder Beschriftung im Formular')->required()->maxLength(200)->live(onBlur: true),
|
|
||||||
Select::make('type')->label('Art der Antwort')->required()->live()->dehydrated()
|
|
||||||
->options(FieldType::options())
|
|
||||||
->disabled(fn (Get $get): bool => ! str_starts_with((string) $get('key'), 'tmp_'))
|
|
||||||
->helperText('Nach dem Speichern nicht mehr änderbar, weil Bedingungen und bisherige Anfragen darauf aufbauen. Soll sich die Art ändern, lege ein neues Feld an.'),
|
|
||||||
Repeater::make('options')->label('Auswahlwerte')
|
|
||||||
->schema([Hidden::make('key'), TextInput::make('label')->label('Bezeichnung')->required()->maxLength(120)])
|
|
||||||
->reorderableWithButtons()
|
|
||||||
->addActionLabel('Auswahlwert hinzufügen')
|
|
||||||
->minItems(1)
|
|
||||||
->itemLabel(fn (array $state): ?string => $state['label'] ?? null)
|
|
||||||
->visible(fn (Get $get): bool => FieldType::tryFrom((string) $get('type'))?->hasOptions() ?? false)
|
|
||||||
->helperText('Jeder Wert behält seine feste interne Kennung; eine Umbenennung beschädigt keine Anfragen.'),
|
|
||||||
Textarea::make('help')->label('Hilfetext (optional)')->rows(2)->maxLength(600)->helperText('Steht unter der Frage.'),
|
|
||||||
Toggle::make('required')->label('Pflichtfeld'),
|
|
||||||
Section::make('Weitere Einstellungen')->compact()->collapsed()->schema([
|
|
||||||
Select::make('purpose')->label('Verwendung in der Anfrageübersicht')->options(FieldPurpose::options())->placeholder('Keine besondere Verwendung')
|
|
||||||
->helperText('Welche Angabe der Posteingang als Name, E-Mail-Adresse oder Nachricht zeigt. Jedes Formular braucht ein Feld „E-Mail-Adresse für Rückfragen“.'),
|
|
||||||
]),
|
|
||||||
Text::make(fn (Get $get): string => 'Dieses Feld wird auch in diesen Formularen verwendet: '.$get('used_in').'. Eine Änderung gilt dort mit der nächsten Veröffentlichung.')
|
|
||||||
->visible(fn (Get $get): bool => filled($get('used_in'))),
|
|
||||||
self::condition('field'),
|
|
||||||
]),
|
|
||||||
Block::make('section')
|
|
||||||
->label(fn (?array $state): string => $state === null ? 'Teilbereich' : 'Teilbereich: '.(($state['label'] ?? '') ?: 'neu').(filled($state['cond']['effect'] ?? null) ? ' (Bedingung)' : ''))
|
|
||||||
->icon('heroicon-o-rectangle-group')
|
|
||||||
->schema([
|
|
||||||
Hidden::make('key')->default(fn (): string => FormEditor::temporaryKey()),
|
|
||||||
Hidden::make('missing')->default(false),
|
|
||||||
Hidden::make('used_in'),
|
|
||||||
TextInput::make('label')->label('Überschrift des Teilbereichs')->required()->maxLength(200)->live(onBlur: true)
|
|
||||||
->helperText('Die Felder darunter stehen im Formular unter dieser Überschrift, bis ein weiterer Teilbereich oder „Ende des Teilbereichs“ folgt.'),
|
|
||||||
Textarea::make('description')->label('Erläuterung (optional)')->rows(2)->maxLength(600),
|
|
||||||
Text::make(fn (Get $get): string => 'Dieser Teilbereich wird auch in diesen Formularen verwendet: '.$get('used_in').'. Änderungen an seinen Feldern gelten dort mit der nächsten Veröffentlichung.')
|
|
||||||
->visible(fn (Get $get): bool => filled($get('used_in'))),
|
|
||||||
self::condition('group'),
|
|
||||||
]),
|
|
||||||
Block::make('end')
|
|
||||||
->label('Ende des Teilbereichs')
|
|
||||||
->icon('heroicon-o-arrow-uturn-down')
|
|
||||||
->schema([Text::make('Die folgenden Felder stehen wieder ohne Teilbereich.')]),
|
|
||||||
Block::make('issue')
|
|
||||||
->label('Frage nach dem Anliegen')
|
|
||||||
->icon('heroicon-o-chat-bubble-left-right')
|
|
||||||
->maxItems(1)
|
|
||||||
->schema([
|
|
||||||
Select::make('issues')->label('Angebotene Anliegen')->multiple()->live()
|
|
||||||
->options(fn (): array => InquiryIssue::query()->offered()->whereNull('parent_id')->orderBy('sort_order')->pluck('label', 'key')->all())
|
|
||||||
->helperText('Welche Anliegen dieses Formular kennt. Leer: alle angebotenen. Ein Anfragegrund im Widget kann daraus eines vorwählen; die Frage entfällt dann. Anliegen und Unteranliegen pflegst du unter „Einstellungen → Anliegen“.'),
|
|
||||||
]),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bedingung am Element: Wirkung, Verknüpfung und eine Liste von Vergleichen. Ohne Wirkung gibt es keine Bedingung.
|
|
||||||
*/
|
|
||||||
private static function condition(string $kind): Section
|
|
||||||
{
|
|
||||||
return Section::make('Bedingung (optional)')->statePath('cond')->compact()->collapsed()->schema([
|
|
||||||
Hidden::make('pos'),
|
|
||||||
Select::make('effect')->label('Wirkung')->options(self::EFFECT_LABELS[$kind])->placeholder('Keine Bedingung')->live()
|
|
||||||
->helperText($kind === 'step' ? 'Zum Beispiel: Bereich „Angaben zur Schule“ nur anzeigen, wenn das Anliegen „Kursanfrage“ ist.' : null),
|
|
||||||
Select::make('match')->label('Es müssen zutreffen')->options(['all' => 'alle Bedingungen', 'any' => 'mindestens eine Bedingung'])->default('all')
|
|
||||||
->visible(fn (Get $get): bool => filled($get('effect'))),
|
|
||||||
Repeater::make('conditions')
|
|
||||||
->label('Bedingungen')
|
|
||||||
->schema([
|
|
||||||
Select::make('source')->label('Wenn …')->required()->live()->searchable()
|
|
||||||
->options(fn (Select $component, $livewire): array => self::sources((array) ($livewire->data['editor'] ?? []), $component->getStatePath())),
|
|
||||||
Select::make('op')->label('Vergleich')->required()->options(TemplateCompiler::OPERATORS)->default('eq')->live(),
|
|
||||||
Select::make('values')->label('Wert')->required()->multiple()
|
|
||||||
->options(fn (Get $get, $livewire): array => self::sourceValues((array) ($livewire->data['editor'] ?? []), (string) $get('source'))),
|
|
||||||
])
|
|
||||||
->addActionLabel('Bedingung hinzufügen')
|
|
||||||
->visible(fn (Get $get): bool => filled($get('effect')))
|
|
||||||
->helperText('Zur Auswahl stehen Felder, die im Formular weiter oben stehen.'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed>|null $state
|
|
||||||
*/
|
|
||||||
private static function fieldBadges(?array $state): string
|
|
||||||
{
|
|
||||||
$parts = [];
|
|
||||||
|
|
||||||
if (filled($state['type'] ?? null)) {
|
|
||||||
$parts[] = FieldType::tryFrom((string) $state['type'])?->label();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($state['required'] ?? false) {
|
|
||||||
$parts[] = 'Pflicht';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filled($state['cond']['effect'] ?? null)) {
|
|
||||||
$parts[] = 'Bedingung';
|
|
||||||
}
|
|
||||||
|
|
||||||
$parts = array_filter($parts);
|
|
||||||
|
|
||||||
return $parts === [] ? '' : ' ('.implode(', ', $parts).')';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list<Component>
|
* @return list<Component>
|
||||||
*/
|
*/
|
||||||
@@ -241,7 +78,7 @@ private static function rules(): array
|
|||||||
Hidden::make('pos'),
|
Hidden::make('pos'),
|
||||||
Select::make('effect')->label('Wirkung')->required()->live()->options(TemplateCompiler::EFFECTS),
|
Select::make('effect')->label('Wirkung')->required()->live()->options(TemplateCompiler::EFFECTS),
|
||||||
Select::make('target')->label('Ziel')->required()->live()->searchable()
|
Select::make('target')->label('Ziel')->required()->live()->searchable()
|
||||||
->options(fn ($livewire, Get $get): array => self::targets((array) ($livewire->data['editor'] ?? []), (string) $get('effect'))),
|
->options(fn ($livewire, Get $get): array => self::targets(self::flat($livewire), (string) $get('effect'))),
|
||||||
Select::make('value')->label('Vorbelegen mit')->live()
|
Select::make('value')->label('Vorbelegen mit')->live()
|
||||||
->options(fn (Get $get): array => str_starts_with((string) $get('target'), 'field:') ? self::fieldValues(substr((string) $get('target'), 6)) : [])
|
->options(fn (Get $get): array => str_starts_with((string) $get('target'), 'field:') ? self::fieldValues(substr((string) $get('target'), 6)) : [])
|
||||||
->visible(fn (Get $get): bool => $get('effect') === 'preset')->required(fn (Get $get): bool => $get('effect') === 'preset'),
|
->visible(fn (Get $get): bool => $get('effect') === 'preset')->required(fn (Get $get): bool => $get('effect') === 'preset'),
|
||||||
@@ -250,17 +87,17 @@ private static function rules(): array
|
|||||||
->label('Bedingungen')
|
->label('Bedingungen')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('source')->label('Wenn …')->required()->live()->searchable()
|
Select::make('source')->label('Wenn …')->required()->live()->searchable()
|
||||||
->options(fn ($livewire): array => self::sources((array) ($livewire->data['editor'] ?? []), null)),
|
->options(fn ($livewire): array => self::sources(self::flat($livewire))),
|
||||||
Select::make('op')->label('Vergleich')->required()->options(TemplateCompiler::OPERATORS)->default('eq')->live(),
|
Select::make('op')->label('Vergleich')->required()->options(TemplateCompiler::OPERATORS)->default('eq')->live(),
|
||||||
Select::make('values')->label('Wert')->required()->multiple()
|
Select::make('values')->label('Wert')->required()->multiple()
|
||||||
->options(fn ($livewire, Get $get): array => self::sourceValues((array) ($livewire->data['editor'] ?? []), (string) $get('source'))),
|
->options(fn ($livewire, Get $get): array => self::sourceValues(self::flat($livewire), (string) $get('source'))),
|
||||||
])
|
])
|
||||||
->minItems(1)
|
->minItems(1)
|
||||||
->addActionLabel('Bedingung hinzufügen'),
|
->addActionLabel('Bedingung hinzufügen'),
|
||||||
])
|
])
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->addActionLabel('Regel hinzufügen')
|
->addActionLabel('Regel hinzufügen')
|
||||||
->itemLabel(fn (array $state, $livewire): string => (TemplateCompiler::EFFECTS[$state['effect'] ?? ''] ?? 'Neue Regel').(($state['target'] ?? null) ? ' → '.self::targetName((string) $state['target'], (array) ($livewire->data['editor'] ?? [])) : '')),
|
->itemLabel(fn (array $state, $livewire): string => (TemplateCompiler::EFFECTS[$state['effect'] ?? ''] ?? 'Neue Regel').(($state['target'] ?? null) ? ' → '.self::targetName((string) $state['target'], self::flat($livewire)) : '')),
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -288,16 +125,15 @@ private static function texts(): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Felder des Katalogs, die im Formular noch nicht vorkommen.
|
* Der aktuelle Aufbau in der flachen Ansicht (Bereiche, Felder, Teilbereiche, Ende-Markierungen), aus dem Text der Formularansicht.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $editor
|
* @return array<string, mixed>
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
*/
|
||||||
private static function catalogFields(array $editor): array
|
private static function flat(mixed $livewire): array
|
||||||
{
|
{
|
||||||
$used = array_keys(self::inventory($editor)['fields']);
|
$tree = json_decode((string) ($livewire->data['editor_json'] ?? ''), true);
|
||||||
|
|
||||||
return InquiryField::query()->offered()->whereNotIn('key', $used)->orderBy('name')->pluck('name', 'key')->all();
|
return FormEditor::fromTree(is_array($tree) ? $tree : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -389,32 +225,13 @@ private static function targetName(string $target, array $editor = []): string
|
|||||||
* @param array<string, mixed> $editor
|
* @param array<string, mixed> $editor
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
private static function sources(array $editor, ?string $path): array
|
private static function sources(array $editor): array
|
||||||
{
|
{
|
||||||
$areaId = null;
|
|
||||||
$blockId = null;
|
|
||||||
|
|
||||||
if ($path !== null) {
|
|
||||||
$segments = explode('.', $path);
|
|
||||||
$areaAt = array_search('areas', $segments, true);
|
|
||||||
$itemAt = array_search('items', $segments, true);
|
|
||||||
$areaId = $areaAt === false ? null : ($segments[$areaAt + 1] ?? null);
|
|
||||||
$blockId = $itemAt === false ? null : ($segments[$itemAt + 1] ?? null);
|
|
||||||
}
|
|
||||||
|
|
||||||
$catalog = InquiryField::query()->get()->keyBy('key');
|
$catalog = InquiryField::query()->get()->keyBy('key');
|
||||||
$sources = [];
|
$sources = [];
|
||||||
|
|
||||||
foreach ((array) ($editor['areas'] ?? []) as $currentArea => $area) {
|
foreach ((array) ($editor['areas'] ?? []) as $area) {
|
||||||
if ($areaId !== null && (string) $currentArea === $areaId && $blockId === null) {
|
foreach ((array) ($area['items'] ?? []) as $block) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ((array) ($area['items'] ?? []) as $currentBlock => $block) {
|
|
||||||
if ($areaId !== null && (string) $currentArea === $areaId && (string) $currentBlock === $blockId) {
|
|
||||||
break 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = (array) ($block['data'] ?? []);
|
$data = (array) ($block['data'] ?? []);
|
||||||
$key = (string) ($data['key'] ?? '');
|
$key = (string) ($data['key'] ?? '');
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Concerns;
|
||||||
|
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liefert ein Bild einer Disk mit Zwischenspeicherung aus (docs/architektur/bildvarianten.md).
|
||||||
|
*
|
||||||
|
* Mit Versionsangabe in der Adresse (`?v=`) ändert sich die Adresse, sobald sich das Bild ändert; der Browser darf es
|
||||||
|
* dann ein Jahr behalten. Ohne Version bleibt es bei einer Rückfrage mit ETag und Last-Modified (304 ohne Inhalt).
|
||||||
|
*/
|
||||||
|
trait ServesImages
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param 'public'|'private' $scope `private` für alles, was eine Anmeldung oder Berechtigung voraussetzt
|
||||||
|
*/
|
||||||
|
protected function respondWithImage(Request $request, string $diskName, string $path, string $scope = 'private', bool $versioned = false): Response
|
||||||
|
{
|
||||||
|
$disk = Storage::disk($diskName);
|
||||||
|
$headers = [
|
||||||
|
'Content-Disposition' => 'inline',
|
||||||
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
|
];
|
||||||
|
$response = $disk->response($path, null, $headers);
|
||||||
|
$modified = (int) $disk->lastModified($path);
|
||||||
|
$size = (int) $disk->size($path);
|
||||||
|
|
||||||
|
$response->setEtag(md5($path.'|'.$modified.'|'.$size));
|
||||||
|
$response->setLastModified(Carbon::createFromTimestamp($modified));
|
||||||
|
|
||||||
|
if ($versioned) {
|
||||||
|
$response->headers->set('Cache-Control', $scope.', max-age=31536000, immutable');
|
||||||
|
} else {
|
||||||
|
$response->headers->set('Cache-Control', $scope.', max-age=0, must-revalidate');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->isNotModified($request);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pfad der angefragten Größe (`?g=klein|mittel`), sonst die Hauptdatei. */
|
||||||
|
protected function imagePathFor(Request $request, string $diskName, string $path): string
|
||||||
|
{
|
||||||
|
$size = $request->query('g');
|
||||||
|
$resolved = ImageVariants::resolve(Storage::disk($diskName), $path, is_string($size) ? $size : null);
|
||||||
|
|
||||||
|
// Bestand ohne Fassungen: Die Hauptdatei geht hinaus, und die Warteschlange legt die Fassungen an (der Web-Prozess
|
||||||
|
// schreibt nie). Höchstens einmal je Tag und Bild; ist die Quelle schmaler als die Stufe, bleibt es bei der Hauptdatei.
|
||||||
|
if ($resolved === $path && ImageVariants::isSize($size) && Cache::add('bildvarianten.'.md5($path), true, now()->addDay())) {
|
||||||
|
DeriveImageVariants::dispatch($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `?v=` ist da und eine einfache Zahl (Zeitstempel). */
|
||||||
|
protected function hasImageVersion(Request $request): bool
|
||||||
|
{
|
||||||
|
$version = $request->query('v');
|
||||||
|
|
||||||
|
return is_string($version) && preg_match('/^[0-9]{1,12}$/', $version) === 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,15 +12,18 @@
|
|||||||
use App\Domain\Identity\StaffRole;
|
use App\Domain\Identity\StaffRole;
|
||||||
use App\Domain\Media\ThumbnailDeriver;
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\EditorialCatalog;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
|
|
||||||
class EditorialPreviewController extends Controller
|
class EditorialPreviewController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
public function show(Composition $composition, ?CompositionVersion $version = null): View
|
public function show(Composition $composition, ?CompositionVersion $version = null): View
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
@@ -104,7 +107,7 @@ public function draft(Composition $composition): View
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function card(string $kind, int $subject): StreamedResponse
|
public function card(Request $request, string $kind, int $subject): SymfonyResponse
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
||||||
@@ -116,7 +119,13 @@ public function card(string $kind, int $subject): StreamedResponse
|
|||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $this->respondWithImage(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
|
$this->imagePathFor($request, 'media_derived', $path),
|
||||||
|
'private',
|
||||||
|
$this->hasImageVersion($request),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
use App\Domain\Media\FilmPlayback;
|
use App\Domain\Media\FilmPlayback;
|
||||||
use App\Domain\Media\HlsPlaylist;
|
use App\Domain\Media\HlsPlaylist;
|
||||||
use App\Domain\Media\MediaRendition;
|
use App\Domain\Media\MediaRendition;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\CourseOutline;
|
use App\Http\CourseOutline;
|
||||||
use App\Http\LibraryCatalog;
|
use App\Http\LibraryCatalog;
|
||||||
@@ -32,10 +33,13 @@
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class LibraryController extends Controller
|
class LibraryController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
||||||
public const TYPES = [
|
public const TYPES = [
|
||||||
'programm' => 'Programme',
|
'programm' => 'Programme',
|
||||||
@@ -361,7 +365,7 @@ public function rendition(
|
|||||||
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function thumbnail(Request $request, string $kind, int $subject): StreamedResponse
|
public function thumbnail(Request $request, string $kind, int $subject): SymfonyResponse
|
||||||
{
|
{
|
||||||
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
||||||
$model = $kind === 'komposition'
|
$model = $kind === 'komposition'
|
||||||
@@ -373,7 +377,13 @@ public function thumbnail(Request $request, string $kind, int $subject): Streame
|
|||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $this->respondWithImage(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
|
$this->imagePathFor($request, 'media_derived', $path),
|
||||||
|
'private',
|
||||||
|
$this->hasImageVersion($request),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,16 +3,22 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Http\Controllers\Concerns\ServesByteRanges;
|
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class WebsiteMediaController extends Controller
|
class WebsiteMediaController extends Controller
|
||||||
{
|
{
|
||||||
use ServesByteRanges;
|
use ServesByteRanges;
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
public function show(Request $request, ContentElement $element, WebsiteMedia $media): StreamedResponse
|
public function show(Request $request, ContentElement $element, WebsiteMedia $media): Response
|
||||||
{
|
{
|
||||||
$presentation = $media->present($element);
|
$presentation = $media->present($element);
|
||||||
abort_if($presentation === null, 404);
|
abort_if($presentation === null, 404);
|
||||||
@@ -20,6 +26,45 @@ public function show(Request $request, ContentElement $element, WebsiteMedia $me
|
|||||||
$path = $element->website_public_path;
|
$path = $element->website_public_path;
|
||||||
abort_if(! is_string($path), 404);
|
abort_if(! is_string($path), 404);
|
||||||
|
|
||||||
return $this->respondWithRanges($request, 'media_public', $path, $presentation->kind !== 'bild');
|
if ($presentation->kind !== 'bild') {
|
||||||
|
return $this->respondWithRanges($request, 'media_public', $path, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $this->widthPath($request, $element, $path);
|
||||||
|
// Die Adresse trägt den Zeitpunkt der Freigabe. Gilt er noch, ändert sich der Inhalt unter dieser Adresse nicht mehr
|
||||||
|
// (eine neue Freigabe liefert eine neue Adresse); eine veraltete Adresse wird nur kurz vorgehalten und geprüft.
|
||||||
|
$current = $this->hasImageVersion($request)
|
||||||
|
&& (int) $request->query('v') === $element->website_released_at?->getTimestamp();
|
||||||
|
|
||||||
|
return $this->respondWithImage($request, 'media_public', $path, 'public', $current);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die angefragte Breite (`?w=640|1280|1920`), sonst die volle Datei. Fehlt die Breite noch, geht die volle Datei hinaus,
|
||||||
|
* und die Warteschlange legt die Breiten an (höchstens einmal je Stunde und Bild; der Web-Prozess schreibt nie).
|
||||||
|
*/
|
||||||
|
private function widthPath(Request $request, ContentElement $element, string $path): string
|
||||||
|
{
|
||||||
|
$width = $request->query('w');
|
||||||
|
|
||||||
|
if (! is_string($width) || preg_match('/^[0-9]{3,4}$/', $width) !== 1 || ! ImageVariants::isPublicWidth((int) $width)) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = ImageVariants::publicPath($path, (int) $width);
|
||||||
|
|
||||||
|
if (Storage::disk('media_public')->exists($variant)) {
|
||||||
|
return $variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Cache::add('bildvarianten.website.'.$element->id, true, now()->addHour())) {
|
||||||
|
DeriveWebsiteVariants::dispatch($element->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,7 @@ public function index(User $user): array
|
|||||||
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
||||||
'kind' => $picture['kind'],
|
'kind' => $picture['kind'],
|
||||||
'subject' => $picture['subject'],
|
'subject' => $picture['subject'],
|
||||||
|
'g' => 'mittel',
|
||||||
]),
|
]),
|
||||||
'url' => route('member.program', $composition),
|
'url' => route('member.program', $composition),
|
||||||
];
|
];
|
||||||
@@ -113,7 +114,7 @@ public function index(User $user): array
|
|||||||
: ($element?->id !== null ? 'element-'.$element->id : 'artikel-'.$article->id);
|
: ($element?->id !== null ? 'element-'.$element->id : 'artikel-'.$article->id);
|
||||||
$subject = $element ?? $composition ?? $article;
|
$subject = $element ?? $composition ?? $article;
|
||||||
$text = $element !== null ? $this->text($element) : null;
|
$text = $element !== null ? $this->text($element) : null;
|
||||||
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
$media[$key] = ($media[$key] ?? []) + [
|
$media[$key] = ($media[$key] ?? []) + [
|
||||||
'used_in' => [],
|
'used_in' => [],
|
||||||
'versions' => [],
|
'versions' => [],
|
||||||
@@ -376,7 +377,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($view !== null && $element !== null) {
|
if ($view !== null && $element !== null) {
|
||||||
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ private function entry(User $user, Grant $grant): array
|
|||||||
|
|
||||||
if ($grant->status === GrantStatus::Aktiv) {
|
if ($grant->status === GrantStatus::Aktiv) {
|
||||||
$imageUrl = $composition !== null
|
$imageUrl = $composition !== null
|
||||||
? ThumbnailRef::url('member.thumbnail', 'komposition', $composition->id, $composition->thumbnail_path)
|
? ThumbnailRef::url('member.thumbnail', 'komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at)
|
||||||
: ($element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path));
|
: ($element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at));
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $composition !== null
|
$title = $composition !== null
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die kleineren Fassungen (klein, mittel) zu einem vorhandenen Vorschaubild an. Läuft nur in der Warteschlange, die in
|
||||||
|
* derived/ schreiben darf. Auslöser: Bestand ohne Fassungen, den die Auslieferung oder der Befehl `media:varianten` findet.
|
||||||
|
*/
|
||||||
|
class DeriveImageVariants implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(public readonly string $path) {}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
if (preg_match('#^vorschau/[A-Za-z0-9._\-/]+$#', $this->path) !== 1 || str_contains($this->path, '..')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $this->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Breiten für die Website zu einem bereits freigegebenen Bild an (Bestand von vor den Bildfassungen). Verändert
|
||||||
|
* weder die Freigabe noch den Prüfverlauf; die Freigabe selbst schreibt die Fassungen in {@see PublishWebsiteMedia}.
|
||||||
|
*/
|
||||||
|
class DeriveWebsiteVariants implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(public readonly int $elementId) {}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || $element->output_class !== 'bild' || $element->website_released_at === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
|
||||||
|
if (! is_string($path) || preg_match('#^website/'.$element->id.'/datei\.[a-z0-9]+$#', $path) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$disk = Storage::disk('media_public');
|
||||||
|
ImageVariants::generatePublic($disk, $disk, $path, $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\IdentityChange;
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
use App\Domain\Media\WebsiteRelease;
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
@@ -51,6 +52,12 @@ public function handle(WebsiteRelease $release): void
|
|||||||
|
|
||||||
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||||
Storage::disk('media_public')->delete($previous);
|
Storage::disk('media_public')->delete($previous);
|
||||||
|
ImageVariants::deletePublic(Storage::disk('media_public'), $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class === 'bild') {
|
||||||
|
// Breiten für die Website neben der Hauptdatei; ohne sie liefert die Website immer die volle Datei.
|
||||||
|
ImageVariants::generatePublic(Storage::disk('media_derived'), Storage::disk('media_public'), $derived, $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||||
@@ -69,6 +76,8 @@ private function deletePublicFile(ContentElement $element): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
Storage::disk('media_public')->delete($path);
|
Storage::disk('media_public')->delete($path);
|
||||||
|
// Auch die Breiten: Sonst bliebe ein zurückgenommenes Bild unter dem Namen einer Fassung erreichbar.
|
||||||
|
ImageVariants::deletePublic(Storage::disk('media_public'), $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||||
|
|||||||
@@ -928,3 +928,62 @@ ## ADR-61 – Kommunikation: Formular-Editor an einem Ort und Anfragegründe im
|
|||||||
**Alternativen.** Signierte Widget-Konfiguration in der Seite (verworfen: Der Grund ist keine Berechtigung; mehr bewegliche Teile ohne Gewinn). Neue Tabellen für Widget-Konfigurationen (ausgeschlossen: kein neues Datenmodell). Verschachtelte Teilbereiche mit eigenen Feldlisten im Editor (verworfen: sechs Ebenen Formularstruktur, schwer bedienbar; die flache Liste mit „Ende des Teilbereichs“ bildet dasselbe ab). Feldänderungen je Formular als Kopie (verworfen: zweite Wahrheit; der Hinweis auf gemeinsame Verwendung genügt, Fassungen sind unveränderlich).
|
**Alternativen.** Signierte Widget-Konfiguration in der Seite (verworfen: Der Grund ist keine Berechtigung; mehr bewegliche Teile ohne Gewinn). Neue Tabellen für Widget-Konfigurationen (ausgeschlossen: kein neues Datenmodell). Verschachtelte Teilbereiche mit eigenen Feldlisten im Editor (verworfen: sechs Ebenen Formularstruktur, schwer bedienbar; die flache Liste mit „Ende des Teilbereichs“ bildet dasselbe ab). Feldänderungen je Formular als Kopie (verworfen: zweite Wahrheit; der Hinweis auf gemeinsame Verwendung genügt, Fassungen sind unveränderlich).
|
||||||
**Folgen.** Keine Migration. Zwei bestehende Tests wurden bewusst geändert (Widget-Vertrag: Anfragegründe statt Einstieg). Rückfall: ein Code-Stand ohne ADR-61 kennt `data.reasons` nicht und zeigt ein so gespeichertes Widget nicht an (die Seite bleibt gültig); Formulare und Anfragen bleiben unverändert, im Katalog angelegte Felder bleiben bestehen.
|
**Folgen.** Keine Migration. Zwei bestehende Tests wurden bewusst geändert (Widget-Vertrag: Anfragegründe statt Einstieg). Rückfall: ein Code-Stand ohne ADR-61 kennt `data.reasons` nicht und zeigt ein so gespeichertes Widget nicht an (die Seite bleibt gültig); Formulare und Anfragen bleiben unverändert, im Katalog angelegte Felder bleiben bestehen.
|
||||||
**Quelle.** Entwicklungsauftrag von Lars (UX-Überarbeitung der Kommunikationsverwaltung und des CMS-Kontakt-Widgets) vom 27.11.2026; ADR-60.
|
**Quelle.** Entwicklungsauftrag von Lars (UX-Überarbeitung der Kommunikationsverwaltung und des CMS-Kontakt-Widgets) vom 27.11.2026; ADR-60.
|
||||||
|
|
||||||
|
## ADR-62 – Kommunikation: Formularansicht mit Ziehen und Ablegen statt Builder-Liste
|
||||||
|
|
||||||
|
**Status am 28.11.2026:** Umgesetzt auf `feature/formular-editor-umbau`; praktische Abnahme durch den Betreiber auf `luf-test` offen. Ändert die Darstellung aus ADR-61, nicht die Daten. Beschreibung: `docs/architektur/kommunikationsverwaltung.md` (Abschnitt 13).
|
||||||
|
**Kontext.** Der Aufbau eines Formulars bestand aus verschachtelten Filament-Listen (Repeater und Builder mit aufklappbaren Blöcken). Bei einem Formular mit wenigen Feldern wirkte das riesig und unübersichtlich; ein Teilbereich sah aus wie ein geschlossener Block, dem man nichts zuordnen konnte (die Felder darunter gehörten nur über die Reihenfolge dazu). Der Betreiber verlangte eine formularähnliche Darstellung: links die Frage, daneben der Feldtyp, Hilfetext und Bedingungen über Symbole in einem Pop-up, Bereiche und Teilbereiche deutlich als Einheit, Ziehen und Ablegen für Felder und Teilbereiche.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Eigene Formularansicht** (`filament/communication/form-editor*.blade.php`, Alpine): Bereich = Karte mit Nummer, Titel und Symbolen (Einleitung, Bedingung, weitere Einstellungen, Entfernen); darin Felder als Zeilen (Griff, Frage, Art der Antwort, Pflicht, Symbole für Hilfetext, Auswahlwerte, Bedingung, weitere Einstellungen, Entfernen) und Teilbereiche als eingerahmte Einheit mit eigener Feldliste. Hilfetext, Auswahlwerte, Bedingung, Verwendung in der Anfrageübersicht, Verschieben nach … und der Katalog öffnen in einem Pop-up (natives `dialog`); gesetzte Angaben sind am Symbol markiert, die Bedingung steht als Satz unter dem Element.
|
||||||
|
- **Ziehen und Ablegen** mit SortableJS, das Filament mitliefert (`window.Sortable`, keine neue Abhängigkeit): Bereiche untereinander, Felder an jede Stelle eines Bereichs oder Teilbereichs, Teilbereiche zwischen Bereiche. Ein Teilbereich nimmt nur Felder auf. Ohne Maus: am Griff Pfeil hoch oder runter (am Rand verlässt ein Feld den Teilbereich) und „Verschieben nach …“ im Pop-up „Weitere Einstellungen“.
|
||||||
|
- **Rückgängig** nimmt Änderungen am Aufbau bis zum Speichern zurück (Hinzufügen, Entfernen, Verschieben). Entfernen fragt deshalb nicht nach.
|
||||||
|
- **Daten unverändert:** Der Browser führt den Baum (Bereiche → Felder und Teilbereiche → Felder) und übergibt ihn beim Speichern als Text. `FormEditor::validateTree` prüft ihn serverseitig (Titel, Frage, Auswahlwerte, Längen, Dopplungen, höchstens eine Frage nach dem Anliegen) und nennt Fehlendes, statt still zu kürzen; `FormEditor::fromTree` überführt ihn in dieselbe flache Ansicht wie bisher, aus der `persist` Katalog und Entwurf schreibt. Die Umwandlung `toTree`/`fromTree` ist verlustfrei; ein Test führt jedes Beispielformular durch den Baum und erhält denselben Entwurf und Katalog. Keine Migration, keine Änderung an Engine, Katalog und Anfrageverarbeitung.
|
||||||
|
- **Fehlende Angaben** sind rot umrandet und gezählt; das Speichern lehnt ein unvollständiges Formular mit den Gründen ab und legt nichts an.
|
||||||
|
- **Weitere Regeln** (Vorbelegungen, zusätzliche Regeln desselben Ziels) bleiben unverändert als Liste im Register „Weitere Regeln“; sie lesen den Aufbau aus dem Baumtext und werden kurz nach Änderungen mit dem Server abgeglichen.
|
||||||
|
**Alternativen.** Filament-Builder mit besseren Blocktiteln (verworfen: bleibt eine aufklappbare Endlosliste ohne sichtbare Zugehörigkeit). Neue Datenstruktur mit verschachtelten Teilbereichen im Entwurf (ausgeschlossen: kein neues Datenmodell; die Zugehörigkeit steht schon als Feldgruppe im Katalog). Eigenes Ziehen ohne Bibliothek (verworfen: Berührung, Animation und Randfälle liefert SortableJS).
|
||||||
|
**Folgen.** Keine Migration. Die Livewire-Tests des Editors wurden bewusst auf den Baumtext umgestellt (der Builder entfällt). Rückfall auf ADR-61: Der Entwurf bleibt gültig; die ältere Ansicht liest ihn wieder. Das Ziehen bietet auf Berührungsbildschirmen SortableJS-Standardverhalten, wurde dort aber nicht geprüft.
|
||||||
|
**Quelle.** Rückmeldung von Lars vom 28.11.2026 zur Bedienung des Formular-Editors; ADR-61.
|
||||||
|
|
||||||
|
## ADR-63 – Bildfassungen: Thumbnail, Web und Vollauflösung
|
||||||
|
|
||||||
|
**Status am 28.11.2026:** Umgesetzt auf `feature/bildvarianten`; Messung und Abnahme auf `luf-test` offen. Beschreibung: `docs/architektur/bildvarianten.md`.
|
||||||
|
**Kontext.** Medienauswahl, Contentmanager und Listen luden für jedes Kachelbild dieselbe Datei wie die Vorschau (bei Bildern bis 2400 px), die Website lieferte immer die volle Fassung. Jedes Bild war eine PHP-Anfrage mit Sitzung (`Set-Cookie`, Zeile in `sessions`) und `Cache-Control: no-cache, private`; der Browser behielt nichts. Gemessen auf `luf-test`: 120 bis 260 KB je Vorschaubild, ein PNG mit 1,2 MB als Website-Datei.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Drei Stufen je Bild.** Verwaltung: `klein` (360 px), `mittel` (960 px) und die volle Datei (`thumbnail_path`, unverändert). Website: Breiten 640, 1280 und 1920 px neben der vollen Datei (`website/{id}/datei-{breite}.jpg`). Fassungen entstehen nur, wenn die Quelle breiter ist; nie vergrößert.
|
||||||
|
- **Namensregel statt Spalte.** `element-12-klein.jpg` liegt neben `element-12.jpg`. Keine Migration. Fehlt eine Fassung, gilt die nächstgrößere Datei; Bestand bricht nicht.
|
||||||
|
- **Geschrieben wird nur in der Warteschlange** (`ThumbnailDeriver`, `PresentationFile::place`, `PublishWebsiteMedia`). Der Web-Prozess liest nur. Bestand ohne Fassungen füllt sich selbst: Die Auslieferung nimmt die volle Datei und legt einen Auftrag an (Website: `DeriveWebsiteVariants`, höchstens einmal je Stunde und Bild; Verwaltung und Mitgliederbereich: `DeriveImageVariants`, höchstens einmal je Tag und Bild); `media:varianten` holt alles auf einmal nach, ohne Zugriff auf den Server.
|
||||||
|
- **Zwischenspeicherung.** Adressen tragen Größe (`g`) und Version (`v`, `updated_at` des Mediums bzw. Zeitpunkt der Freigabe). Mit Version: ein Jahr, `immutable` (`private` in der Verwaltung und im Mitgliederbereich, `public` auf der Website). Ohne Version: ETag und Last-Modified, `304` ohne Inhalt. Eine neue Ableitung setzt die Version (`touch`).
|
||||||
|
- **Website ohne Sitzung.** Die Route `website.media` läuft ohne Sitzung, Cookies und CSRF: keine Sitzungszeile, kein `Set-Cookie`, zwischenspeicherbar.
|
||||||
|
- **`srcset`** in Hero, Bild mit Text, Karten und Medienkarte; Abschnittshintergründe nehmen die Breite 1920. Nur JPEG-Quellen erhalten Breiten (PNG, GIF, WebP können Transparenz tragen).
|
||||||
|
- **Rücknahme** der Website-Freigabe löscht auch die Breiten.
|
||||||
|
- **Auswahl im CMS:** Die Optionsliste fragte je Eintrag das Medium dreimal ab; geladene Medien werden jetzt weitergereicht.
|
||||||
|
**Alternativen.** WebP (verworfen für jetzt: das Docker-Image baut GD ohne WebP; eigener Schritt mit Dockerfile-Änderung). Fassungen im Aufruf berechnen und zwischenspeichern (verworfen: der Web-Prozess darf nicht schreiben). Spalten für Fassungen (verworfen: Namensregel genügt, keine Migration). Statische Auslieferung durch den Webserver (verworfen: private Medien bleiben hinter der Berechtigung).
|
||||||
|
**Folgen.** Keine Migration. Tests mit festen Adressen der Website-Bilder wurden bewusst geändert (Adresse trägt `?v=`, Bild-Tags tragen `srcset`). Rückfall: Ein Stand ohne ADR-63 kennt `g`/`v` nicht und liefert die volle Datei; die Fassungsdateien bleiben liegen und stören nicht. Offen: EXIF-Drehung (Handyfotos), WebP.
|
||||||
|
**Quelle.** Rückmeldung von Lars vom 28.11.2026 zu den Ladezeiten von Medienauswahl, Contentmanager und Website.
|
||||||
|
|
||||||
|
## ADR-64 – CMS-Seiteneditor: Abschnittseinstellungen im Dialog und kompakterer Seitenaufbau
|
||||||
|
|
||||||
|
**Status am 28.11.2026:** Umgesetzt auf `feature/cms-seitenaufbau-kompakt`; praktische Abnahme durch den Betreiber auf `luf-test` offen. Ändert nur Darstellung und Bedienung des Seiteneditors (ADR zur Seitenarbeitsfläche, Abschnitte mit Name und Sprungmarke). Abnahme: `docs/ux/verwaltung/abnahme/cms-seitenaufbau.md`.
|
||||||
|
**Kontext.** Jeder Abschnitt zeigte einen eigenen Block „Name, Sprungmarke und Sichtbarkeit“, dazu gestrichelte Rahmen um jeden Platz und Rahmen um Bausteinvorschauen. Bei Seiten mit mehreren Abschnitten füllten wiederholte Einstellungen und verschachtelte Rahmen den Bildschirm; Aufbau und Inhalt der Seite waren schwer zu überblicken.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Einstellungsdialog:** Ein Zahnrad im Abschnittskopf öffnet „Abschnitt N: Einstellungen“ (Name, Sprungmarke mit Vorschlag und Linkhinweis, „Auf der Website ausblenden“). Umgesetzt als Filament-Aktion am Abschnitt (`SectionEditor::settingsAction`); die drei Angaben bleiben als verdeckte Felder im Formularzustand, damit Speichern, Fingerabdruck („nicht gespeichert“) und Revisionen unverändert funktionieren.
|
||||||
|
- **Speicherverhalten:** „Übernehmen“ ändert nur den Seitenarbeitsstand (andere offene Eingaben der Seite bleiben); Abbrechen, Schließen und Esc verwerfen. Dauerhaft speichert weiter „Entwurf speichern“.
|
||||||
|
- **Prüfung:** Die Sprungmarke wird im Dialog in die zulässige Form gebracht und mit denselben Regeln und Texten geprüft wie beim Speichern (`PageSections::anchorProblem`), auch gegen noch ungespeicherte Marken der anderen Abschnitte. Lehnt das Speichern der Seite Name oder Sprungmarke ab, steht die Meldung am Abschnitt mit „Einstellungen öffnen“, und die Seite scrollt dorthin.
|
||||||
|
- **Kompakter Aufbau (nur Stile):** Der Einstellungsblock entfällt; Abstände in Abschnitt und Platzraster sind kleiner, ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens (nur ein leerer Platz bleibt umrandet), Rahmen um Baustein und Vorschau entfallen. Abschnittskante, Raster mit bis zu vier Einheiten, Konfigurieren, Duplizieren, Verschieben, Entfernen und Einklappen sind unverändert.
|
||||||
|
**Alternativen.** Eigenes Overlay statt Filament-Aktion (verworfen: Fokus, Esc und Abbrechen liefert die Aktion bereits). Einstellungen beim Abschnitt eingeklappt lassen (verworfen: der Kopf des eingeklappten Blocks belegt weiter eine Zeile je Abschnitt).
|
||||||
|
**Folgen.** Keine Migration, kein neues Seitenformat. Rückfall: Der ältere Stand zeigt die Eingabefelder wieder im Abschnitt; gespeicherte Werte bleiben erhalten.
|
||||||
|
**Quelle.** Auftrag von Lars vom 28.11.2026 (Überarbeitung der Übersicht des CMS-Seiteneditors).
|
||||||
|
|
||||||
|
## ADR-65 – CMS-Seiteneditor: Abschnitt auf eine andere Seite kopieren oder verschieben
|
||||||
|
|
||||||
|
**Status am 28.11.2026:** Umgesetzt auf `feature/cms-abschnitt-uebertragen`; praktische Abnahme durch den Betreiber auf `luf-test` offen. Abnahme: `docs/ux/verwaltung/abnahme/cms-abschnitt-uebertragen.md`.
|
||||||
|
**Kontext.** Abschnitte lassen sich nur innerhalb einer Seite duplizieren und verschieben. Wer einen Abschnitt auf einer anderen Seite braucht, baute ihn bisher von Hand nach.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Schalter und Dialog:** Zwei Icon-Schalter im Abschnittskopf („Auf andere Seite kopieren“, „Auf andere Seite verschieben“) öffnen einen kleinen Dialog: Zielseite als Auswahlfeld (ohne die geöffnete Seite, mit Titel zur Orientierung) und Position (Am Anfang, Am Ende, hinter einem wählbaren Abschnitt). Umgesetzt als Filament-Aktionen am Abschnitt (`SectionTransferActions`), Logik in `SectionTransfer`, Ablauf in `EditPage::transferSection`.
|
||||||
|
- **Quelle und Format:** Übertragen wird der Arbeitsstand des Abschnitts im Editor, aufbereitet wie beim Speichern. Die Zielseite erhält über `PageService::saveRevision` eine neue Entwurfsrevision; Format, Revisionen und Veröffentlichung bleiben unverändert, nichts wird veröffentlicht.
|
||||||
|
- **Kopie und Verschiebung:** Die Kopie bekommt neue Kennungen, die Verschiebung behält sie. Eine auf der Zielseite vergebene Sprungmarke wird mit „-2“, „-3“ … eindeutig gemacht und in der Meldung genannt (statt sie zu löschen oder die Übertragung abzulehnen).
|
||||||
|
- **Verschieben speichert die Quellseite:** Der Abschnitt darf nicht auf beiden Seiten stehen bleiben, wenn die Seite danach nicht gespeichert wird. Deshalb speichert das Verschieben die Quellseite als Entwurf und sagt das im Dialog (auch übrige offene Änderungen werden gespeichert).
|
||||||
|
- **Reihenfolge und Prüfung:** Erst werden Ziel (Höchstzahlen, Bausteinregeln) und beim Verschieben die Quelle ohne den Abschnitt geprüft; dann wird das Ziel, danach die Quelle geschrieben. Ein Ausfall dazwischen ergibt einen doppelten, nie einen verlorenen Abschnitt.
|
||||||
|
**Alternativen.** Verschieben ohne Speichern der Quellseite (verworfen: Abschnitt stünde nach dem Verlassen der Seite doppelt). Übertragung über ein eigenes Overlay (verworfen: die Filament-Aktion liefert Fokus, Esc und Abbrechen). Sprungmarke beim Kopieren leeren (verworfen: gleiche Einstellungen waren gefordert).
|
||||||
|
**Folgen.** Keine Migration. Verweise innerhalb der Seite (`#marke`) in übertragenen Widgets werden nicht umgeschrieben. Rückfall: Schalter entfallen; übertragene Abschnitte bleiben normale Abschnitte.
|
||||||
|
**Quelle.** Auftrag von Lars vom 28.11.2026.
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Bildfassungen (ADR-63)
|
||||||
|
|
||||||
|
Stand 28.11.2026. Gilt für alle Bilder, die die Anwendung anzeigt: Vorschaubilder der Verwaltung (Medienauswahl, Listen, Karten, Aufbau), Bilder im CMS und auf der Website.
|
||||||
|
|
||||||
|
## Stufen
|
||||||
|
|
||||||
|
| Stufe | Wo | Breite | Verwendung |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `klein` | `derived/vorschau/…-klein.jpg` | 360 px | Auswahl, Listen, Kacheln, Zeilen im Aufbau |
|
||||||
|
| `mittel` | `derived/vorschau/…-mittel.jpg` | 960 px | Detailansicht, Vorschau im Editor, Kartenbilder in Seitenvorschauen, Poster |
|
||||||
|
| voll | `derived/vorschau/element-N.jpg` (`thumbnail_path`) | Bilder bis 2400 px, sonst 640 px | Quelle für die Website-Freigabe |
|
||||||
|
| Website | `public/website/N/datei-{640,1280,1920}.jpg` | 640, 1280, 1920 | `srcset` von Hero, Bild mit Text, Karten; Hintergrund 1920 |
|
||||||
|
| Website voll | `public/website/N/datei.jpg` | bis 2400 px | Rückfall und `src` |
|
||||||
|
| Original | `originals/…`, `derived/inhalte/…` | unverändert | nur Hintergrundverarbeitung, nie ausgeliefert |
|
||||||
|
|
||||||
|
Die Fassungen heißen wie die Hauptdatei mit Suffix (`ImageVariants::path`). Es gibt keine Spalte. **Fehlt eine Fassung, gilt die nächstgrößere Datei.**
|
||||||
|
|
||||||
|
## Wer schreibt
|
||||||
|
|
||||||
|
Nur die Warteschlange (`queue`); der Web-Prozess liest:
|
||||||
|
|
||||||
|
- `ThumbnailDeriver::still()` und `frame()` (jede Ableitung eines Vorschaubildes) und `PresentationFile::place()` rufen `ImageVariants::generate`.
|
||||||
|
- `PublishWebsiteMedia` (Freigabe) ruft `ImageVariants::generatePublic`; Rücknahme und Ersatz löschen die Breiten.
|
||||||
|
- `DeriveImageVariants` und `DeriveWebsiteVariants` füllen Bestand nach. Sie werden vom Befehl `php artisan media:varianten` (`--now`, `--pretend`) oder von der Auslieferung angestoßen, wenn eine Breite fehlt (höchstens einmal je Stunde und Bild).
|
||||||
|
|
||||||
|
Eine Fassung entsteht nur, wenn die Quelle breiter ist; sonst wird eine ältere gelöscht. Fassungen sind JPEG (Qualität 80, progressiv), transparente Flächen werden weiß. Website-Breiten gibt es nur für JPEG-Quellen.
|
||||||
|
|
||||||
|
## Auslieferung
|
||||||
|
|
||||||
|
- **Verwaltung** `GET /redaktion/karte/{kind}/{subject}?g=klein|mittel&v=…` (nur angemeldete Redaktion) und **Mitgliederbereich** `member.thumbnail` mit denselben Parametern (Berechtigung unverändert).
|
||||||
|
- **Website** `GET /website-medien/{id}?w=640|1280|1920&v=…` (nur freigegebene Medien).
|
||||||
|
- `ThumbnailRef::url(route, kind, id, path, size, version)` und `EditorialCatalog::cardUrl` bauen die Adressen. Wer ein Bild neu anzeigt, wählt `klein` für alles unter etwa 180 px Anzeigebreite, sonst `mittel`, und übergibt `updated_at` als Version.
|
||||||
|
- Mit `v` in der Adresse: `Cache-Control: private|public, max-age=31536000, immutable`. Ohne `v` oder bei veralteter Website-Version: `max-age=0, must-revalidate` mit ETag und Last-Modified, `304` bei unverändertem Bild.
|
||||||
|
- Die Website-Route läuft ohne Sitzung und Cookies.
|
||||||
|
|
||||||
|
## Nachprüfen
|
||||||
|
|
||||||
|
Auf dem Server nur lesend: `ls derived/vorschau | grep -- -klein`, `ls public/website/*/`. Im Browser: Netzwerk-Reiter, `Cache-Control` und Größe der Bilder; zweiter Aufruf der Medienauswahl lädt die Bilder aus dem Browser-Cache.
|
||||||
|
|
||||||
|
## Nicht enthalten
|
||||||
|
|
||||||
|
EXIF-Drehung von Handyfotos (bisher nicht beachtet), WebP/AVIF (das Image baut GD ohne WebP), Fassungen für Film-Standbilder über 640 px.
|
||||||
@@ -275,7 +275,15 @@ ## 11. Abschnitte und Plätze
|
|||||||
- `anchor`: Sprungmarke (Kleinbuchstaben, Ziffern, einzelne Bindestriche, höchstens 60 Zeichen), je Seite eindeutig, ohne reservierte Kennungen (`inhalt`, `main`, `top`, `site-nav`, `fuss-themen`, `mb-account-menu`, Vorsilbe `bereich-`). Der Renderer gibt sie als `id` des Abschnitts aus; ohne Sprungmarke bleibt `bereich-<Kennung>`. Der Versatz zur festen Kopfzeile kommt aus `scroll-padding-top` (`resources/css/base.css`). Ein Link „#marke“ gilt auf derselben Seite, „/pfad#marke“ von anderen Seiten, „https://Adresse/pfad#marke“ von außen.
|
- `anchor`: Sprungmarke (Kleinbuchstaben, Ziffern, einzelne Bindestriche, höchstens 60 Zeichen), je Seite eindeutig, ohne reservierte Kennungen (`inhalt`, `main`, `top`, `site-nav`, `fuss-themen`, `mb-account-menu`, Vorsilbe `bereich-`). Der Renderer gibt sie als `id` des Abschnitts aus; ohne Sprungmarke bleibt `bereich-<Kennung>`. Der Versatz zur festen Kopfzeile kommt aus `scroll-padding-top` (`resources/css/base.css`). Ein Link „#marke“ gilt auf derselben Seite, „/pfad#marke“ von anderen Seiten, „https://Adresse/pfad#marke“ von außen.
|
||||||
- `hidden`: `true` blendet den Abschnitt auf der Website aus. Er zählt weder für die Hauptüberschrift (H1) noch für Trenner; Bilder und Medien bleiben erfasst, damit sie nicht als ungenutzt gelten. Die Seitenvorschau zeigt an seiner Stelle einen schmalen Hinweis. `pageTitle()` übergeht ausgeblendete Abschnitte.
|
- `hidden`: `true` blendet den Abschnitt auf der Website aus. Er zählt weder für die Hauptüberschrift (H1) noch für Trenner; Bilder und Medien bleiben erfasst, damit sie nicht als ungenutzt gelten. Die Seitenvorschau zeigt an seiner Stelle einen schmalen Hinweis. `pageTitle()` übergeht ausgeblendete Abschnitte.
|
||||||
- Fehler: `sections.N.name`, `sections.N.anchor` (Form, reserviert, doppelt). Ein kopierter Abschnitt gibt seine Sprungmarke ab (Namen erhalten „(Kopie)“), damit die Seite speicherbar bleibt.
|
- Fehler: `sections.N.name`, `sections.N.anchor` (Form, reserviert, doppelt). Ein kopierter Abschnitt gibt seine Sprungmarke ab (Namen erhalten „(Kopie)“), damit die Seite speicherbar bleibt.
|
||||||
- Im Seitenaufbau stehen die Felder am Abschnitt („Name, Sprungmarke und Sichtbarkeit“); die Kopfzeile des Abschnitts zeigt Name, `#marke` und „Ausgeblendet“.
|
- Im Seitenaufbau stehen die Felder nicht mehr als Eingabeblock im Abschnitt: Der Einstellungsbutton (Zahnrad) im Abschnittskopf öffnet einen Dialog „Abschnitt N: Einstellungen“ mit Name, Sprungmarke (samt „aus dem Namen vorschlagen“ und Linkhinweis) und „Auf der Website ausblenden“. „Übernehmen“ ändert nur den Seitenentwurf; Abbrechen, Schließen und Esc verwerfen. Die Kopfzeile des Abschnitts zeigt Name, `#marke` und „Ausgeblendet“ als Zusammenfassung. Der Dialog prüft die Sprungmarke mit denselben Regeln und Texten wie das Speichern (`PageSections::anchorProblem`), auch gegen noch ungespeicherte Marken der anderen Abschnitte. Lehnt das Speichern der Seite Name oder Sprungmarke ab, steht die Meldung am Abschnitt mit „Einstellungen öffnen“. Das gespeicherte Format ändert sich nicht.
|
||||||
|
|
||||||
|
**Abschnitt auf eine andere Seite kopieren oder verschieben.** Zwei Schalter im Abschnittskopf des Seiteneditors öffnen einen Dialog mit Zielseite (Auswahlfeld, ohne die geöffnete Seite) und Position (Am Anfang, Am Ende, Hinter Abschnitt N: Name oder erste Überschrift). Die Logik liegt in `App\Domain\Cms\SectionTransfer`, die Orchestrierung in `EditPage::transferSection`, die Schalter in `SectionTransferActions`. Es ändert sich kein gespeichertes Format.
|
||||||
|
- **Quelle ist der Arbeitsstand** der geöffneten Seite (auch Ungespeichertes), aufbereitet wie beim Speichern.
|
||||||
|
- **Kopieren:** Die Quellseite bleibt unberührt. Der Abschnitt erhält auf der Zielseite neue Kennungen (Abschnitt und Widgets); Name, Sprungmarke, Sichtbarkeit, Raster, Gestaltung und Widgets sind gleich. Ist die Sprungmarke auf der Zielseite vergeben, wird „-2“, „-3“ … angehängt und die Meldung nennt es.
|
||||||
|
- **Verschieben:** Die Kennungen bleiben. Nach dem Einfügen wird der Abschnitt aus dem Arbeitsstand entfernt und die Quellseite als Entwurf gespeichert (der Dialog sagt, dass dabei auch übrige offene Änderungen dieser Seite gespeichert werden).
|
||||||
|
- **Zielseite:** erhält eine neue Entwurfsrevision aus ihrem letzten Stand plus Abschnitt; SEO-Angaben bleiben. Nichts wird veröffentlicht.
|
||||||
|
- **Sicherung:** Vor dem ersten Schreiben wird geprüft, ob die Zielseite (höchstens 30 Abschnitte, 60 Widgets, Regeln der Bausteine) und beim Verschieben die Quellseite ohne den Abschnitt gültig bleiben. Scheitert eine Prüfung, wird nichts geschrieben. Gespeichert wird zuerst das Ziel, dann die Quelle; ein Ausfall dazwischen führt zu einem doppelten, nie zu einem verlorenen Abschnitt.
|
||||||
|
- Verweise innerhalb der Seite (`#marke`) in Widgets des übertragenen Abschnitts werden nicht umgeschrieben.
|
||||||
|
|
||||||
**Linkziele.** `SafeUrl` erlaubt Seitenpfade (auch mit `#marke`), `#marke` (nur diese Seite) und http(s)-Adressen. Alle Linkfelder der Widgets (Schaltflächen von Einstieg und Bild-Text, Handlungsaufforderung, Karten, Merkmale) sind `WidgetsSupportinkfield`: ein Textfeld mit Linksymbol, das den Dialog „Interne Seite wählen“ (`ChoosesLinkTargets`, `filament.cms.link-picker`) öffnet. Schritt 1 wählt die Seite (oder „Diese Seite“) mit Veröffentlichungszustand, Schritt 2 eine Sprungmarke; nicht veröffentlichte Marken und ausgeblendete Abschnitte sind gekennzeichnet. Die Marken der bearbeiteten Seite stammen aus dem Formular (auch ungespeicherte). Der Dialog schreibt nur die Adresse in das Feld. Im formatierten Text (Fließtext, Einleitung der Überschrift, Bild-Text) setzt das Werkzeug „Interne Seite oder Sprungmarke verlinken“ (`InternalLinkPlugin`) den Link am markierten Text. Menüeinträge: Spalte `navigation_items.anchor`, zweiter Schritt in „Ziel ändern“; der Link bleibt an die Zielseite gebunden.
|
**Linkziele.** `SafeUrl` erlaubt Seitenpfade (auch mit `#marke`), `#marke` (nur diese Seite) und http(s)-Adressen. Alle Linkfelder der Widgets (Schaltflächen von Einstieg und Bild-Text, Handlungsaufforderung, Karten, Merkmale) sind `WidgetsSupportinkfield`: ein Textfeld mit Linksymbol, das den Dialog „Interne Seite wählen“ (`ChoosesLinkTargets`, `filament.cms.link-picker`) öffnet. Schritt 1 wählt die Seite (oder „Diese Seite“) mit Veröffentlichungszustand, Schritt 2 eine Sprungmarke; nicht veröffentlichte Marken und ausgeblendete Abschnitte sind gekennzeichnet. Die Marken der bearbeiteten Seite stammen aus dem Formular (auch ungespeicherte). Der Dialog schreibt nur die Adresse in das Feld. Im formatierten Text (Fließtext, Einleitung der Überschrift, Bild-Text) setzt das Werkzeug „Interne Seite oder Sprungmarke verlinken“ (`InternalLinkPlugin`) den Link am markierten Text. Menüeinträge: Spalte `navigation_items.anchor`, zweiter Schritt in „Ziel ändern“; der Link bleibt an die Zielseite gebunden.
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ ### Formular bearbeiten
|
|||||||
### Widget „Anfrage“ im Seiteneditor
|
### Widget „Anfrage“ im Seiteneditor
|
||||||
|
|
||||||
- Reiter **Inhalt:** **Anfragegründe** (Bezeichnung, Kurzbeschreibung, Formular, optional Anliegen und Unteranliegen vorwählen), Frage der Auswahl, Beschriftung des Buttons. Die Kennung eines Grundes (für Links) entsteht beim Speichern.
|
- Reiter **Inhalt:** **Anfragegründe** (Bezeichnung, Kurzbeschreibung, Formular, optional Anliegen und Unteranliegen vorwählen), Frage der Auswahl, Beschriftung des Buttons. Die Kennung eines Grundes (für Links) entsteht beim Speichern.
|
||||||
- Reiter **Darstellung:** **Formularführung** (langes Formular oder mehrstufiger Dialog) und **Präsentation** (im Abschnitt oder als Dialog über der Seite) getrennt; Auswahl als Karten oder Auswahlfeld, Breite, Abstände, Feldanordnung, Buttondarstellung. Das responsive Verhalten ergibt sich aus der verfügbaren Breite.
|
- Reiter **Darstellung:** **Formularführung** (langes Formular oder mehrstufig, Schritt für Schritt) und **Präsentation** (im Abschnitt oder im Pop-up-Fenster über der Seite) getrennt; Auswahl als Karten oder Auswahlfeld, Breite, Abstände, Feldanordnung, Buttondarstellung. Das responsive Verhalten ergibt sich aus der verfügbaren Breite.
|
||||||
- **Vorauswahl durch einen Button der Seite:** Link auf die Seite mit `?grund=Kennung` (und gegebenenfalls `#Sprungmarke`). Das Widget wählt den Grund und öffnet bei „Dialog“ den Dialog.
|
- **Vorauswahl durch einen Button der Seite:** Link auf die Seite mit `?grund=Kennung` (und gegebenenfalls `#Sprungmarke`). Das Widget wählt den Grund und öffnet bei „Dialog“ den Dialog.
|
||||||
- Mehrere zulässige Gründe: Der Besucher sieht zuerst die Frage, danach nur das Formular seines Grundes („Anderen Grund wählen“ wechselt, Eingaben bleiben je Grund erhalten). Ein einziger Grund: kein Auswahlschritt.
|
- Mehrere zulässige Gründe: Der Besucher sieht zuerst die Frage, danach nur das Formular seines Grundes („Anderen Grund wählen“ wechselt, Eingaben bleiben je Grund erhalten). Ein einziger Grund: kein Auswahlschritt.
|
||||||
- Vorschau im Dialog des Widgets, in der Seitenvorschau und in der Geräteansicht.
|
- Vorschau im Dialog des Widgets, in der Seitenvorschau und in der Geräteansicht.
|
||||||
@@ -133,3 +133,30 @@ ### Widget „Anfrage“ im Seiteneditor
|
|||||||
### Öffentliche Adressen und Grenzen
|
### Öffentliche Adressen und Grenzen
|
||||||
|
|
||||||
`/anfrage/formular/{vorlage}` (Beschreibung und Token), `/zustand`, `/senden`; Grund in der Adresse (`anliegen`, `unteranliegen`, `modus`). Dieselbe Ratenbegrenzung wie bei Einstiegen. Neue Felder und Auswahlwerte stehen in Bedingungen erst nach dem ersten Speichern zur Verfügung. Nicht umgesetzt: Vorbelegung weiterer Felder (zum Beispiel Kursformat) je Anfragegrund; dafür bleibt der Anfrage-Einstieg.
|
`/anfrage/formular/{vorlage}` (Beschreibung und Token), `/zustand`, `/senden`; Grund in der Adresse (`anliegen`, `unteranliegen`, `modus`). Dieselbe Ratenbegrenzung wie bei Einstiegen. Neue Felder und Auswahlwerte stehen in Bedingungen erst nach dem ersten Speichern zur Verfügung. Nicht umgesetzt: Vorbelegung weiterer Felder (zum Beispiel Kursformat) je Anfragegrund; dafür bleibt der Anfrage-Einstieg.
|
||||||
|
|
||||||
|
## 13. Formularansicht des Aufbaus (ADR-62)
|
||||||
|
|
||||||
|
Der Aufbau eines Formulars ist eine eigene Ansicht statt einer Filament-Liste.
|
||||||
|
|
||||||
|
### Aufbau der Ansicht
|
||||||
|
|
||||||
|
- **Bereich** (im mehrstufigen Dialog ein Schritt): Karte mit Nummer, Titel und Symbolen für Einleitung, Bedingung, weitere Einstellungen und Entfernen. Darunter die Felder und Teilbereiche, am Ende „Neues Feld“, „Vorhandenes Feld einfügen“, „Teilbereich“ und (einmal im Formular) „Frage nach dem Anliegen“.
|
||||||
|
- **Teilbereich:** eingerahmte Einheit im Bereich mit Überschrift, Symbolen und eigener Feldliste („Neues Feld im Teilbereich“). Die Bedingung gilt für alle Felder darin.
|
||||||
|
- **Feld:** eine Zeile mit Griff, Frage, Art der Antwort und Pflicht. Symbole öffnen Pop-ups: Hilfetext, Auswahlwerte (nur bei Auswahlfeldern, mit Zähler), Bedingung, weitere Einstellungen. Die Art ist nach dem ersten Speichern gesperrt.
|
||||||
|
- **Bedingung:** Wirkung, „alle/mindestens eine“, Vergleiche auf Felder oberhalb des Elements und die Frage nach dem Anliegen; als Satz unter dem Element sichtbar. Verweist eine Bedingung nach einer Verschiebung auf ein Feld darunter, ist das Symbol gelb markiert.
|
||||||
|
- **Weitere Einstellungen:** Verwendung in der Anfrageübersicht, Hinweis auf gemeinsame Verwendung, „Verschieben nach …“.
|
||||||
|
- **Rückgängig** bis zum Speichern; Hinweiszeile mit Anzahl der Bereiche, Felder und Teilbereiche.
|
||||||
|
|
||||||
|
### Bedienung
|
||||||
|
|
||||||
|
- **Ziehen:** am Griff; Felder in jeden Bereich und Teilbereich, Teilbereiche zwischen Bereiche, Bereiche untereinander.
|
||||||
|
- **Tastatur:** Griff fokussieren, Pfeil hoch oder runter; am Rand eines Teilbereichs verlässt das Feld ihn. „Verschieben nach …“ setzt ein Element ans Ende eines Bereichs oder Teilbereichs.
|
||||||
|
- **Fehlende Angaben** (Titel, Frage, Auswahlwerte) sind rot umrandet; Speichern nennt die Gründe und ändert nichts.
|
||||||
|
|
||||||
|
### Technik
|
||||||
|
|
||||||
|
`TemplateEditor` liefert die Ansicht über ein `ViewField` (`editor_json`). Der Browser führt den Baum (Alpine, `form-editor-script.blade.php`) und schreibt ihn beim Speichern als Text. `FormEditor::validateTree` prüft, `fromTree` überführt ihn in die flache Ansicht, `persist` schreibt Katalog und Entwurf wie bisher; `toTree` ist die Gegenrichtung beim Öffnen. Nach dem Speichern liefert der Server den Baum mit festen Kennungen, die Ansicht übernimmt ihn (sonst legte ein zweites Speichern Felder doppelt an). Keine Migration.
|
||||||
|
|
||||||
|
### Grenzen
|
||||||
|
|
||||||
|
Ziehen auf Berührungsbildschirmen und Screenreader-Ansagen sind nicht geprüft. Neue Felder und Auswahlwerte stehen in Bedingungen erst nach dem ersten Speichern zur Verfügung. Die Regelliste „Weitere Regeln“ ist unverändert.
|
||||||
@@ -16,8 +16,11 @@ ## 1. Inhalt (Stand 21.11.2026 abends: 22 Commits seit `main`)
|
|||||||
| Reiter „Darstellung“ gegliedert | Aufbau, Gruppen je Widget, Erklärungen im (i), Einzelschalter für Texte verschwinden bei „Texte auf der Karte: Ausblenden“; Bezeichnungen vereinheitlicht. Keine Migration, gespeicherte Werte unverändert | Claude |
|
| Reiter „Darstellung“ gegliedert | Aufbau, Gruppen je Widget, Erklärungen im (i), Einzelschalter für Texte verschwinden bei „Texte auf der Karte: Ausblenden“; Bezeichnungen vereinheitlicht. Keine Migration, gespeicherte Werte unverändert | Claude |
|
||||||
| Abschnitte: Name, Sprungmarke, Ausblenden | Abschnitte lassen sich benennen (nur zur Orientierung), als Sprungmarke nutzen (Link „#marke“, „/pfad#marke“, von außen „Adresse#marke“) und für die Website ausblenden; Anzeige im Seitenaufbau. Keine Migration (neue optionale Felder in `sections`). **Rollback:** ältere Stände kennen „ausgeblendet“ nicht und zeigen solche Abschnitte wieder | Claude |
|
| Abschnitte: Name, Sprungmarke, Ausblenden | Abschnitte lassen sich benennen (nur zur Orientierung), als Sprungmarke nutzen (Link „#marke“, „/pfad#marke“, von außen „Adresse#marke“) und für die Website ausblenden; Anzeige im Seitenaufbau. Keine Migration (neue optionale Felder in `sections`). **Rollback:** ältere Stände kennen „ausgeblendet“ nicht und zeigen solche Abschnitte wieder | Claude |
|
||||||
| Interne Links wählen | Alle Linkfelder der Widgets und das Werkzeug im formatierten Text bieten einen Dialog für Seiten und Sprungmarken; Menüeinträge können auf eine Sprungmarke zeigen. Migration `2026_12_02_100000_add_anchor_to_navigation_items` (additiv) | Claude |
|
| Interne Links wählen | Alle Linkfelder der Widgets und das Werkzeug im formatierten Text bieten einen Dialog für Seiten und Sprungmarken; Menüeinträge können auf eine Sprungmarke zeigen. Migration `2026_12_02_100000_add_anchor_to_navigation_items` (additiv) | Claude |
|
||||||
|
| CMS-Seiteneditor: Abschnittseinstellungen im Dialog, kompakter Seitenaufbau (ADR-64) | Name, Sprungmarke und Sichtbarkeit eines Abschnitts stehen nicht mehr als Eingabeblock im Seitenaufbau, sondern im Dialog hinter dem Zahnrad im Abschnittskopf („Übernehmen“ ändert nur den Entwurf). Rahmen und Abstände um Abschnitte, Plätze und Bausteine verschlankt. Nur Darstellung und Bedienung: Seitenformat, Revisionen, Veröffentlichung und Website-Ausgabe unverändert, keine Migration. Rückfall: Der ältere Stand zeigt die Eingabefelder wieder im Abschnitt, gespeicherte Werte bleiben. | Claude |
|
||||||
|
| CMS-Seiteneditor: Abschnitt auf eine andere Seite kopieren oder verschieben (ADR-65) | Zwei Schalter im Abschnittskopf öffnen einen Dialog mit Zielseite und Position. Die Zielseite erhält einen neuen Entwurf (nichts wird veröffentlicht); beim Verschieben wird die Quellseite als Entwurf gespeichert. Kein neues Seitenformat, keine Migration. Rückfall: Die Schalter entfallen, übertragene Abschnitte bleiben als normale Abschnitte erhalten. | Claude |
|
||||||
| Kommunikationsverwaltung und Widget „Anfrage“ | Neue Gruppe „Kommunikation“ (Anfragen, Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen, Anfrage-Einstiege, Einstellungen), öffentliche Schnittstelle `/anfrage/{einstieg}` und CMS-Widget `inquiry` (ADR-60). **Vor dem Merge:** Mailversand in `/etc/luf/prod.env` prüfen (`MAIL_*`), Empfänger und Datenschutzhinweis festlegen, Testnachricht in den Einstellungen senden; Beispielkonfiguration auf Prod nur auf ausdrücklichen Wunsch anlegen. Rückfall: ältere Stände kennen das Widget nicht und zeigen es nicht | Claude |
|
| Kommunikationsverwaltung und Widget „Anfrage“ | Neue Gruppe „Kommunikation“ (Anfragen, Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen, Anfrage-Einstiege, Einstellungen), öffentliche Schnittstelle `/anfrage/{einstieg}` und CMS-Widget `inquiry` (ADR-60). **Vor dem Merge:** Mailversand in `/etc/luf/prod.env` prüfen (`MAIL_*`), Empfänger und Datenschutzhinweis festlegen, Testnachricht in den Einstellungen senden; Beispielkonfiguration auf Prod nur auf ausdrücklichen Wunsch anlegen. Rückfall: ältere Stände kennen das Widget nicht und zeigen es nicht | Claude |
|
||||||
| Kommunikation: Formular-Editor und Anfragegründe (ADR-61) | Navigation Anfragen, Formulare & Befragungen, Einstellungen; ein Editor für Bereiche, Felder und Bedingungen; Widget „Anfrage“ mit Anfragegründen statt Einstieg, Formularführung und Präsentation (Dialog) getrennt, Auslieferung `/anfrage/formular/{vorlage}`. Keine Migration. Rückfall: ein Stand ohne ADR-61 zeigt ein Widget mit Anfragegründen nicht an (Seite bleibt gültig), Formulare und Anfragen bleiben unverändert. Zwei Widget-Tests bewusst geändert. | Claude |
|
| Kommunikation: Formular-Editor und Anfragegründe (ADR-61) | Navigation Anfragen, Formulare & Befragungen, Einstellungen; ein Editor für Bereiche, Felder und Bedingungen; Widget „Anfrage“ mit Anfragegründen statt Einstieg, Formularführung und Präsentation (Dialog) getrennt, Auslieferung `/anfrage/formular/{vorlage}`. Keine Migration. Rückfall: ein Stand ohne ADR-61 zeigt ein Widget mit Anfragegründen nicht an (Seite bleibt gültig), Formulare und Anfragen bleiben unverändert. Zwei Widget-Tests bewusst geändert. | Claude |
|
||||||
|
| Kommunikation: Formularansicht des Aufbaus (ADR-62) | Der Aufbau eines Formulars ist eine eigene Ansicht mit Ziehen und Ablegen, Pop-ups für Hilfetext, Auswahlwerte und Bedingung (statt Builder-Liste). Keine Migration, Daten unverändert. Rückfall auf ADR-61 liest denselben Entwurf. Livewire-Tests des Editors bewusst auf den Baumtext umgestellt. | Claude |
|
||||||
| Hero mit Video | Der Einstieg (Variante Foto mit Textfläche) spielt auf Wunsch ein freigegebenes Video stumm auf der Fläche des Fotos ab, mit Schaltfläche zum Anhalten; Foto als Rückfall (ADR-43 Nachtrag). Keine Migration | Claude |
|
| Hero mit Video | Der Einstieg (Variante Foto mit Textfläche) spielt auf Wunsch ein freigegebenes Video stumm auf der Fläche des Fotos ab, mit Schaltfläche zum Anhalten; Foto als Rückfall (ADR-43 Nachtrag). Keine Migration | Claude |
|
||||||
| Website-Datei eines Films | Ablage der Datei eines eigenständigen Präsentationsmediums über die Warteschlange, nachträgliches Hochladen am Medium (Behebung: der Web-Prozess darf `derived/` nicht schreiben) | Lars (anderer Rechner) |
|
| Website-Datei eines Films | Ablage der Datei eines eigenständigen Präsentationsmediums über die Warteschlange, nachträgliches Hochladen am Medium (Behebung: der Web-Prozess darf `derived/` nicht schreiben) | Lars (anderer Rechner) |
|
||||||
| Medienmanager | „Medium löschen“ erreicht Standbilder und übernommene CMS-Bilder (Fremdschlüssel gelockert) | Claude |
|
| Medienmanager | „Medium löschen“ erreicht Standbilder und übernommene CMS-Bilder (Fremdschlüssel gelockert) | Claude |
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Abnahme: Abschnitt auf eine andere Seite kopieren oder verschieben
|
||||||
|
|
||||||
|
Stand: 28.11.2026. Entscheidung: ADR-65, Beschreibung: `docs/architektur/cms-widget-registry.md` (Abschnitt „Abschnitt auf eine andere Seite kopieren oder verschieben“). Screenshots: `abnahme/cms-abschnitt-uebertragen/`. Prüfung durch Claude im Browser (Playwright, Chromium); die praktische Abnahme durch den Betreiber steht aus.
|
||||||
|
|
||||||
|
## Was geändert ist
|
||||||
|
|
||||||
|
- Im Kopf jedes Abschnitts stehen zwei neue Schalter neben dem Zahnrad: „Auf andere Seite kopieren“ und „Auf andere Seite verschieben“ (Tooltip und Screenreader-Name tragen den Text). `kopf-und-meldung-breit`, `kopf-und-meldung-schmal`.
|
||||||
|
- Beide öffnen einen Dialog mit **Zielseite** (Auswahlfeld, durchsuchbar, ohne die geöffnete Seite, mit Titel) und **Position auf der Zielseite**: Am Anfang, Am Ende (Vorgabe) oder „Hinter Abschnitt N: Name oder erste Überschrift“. Die Position wird erst frei, wenn eine Zielseite gewählt ist; hat die Zielseite keine Abschnitte, gibt es nur „Als ersten Abschnitt einfügen“. `dialog-zielseite`, `dialog-position`, `dialog-verschieben`, `dialog-schmal`.
|
||||||
|
- **Kopieren:** Der Abschnitt bleibt hier; auf der Zielseite entsteht ein neuer Abschnitt mit gleichem Inhalt und gleichen Einstellungen (Name, Sprungmarke, „Ausgeblendet“, Raster, Gestaltung, Widgets). Ist die Sprungmarke dort vergeben, wird „-2“ angehängt und die Meldung sagt es.
|
||||||
|
- **Verschieben:** Wie Kopieren, danach verschwindet der Abschnitt von dieser Seite, und diese Seite wird als Entwurf gespeichert (auch übrige offene Änderungen; der Dialog weist darauf hin).
|
||||||
|
- Die Zielseite erhält einen neuen Entwurf, **nichts wird veröffentlicht**. Die Meldung nennt Position und Seite und bietet „Zielseite öffnen“.
|
||||||
|
- Ist die Zielseite voll (30 Abschnitte, 60 Widgets) oder würde sie ungültig, wird nichts geschrieben und die Meldung nennt den Grund.
|
||||||
|
|
||||||
|
## Geprüft
|
||||||
|
|
||||||
|
Automatisierte Tests (`CmsSectionTransferTest`, 9): Kopie lässt die Quelle unberührt und hängt einen gleichen Abschnitt mit neuen Kennungen an; Positionen Anfang, nach 1, nach 2, Ende; Verschieben entfernt den Abschnitt aus der gespeicherten Quelle und behält die Kennung; der ungespeicherte Arbeitsstand wird kopiert; vergebene Sprungmarke wird „-2“; volle Zielseite schreibt nichts, auch nicht beim Verschieben; Auswahl nennt Abschnitte nach Name oder Überschrift; die geöffnete Seite ist kein Ziel; beide Schalter in jedem Abschnittskopf.
|
||||||
|
|
||||||
|
Browser-Prüfung lokal (16 von 16): Schalter je Abschnitt; Enter am Schalter öffnet den Dialog, Fokus im Dialog; Zielseite wählen, Position frei, „Hinter Abschnitt 1“ wählen; Kopieren mit Meldung, Quelle unverändert, Fokus zurück am Schalter; Verschieben mit Meldung, Quelle hat einen Abschnitt weniger und ist gespeichert; Esc schließt; 390 px ohne waagerechtes Scrollen, Dialog passt ins Fenster; keine Skriptfehler.
|
||||||
|
|
||||||
|
## Abweichungen und offen
|
||||||
|
|
||||||
|
- **luf-test:** Die Prüfung auf der Testinstanz folgt nach dem Deploy.
|
||||||
|
- **Nicht geprüft:** Screenreader-Ansagen; Tastatur nur für Schalter, Dialog und Esc.
|
||||||
|
- **Symbole:** Kopieren (Dokument mit Plus) und Verschieben (Pfeil im Kreis) sind reine Symbole mit Tooltip; beschriftete Schalter wären breiter und verdrängen im schmalen Kopf Name und Aktionen.
|
||||||
|
- **Verweise:** `#marke`-Links innerhalb der Seite in übertragenen Widgets werden nicht umgeschrieben.
|
||||||
|
- **Zwei Bearbeiter:** Die Zielseite wird aus ihrem letzten gespeicherten Stand fortgeschrieben; hat jemand sie gleichzeitig geöffnet, sieht diese Person den neuen Abschnitt erst nach dem Neuladen und überschreibt ihn beim Speichern mit ihrem Stand (wie bei jeder Revision heute).
|
||||||
|
After Width: | Height: | Size: 156 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 151 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 182 KiB |
|
After Width: | Height: | Size: 54 KiB |
@@ -0,0 +1,36 @@
|
|||||||
|
# Abnahme: Übersicht des CMS-Seiteneditors (Abschnittseinstellungen im Dialog, kompakter Seitenaufbau)
|
||||||
|
|
||||||
|
Stand: 28.11.2026, Testinstanz `luf-test` auf `develop` @ `7e7019b`. Prüfung durch Claude im Browser (Playwright, Chromium) über die echte Oberfläche; die praktische Abnahme durch den Betreiber steht aus. Entscheidung: ADR-64, Beschreibung: `docs/architektur/cms-widget-registry.md` (Abschnitt „Name, Sprungmarke und Ausblenden“). Screenshots: `abnahme/cms-seitenaufbau/`.
|
||||||
|
|
||||||
|
## Ergebnis auf einen Blick
|
||||||
|
|
||||||
|
Messseite: „Abschnitte, Raster und Flächen“ (`/referenz-abschnitte`, 5 Abschnitte mit den Rastern 4, 2+2, 1+3, 1+1+1+1 und 3+1), unveränderter Inhalt, vorher und nachher auf luf-test.
|
||||||
|
|
||||||
|
| Messwert | Vorher | Nachher |
|
||||||
|
|---|---|---|
|
||||||
|
| Höhe der Seite bei 1440 px Breite | 1987 px | 1531 px (−23 %) |
|
||||||
|
| Höhe der Seite bei 390 px Breite | 3319 px | 2467 px (−26 %) |
|
||||||
|
| Eingabeblock „Name, Sprungmarke und Sichtbarkeit“ | in jedem Abschnitt (5 Mal) | entfällt |
|
||||||
|
|
||||||
|
Belege: `vorher-breit-ganz` und `nachher-breit-ganz` (ganze Seite), `vorher-breit-oben` und `nachher-breit-oben` (erster Bildschirm), `vorher-schmal-oben` und `nachher-schmal-oben` (390 px).
|
||||||
|
|
||||||
|
## Was geändert ist
|
||||||
|
|
||||||
|
- **Abschnittseinstellungen im Dialog:** Das Zahnrad im Abschnittskopf öffnet „Abschnitt N: Einstellungen“ mit Name, Sprungmarke (samt „aus dem Namen vorschlagen“ und Linkhinweis) und „Auf der Website ausblenden“. Im Kopf bleiben Name, `#marke` und „Ausgeblendet“ als Zusammenfassung. `dialog-einstellungen`, `dialog-schmal`.
|
||||||
|
- **Speicherverhalten:** „Übernehmen“ ändert nur den Seitenarbeitsstand (keine Revision, Anzeige „nicht gespeichert“); Abbrechen, Schließen und Esc verwerfen; dauerhaft speichert „Entwurf speichern“. Andere offene Eingaben bleiben erhalten.
|
||||||
|
- **Fehler:** Die Sprungmarke wird im Dialog mit denselben Regeln und Texten wie beim Speichern geprüft (`dialog-fehler`). Lehnt das Speichern der Seite Name oder Sprungmarke ab, steht die Meldung am betroffenen Abschnitt mit „Einstellungen öffnen“, und die Seite scrollt dorthin (`abschnitt-fehler`).
|
||||||
|
- **Kompakter Aufbau (nur Stile):** kleinere Abstände in Abschnitt und Platzraster, ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens (leere Plätze bleiben umrandet), Rahmen um Baustein und Vorschau entfallen. Abschnittskante, Raster mit bis zu vier Einheiten und die Aktionen Konfigurieren, Duplizieren, Verschieben, Entfernen, Einklappen sind unverändert (`konfigurator`).
|
||||||
|
- **Schmale Fenster:** Name und Sprungmarke des Abschnitts stehen in der ersten Kopfzeile, die Aktionen darunter. Vorher war der Name bei 390 px nicht zu sehen.
|
||||||
|
|
||||||
|
## Geprüft auf luf-test (31 von 31 Prüfungen, Testseite `/anfrage-widget-abnahme`)
|
||||||
|
|
||||||
|
Enter am Einstellungsbutton öffnet den Dialog, Fokus im Dialog; Esc schließt, Fokus kehrt zum Button zurück (ebenso nach „Übernehmen“ und „Abbrechen“); ändern, übernehmen, erneut öffnen; Abbrechen und Esc verwerfen; ein offener SEO-Titel bleibt nach dem Dialog erhalten und wird mit gespeichert; doppelte Sprungmarke zeigt die Meldung im Dialog, korrigieren und ausblenden; Abschnitt nach unten und nach oben; Baustein-Konfigurator öffnet wie gewohnt; Entwurf speichern, neu laden, Werte im Kopf und im Dialog kontrolliert; Speicherfehler (doppelte Marke) erscheint am Abschnitt, „Einstellungen öffnen“ führt zum Dialog, nach der Korrektur lässt sich speichern; 390 px ohne waagerechtes Scrollen, Dialog passt ins Fenster; keine Skriptfehler.
|
||||||
|
|
||||||
|
Tests (Gitea-Gate, grün): neue Tests `CmsSectionSettingsTest` (Dialog zeigt und übernimmt die Werte, nur drei Angaben ändern sich, keine Revision beim Übernehmen, Abbrechen ändert nichts, ungültige, reservierte und doppelte Sprungmarke, Meldung am Abschnitt, andere Eingaben bleiben, ein Wortlaut für Dialog und Speichern); die bisherigen Tests zu Name, Sprungmarke, Linkauswahl und Seiteneditor laufen unverändert.
|
||||||
|
|
||||||
|
## Abweichungen und offen
|
||||||
|
|
||||||
|
- **Nicht geprüft:** Screenreader-Ansagen; Tastatur nur für Zahnrad, Dialog, Esc und Fokusrückgabe, nicht für jede Strukturaktion; Seite ohne Abschnitte.
|
||||||
|
- **Dialog bei geöffnetem Baustein-Konfigurator:** nicht vorgesehen; der Konfigurator bleibt ein eigener Dialog (Esc verwirft dort bewusst nichts).
|
||||||
|
- **Die Messwerte** gelten für diese Referenzseite; Seiten mit wenigen, hohen Bausteinen sparen weniger, weil der Gewinn aus dem Wegfall des Eingabeblocks, der Rahmen und der Abstände kommt.
|
||||||
|
- **Testseite:** Die Prüfung hat auf `/anfrage-widget-abnahme` Entwurfsstände mit Namen und Sprungmarken gespeichert (nicht veröffentlicht); zum Zurücksetzen durch den Betreiber.
|
||||||
|
After Width: | Height: | Size: 161 KiB |
|
After Width: | Height: | Size: 137 KiB |
|
After Width: | Height: | Size: 138 KiB |
|
After Width: | Height: | Size: 70 KiB |
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 257 KiB |
|
After Width: | Height: | Size: 173 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 299 KiB |
|
After Width: | Height: | Size: 151 KiB |
|
After Width: | Height: | Size: 47 KiB |
@@ -0,0 +1,27 @@
|
|||||||
|
# Abnahme: Formularansicht des Aufbaus (ADR-62)
|
||||||
|
|
||||||
|
Stand: 28.11.2026, Testinstanz `luf-test` auf `develop` @ `41bf9a0`. Prüfung durch Claude im Browser (Playwright, Chromium) über die echte Oberfläche; die praktische Abnahme durch den Betreiber steht aus. Entscheidung: ADR-62, Beschreibung: `docs/architektur/kommunikationsverwaltung.md` Abschnitt 13. Screenshots: `abnahme/formular-ansicht/`.
|
||||||
|
|
||||||
|
## Anforderungen aus der Rückmeldung vom 28.11.2026
|
||||||
|
|
||||||
|
| Anforderung | Umsetzung | Beleg |
|
||||||
|
|---|---|---|
|
||||||
|
| Keine Endloslisten, Formular-Darstellung: links die Frage, daneben der Feldtyp | Feld = eine Zeile: Griff, Frage, Art der Antwort, Pflicht, Symbole | `aufbau-neu` |
|
||||||
|
| Hilfetext, Bedingungen über Symbole, als Pop-up | Symbole je Feld, Teilbereich und Bereich öffnen ein Pop-up (Hilfetext, Auswahlwerte, Bedingung, weitere Einstellungen); gesetzte Angaben sind am Symbol markiert, die Bedingung steht als Satz unter dem Element | `dialog-hilfetext`, `dialog-auswahlwerte`, `dialog-bedingung` |
|
||||||
|
| Bereiche und Teilbereiche deutlich abgegrenzt, eine visuelle Einheit | Bereich = Karte mit grünem Rand und Nummer; Teilbereich = blau eingerahmte Einheit mit eigener Feldliste, „Neues Feld im Teilbereich“ | `aufbau-neu`, `nach-ziehen` |
|
||||||
|
| Felder und Teilbereiche per Ziehen an beliebige Positionen | SortableJS: Feld in jeden Bereich und Teilbereich, Teilbereich zwischen Bereiche, Bereiche untereinander | `nach-ziehen` |
|
||||||
|
|
||||||
|
## Geprüft auf luf-test (26 von 26 Prüfungen)
|
||||||
|
|
||||||
|
Formular über die Liste anlegen; Bereich, Felder, Auswahlfeld (Pop-up öffnet sofort, drei Werte), Hilfetext, Teilbereich mit zwei Feldern; Feld in den Teilbereich ziehen und zurück, Teilbereich in einen anderen Bereich, Bereich nach oben; zweimal „Rückgängig“; Tastatur (Pfeil runter am Griff, Fokus bleibt); Speichern zweimal ohne Doppelungen (feste Kennungen, gleicher Aufbau nach Neuladen); Bedingung am Teilbereich („nur anzeigen, wenn Welches Format … ist Schul-AG“); „Verschieben nach …“; fehlende Frage: rote Meldung mit Grund, nichts gespeichert; 1440, 768 und 390 px ohne waagerechtes Scrollen; Pop-up passt auf 390 px; Esc schließt das Pop-up; keine Skriptfehler.
|
||||||
|
|
||||||
|
Lokal zusätzlich: kein Warnhinweis beim Verlassen ohne Änderung, Warnung nach einer Änderung, Register „Weitere Regeln“ und „Konfiguration prüfen“ aus der neuen Ansicht. Tests (Gitea-Gate, grün): Baumumwandlung ohne Verlust über alle Beispielformulare, Teilbereich mit Feldern und Einzelfeld danach, Prüfung fehlender Angaben, Anlegen im Editor mit zweimaligem Speichern, Ablehnung eines unvollständigen Formulars.
|
||||||
|
|
||||||
|
## Nicht geprüft oder offen
|
||||||
|
|
||||||
|
- **Berührungsbildschirme:** Ziehen mit dem Finger und Screenreader-Ansagen nicht geprüft; ohne Maus gehen Pfeiltasten am Griff und „Verschieben nach …“.
|
||||||
|
- **Tastatur in der Verwaltung** nur für Griff, Pop-ups und Esc geprüft, nicht für jede Kombination.
|
||||||
|
- **Neue Felder und Auswahlwerte** stehen in Bedingungen erst nach dem ersten Speichern zur Verfügung (Hinweis im Pop-up).
|
||||||
|
- **Veröffentlichen** aus der neuen Ansicht ist durch Tests belegt, auf luf-test nicht durchgespielt.
|
||||||
|
- **Testinhalte auf luf-test:** mehrere Formulare „Editor Formular …“ und „Pruef Formular …“ (unveröffentlicht); zum Löschen oder Archivieren durch den Betreiber.
|
||||||
|
- Der Screenshot-Ausschnitt zeigt in Vollseitenaufnahmen die mitlaufende Kopfleiste mitten im Bild; das ist ein Aufnahmeartefakt, kein Fehler der Seite.
|
||||||
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 208 KiB |
|
After Width: | Height: | Size: 160 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 155 KiB |
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 263 KiB |
|
After Width: | Height: | Size: 228 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 153 KiB |
@@ -17,7 +17,7 @@
|
|||||||
<{{ $as }} {{ $attributes->class('vw-eintrag') }}>
|
<{{ $as }} {{ $attributes->class('vw-eintrag') }}>
|
||||||
<span class="vw-bild">
|
<span class="vw-bild">
|
||||||
@if (filled($bild))
|
@if (filled($bild))
|
||||||
<img src="{{ $bild }}" alt="{{ $bildAlt }}" loading="lazy">
|
<img src="{{ $bild }}" alt="{{ $bildAlt }}" loading="lazy" decoding="async">
|
||||||
@else
|
@else
|
||||||
<span class="vw-bild-ersatz" data-symbol="{{ $symbol }}">@include('filament.verwaltung.icon', ['name' => $symbol])@if (filled($bildFehlt))<span class="vw-sr">{{ $bildFehlt }}</span>@endif</span>
|
<span class="vw-bild-ersatz" data-symbol="{{ $symbol }}">@include('filament.verwaltung.icon', ['name' => $symbol])@if (filled($bildFehlt))<span class="vw-sr">{{ $bildFehlt }}</span>@endif</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
@php
|
@php
|
||||||
$metadata = is_array($version->metadata) ? $version->metadata : [];
|
$metadata = is_array($version->metadata) ? $version->metadata : [];
|
||||||
$class = $version->element->output_class;
|
$class = $version->element->output_class;
|
||||||
$poster = \App\Domain\Media\ThumbnailRef::url('editorial.card', 'element', $version->element->id, $version->element->thumbnail_path);
|
$poster = \App\Domain\Media\ThumbnailRef::url('editorial.card', 'element', $version->element->id, $version->element->thumbnail_path, 'mittel', $version->element->updated_at);
|
||||||
$playback = $class === 'film' ? app(\App\Http\Controllers\ContentPreviewController::class)->playback($version) : null;
|
$playback = $class === 'film' ? app(\App\Http\Controllers\ContentPreviewController::class)->playback($version) : null;
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
{{--
|
||||||
|
Meldung am Abschnitt, wenn das Speichern der Seite Name oder Sprungmarke des Abschnitts abgewiesen hat. Die Eingabefelder
|
||||||
|
stehen im Einstellungsdialog; hier steht der Grund mit einem Weg dorthin.
|
||||||
|
--}}
|
||||||
|
@php
|
||||||
|
$abschnitt = $getStatePath();
|
||||||
|
$meldungen = array_values(array_unique([...$errors->get($abschnitt.'.name'), ...$errors->get($abschnitt.'.anchor')]));
|
||||||
|
@endphp
|
||||||
|
@if ($meldungen !== [])
|
||||||
|
<div class="luf-abschnitt-fehler" role="alert" data-abschnitt-fehler>
|
||||||
|
<span>
|
||||||
|
<strong>Name oder Sprungmarke dieses Abschnitts prüfen:</strong>
|
||||||
|
{{ implode(' ', $meldungen) }}
|
||||||
|
</span>
|
||||||
|
<button type="button" class="luf-abschnitt-fehler-aktion"
|
||||||
|
x-on:click="$el.closest('.fi-fo-repeater-item')?.querySelector('[data-luf-einstellungen]')?.click()">
|
||||||
|
Einstellungen öffnen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
@@ -27,12 +27,17 @@
|
|||||||
|
|
||||||
/* Seitenaufbau (CMS-Abschluss): Abschnitt als Hauptgruppe, Plätze über Lage und Breite, Bausteine mit kurzem
|
/* Seitenaufbau (CMS-Abschluss): Abschnitt als Hauptgruppe, Plätze über Lage und Breite, Bausteine mit kurzem
|
||||||
Namen und Miniaturvorschau. Mehrere Abschnitte bleiben auf einem Desktopbildschirm überblickbar. */
|
Namen und Miniaturvorschau. Mehrere Abschnitte bleiben auf einem Desktopbildschirm überblickbar. */
|
||||||
.luf-sections > .fi-fo-repeater-items { gap: .75rem; }
|
.luf-sections > .fi-fo-repeater-items { gap: .5rem; }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item { border-left: 4px solid rgb(3 37 81 / 70%); }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item { border-left: 4px solid rgb(3 37 81 / 70%); }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header { padding: .25rem .75rem; min-height: 0; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header { padding: .1rem .6rem; min-height: 0; }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content { padding: .4rem .6rem .6rem; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content { padding: .25rem .5rem .5rem; }
|
||||||
.luf-sections .fi-fo-repeater-item-header-label { font-weight: 600; white-space: normal; }
|
.luf-sections .fi-fo-repeater-item-header-label { font-weight: 600; white-space: normal; }
|
||||||
.luf-abschnitt { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .65rem; }
|
.luf-abschnitt { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .65rem; }
|
||||||
|
/* Schmale Fenster: Name und Zusammenfassung des Abschnitts stehen in der ersten Zeile, die Aktionen darunter. */
|
||||||
|
@media (max-width: 40rem) {
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header { flex-wrap: wrap; row-gap: .1rem; }
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-header > .fi-fo-repeater-item-header-label { order: -1; flex: 1 1 100%; }
|
||||||
|
}
|
||||||
.luf-abschnitt-nr { font-weight: 700; }
|
.luf-abschnitt-nr { font-weight: 700; }
|
||||||
.luf-abschnitt-meta { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
.luf-abschnitt-meta { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
||||||
.luf-abschnitt-nummer { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
.luf-abschnitt-nummer { font-size: .8rem; font-weight: 500; color: #3e4c5c; }
|
||||||
@@ -41,7 +46,14 @@
|
|||||||
/* Ausgeblendeter Abschnitt: gestrichelte Kante und zurückgenommener Inhalt, der Kopf bleibt gut lesbar. */
|
/* Ausgeblendeter Abschnitt: gestrichelte Kante und zurückgenommener Inhalt, der Kopf bleibt gut lesbar. */
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) { border-left-style: dashed; border-left-color: #c98a00; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) { border-left-style: dashed; border-left-color: #c98a00; }
|
||||||
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) > .fi-fo-repeater-item-content { opacity: .72; }
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item:has(.luf-abschnitt.is-ausgeblendet) > .fi-fo-repeater-item-content { opacity: .72; }
|
||||||
.luf-abschnitt-bezeichnung { margin-bottom: .5rem; }
|
/* Meldung am Abschnitt, wenn Name oder Sprungmarke beim Speichern abgewiesen wurden (Eingabe im Einstellungsdialog). */
|
||||||
|
.luf-abschnitt-fehler { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem .75rem; margin-bottom: .35rem; padding: .35rem .6rem; border: 1px solid var(--vw-error); border-radius: var(--vw-radius-small); background: var(--vw-error-soft); color: var(--vw-error); font-size: var(--vw-small); }
|
||||||
|
.luf-abschnitt-fehler-aktion { padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
|
||||||
|
.luf-sections .fi-fo-repeater-item-header [data-luf-einstellungen] { flex: none; }
|
||||||
|
/* Verdeckte Felder und leere Meldungen belegen keine Zeile im Abschnitt (sonst addiert sich der Zeilenabstand). */
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content > .fi-sc { gap: .4rem; }
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content > .fi-sc > .fi-sc-component:has(> input[type='hidden']),
|
||||||
|
.luf-sections > .fi-fo-repeater-items > .fi-fo-repeater-item > .fi-fo-repeater-item-content > .fi-sc > .fi-sc-component:not(:has(*)) { display: none; }
|
||||||
.luf-link-pfad { font-family: ui-monospace, monospace; font-size: .85em; overflow-wrap: anywhere; }
|
.luf-link-pfad { font-family: ui-monospace, monospace; font-size: .85em; overflow-wrap: anywhere; }
|
||||||
|
|
||||||
/* Rasterauswahl als grafische Kacheln */
|
/* Rasterauswahl als grafische Kacheln */
|
||||||
@@ -55,19 +67,21 @@
|
|||||||
|
|
||||||
/* Plätze im Verhältnis des Desktop-Rasters; auf schmalen Bildschirmen untereinander. Ein Platz hat keinen eigenen
|
/* Plätze im Verhältnis des Desktop-Rasters; auf schmalen Bildschirmen untereinander. Ein Platz hat keinen eigenen
|
||||||
Kopf: links der Griff zum Verschieben des Bausteins, daneben der Baustein. */
|
Kopf: links der Griff zum Verschieben des Bausteins, daneben der Baustein. */
|
||||||
.luf-slots > .fi-fo-repeater-items { display: grid; gap: .5rem; grid-template-columns: minmax(0, 1fr); }
|
.luf-slots > .fi-fo-repeater-items { display: grid; gap: .35rem; grid-template-columns: minmax(0, 1fr); }
|
||||||
@media (min-width: 64rem) {
|
@media (min-width: 64rem) {
|
||||||
.luf-slots > .fi-fo-repeater-items { grid-template-columns: var(--luf-slot-cols, minmax(0, 1fr)); }
|
.luf-slots > .fi-fo-repeater-items { grid-template-columns: var(--luf-slot-cols, minmax(0, 1fr)); }
|
||||||
}
|
}
|
||||||
.luf-slots .fi-fo-repeater-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; background: transparent; border: 1px dashed rgb(3 37 81 / 18%); box-shadow: none; }
|
/* Ein Platz ist eine leise Fläche statt eines gestrichelten Rahmens; nur ein leerer Platz bleibt gestrichelt. */
|
||||||
.luf-slots .fi-fo-repeater-item-header { padding: .3rem 0 .3rem .15rem; border: 0; background: transparent; min-height: 0; }
|
.luf-slots .fi-fo-repeater-item { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; background: var(--vw-paper); border: 0; border-radius: var(--vw-radius-small); box-shadow: none; }
|
||||||
|
.luf-slots .fi-fo-repeater-item:not(:has(.fi-fo-builder-item)) { background: transparent; box-shadow: inset 0 0 0 1px var(--vw-line-strong); }
|
||||||
|
.luf-slots .fi-fo-repeater-item-header { padding: .2rem 0 .2rem .1rem; border: 0; background: transparent; min-height: 0; }
|
||||||
.luf-slots .fi-fo-repeater-item:has(.luf-platz-warnung) { grid-template-columns: minmax(0, 1fr); }
|
.luf-slots .fi-fo-repeater-item:has(.luf-platz-warnung) { grid-template-columns: minmax(0, 1fr); }
|
||||||
.luf-platz-warnung { display: block; padding: .25rem .5rem; border-radius: .35rem; background: #fff6dc; color: #9a5b00; font-size: .8rem; font-weight: 600; }
|
.luf-platz-warnung { display: block; padding: .25rem .5rem; border-radius: .35rem; background: #fff6dc; color: #9a5b00; font-size: .8rem; font-weight: 600; }
|
||||||
.luf-slots .fi-fo-repeater-item-content { padding: .3rem .4rem .4rem .25rem; min-width: 0; }
|
.luf-slots .fi-fo-repeater-item-content { padding: .2rem .35rem .3rem .15rem; border: 0; min-width: 0; }
|
||||||
.luf-slots .fi-fo-builder-item { border: 0; box-shadow: none; background: transparent; }
|
.luf-slots .fi-fo-builder-item { border: 0; box-shadow: none; background: transparent; }
|
||||||
.luf-slots .fi-fo-builder-item-header { padding: 0 0 .25rem; gap: .25rem .35rem; flex-wrap: wrap; min-height: 0; }
|
.luf-slots .fi-fo-builder-item-header { padding: 0 0 .15rem; gap: .15rem .35rem; flex-wrap: wrap; min-height: 0; }
|
||||||
.luf-slots .fi-fo-builder-item-header .fi-btn { min-height: 1.9rem; padding-block: .15rem; }
|
.luf-slots .fi-fo-builder-item-header .fi-btn { min-height: 1.9rem; padding-block: .15rem; }
|
||||||
.luf-slots .fi-fo-builder-item-content { padding: 0; }
|
.luf-slots .fi-fo-builder-item-content { padding: 0; border: 0; }
|
||||||
.luf-slots .fi-fo-builder-add-action-ctn,
|
.luf-slots .fi-fo-builder-add-action-ctn,
|
||||||
.luf-slots .fi-fo-builder .fi-fo-builder-add-btn-ctn { justify-content: center; }
|
.luf-slots .fi-fo-builder .fi-fo-builder-add-btn-ctn { justify-content: center; }
|
||||||
.luf-baustein { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; min-width: 0; line-height: 1.3; }
|
.luf-baustein { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .5rem; min-width: 0; line-height: 1.3; }
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
{{-- Zeile eines Feldes in der Formularansicht. $f ist der Name der Alpine-Variable (item oder inner). --}}
|
||||||
|
<div class="vw-fe-zeile">
|
||||||
|
<button type="button" class="vw-fe-griff" aria-label="Feld verschieben: mit der Maus ziehen oder Pfeil hoch und runter" title="Feld verschieben"
|
||||||
|
x-on:keydown.up.prevent="shift({{ $f }}, -1)" x-on:keydown.down.prevent="shift({{ $f }}, 1)">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'griff'])
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<label class="vw-fe-frage">
|
||||||
|
<span class="vw-sr">Frage oder Beschriftung des Feldes</span>
|
||||||
|
<input type="text" x-model="{{ $f }}.label" maxlength="200" placeholder="Frage oder Beschriftung, z. B. Ihre E-Mail-Adresse"
|
||||||
|
x-bind:class="{ 'is-invalid': !{{ $f }}.label.trim() }" x-bind:aria-invalid="!{{ $f }}.label.trim()" data-fe-feld="frage">
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label class="vw-fe-typ">
|
||||||
|
<span class="vw-sr">Art der Antwort</span>
|
||||||
|
<select x-model="{{ $f }}.type" x-on:change="typeChanged({{ $f }})" x-bind:disabled="!isTmp({{ $f }}.key)"
|
||||||
|
x-bind:title="isTmp({{ $f }}.key) ? '' : 'Die Art lässt sich nach dem Speichern nicht mehr ändern, weil Bedingungen und bisherige Anfragen darauf aufbauen. Lege dafür ein neues Feld an.'" data-fe-feld="typ">
|
||||||
|
<template x-for="type in cfg.types" x-bind:key="type.value">
|
||||||
|
<option x-bind:value="type.value" x-text="type.label" x-bind:selected="{{ $f }}.type === type.value"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<label class="vw-fe-pflicht">
|
||||||
|
<input type="checkbox" x-model="{{ $f }}.required" data-fe-feld="pflicht">
|
||||||
|
<span>Pflicht</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<span class="vw-fe-symbole">
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-gesetzt': {{ $f }}.help.trim() }" x-on:click="openModal('text', {{ $f }})" x-bind:title="{{ $f }}.help.trim() ? 'Hilfetext: ' + {{ $f }}.help : 'Hilfetext hinzufügen'" aria-label="Hilfetext des Feldes" data-fe-aktion="hilfetext">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'frage'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-versteckt': !typeOf({{ $f }}.type).options, 'is-gesetzt': {{ $f }}.options.length > 0, 'is-warnung': {{ $f }}.options.length === 0 }" x-bind:tabindex="typeOf({{ $f }}.type).options ? 0 : -1" x-bind:aria-hidden="!typeOf({{ $f }}.type).options" x-on:click="openModal('options', {{ $f }})" x-bind:title="optionsText({{ $f }})" aria-label="Auswahlwerte des Feldes" data-fe-aktion="auswahlwerte">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'liste'])
|
||||||
|
<span class="vw-fe-zaehler" x-text="{{ $f }}.options.length"></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-gesetzt': hasCond({{ $f }}), 'is-warnung': condProblem({{ $f }}) }" x-on:click="openModal('cond', {{ $f }})" x-bind:title="condText({{ $f }}) || 'Bedingung für das Feld'" aria-label="Bedingung des Feldes" data-fe-aktion="bedingung-feld">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'verzweigung'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-on:click="openModal('more', {{ $f }})" title="Weitere Einstellungen" aria-label="Weitere Einstellungen des Feldes">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'mehr'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol is-gefahr" x-on:click="remove({{ $f }})" title="Feld aus dem Formular entfernen" aria-label="Feld aus dem Formular entfernen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'papierkorb'])
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="vw-fe-bedingung" x-show="hasCond({{ $f }})" x-cloak>
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'verzweigung'])
|
||||||
|
<span x-text="condText({{ $f }})"></span>
|
||||||
|
</p>
|
||||||
|
<p class="vw-fe-bedingung is-info" x-show="{{ $f }}.used_in" x-cloak>
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'info'])
|
||||||
|
<span>Auch verwendet in: <span x-text="{{ $f }}.used_in"></span></span>
|
||||||
|
</p>
|
||||||
@@ -0,0 +1,828 @@
|
|||||||
|
@verbatim
|
||||||
|
<script>
|
||||||
|
/*
|
||||||
|
* Formularansicht des Aufbaus (ADR-62). Der Baum besteht aus Bereichen (areas[]), darin Felder, Teilbereiche (mit eigenen
|
||||||
|
* Feldern) und höchstens einer Frage nach dem Anliegen. Der Browser führt den Baum; beim Speichern liegt er als Text im
|
||||||
|
* Formularzustand (state), den FormEditor prüft und in Katalog und Entwurf überführt. Ziehen und Ablegen: SortableJS, das
|
||||||
|
* Filament mitbringt (window.Sortable). Der Baum ist die einzige Wahrheit: Nach jedem Ablegen wird die Verschiebung im
|
||||||
|
* Baum nachvollzogen und die vom Ziehen bewegte DOM-Position zurückgesetzt, damit Alpine die Liste neu zeichnet.
|
||||||
|
*/
|
||||||
|
window.lufFormEditor = window.lufFormEditor || function (cfg) {
|
||||||
|
const letters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const random = (n) => Array.from({ length: n }, () => letters[Math.floor(Math.random() * letters.length)]).join('');
|
||||||
|
const uid = () => 'n' + random(9);
|
||||||
|
const kindOfEffect = { area: 'step', section: 'group', field: 'field' };
|
||||||
|
|
||||||
|
const blankCond = () => ({ effect: '', match: 'all', conditions: [], pos: null });
|
||||||
|
const prepCond = (cond) => {
|
||||||
|
if (!cond || Array.isArray(cond)) {
|
||||||
|
return blankCond();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
effect: cond.effect || '',
|
||||||
|
match: cond.match === 'any' ? 'any' : 'all',
|
||||||
|
conditions: (cond.conditions || []).map((c) => ({ _id: uid(), source: c.source || '', op: c.op || 'eq', values: [...(c.values || [])] })),
|
||||||
|
pos: cond.pos ?? null,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const prepField = (f) => ({
|
||||||
|
_id: uid(),
|
||||||
|
kind: 'field',
|
||||||
|
key: f.key || '',
|
||||||
|
name: f.name || '',
|
||||||
|
label: f.label || '',
|
||||||
|
help: f.help || '',
|
||||||
|
type: f.type || 'text',
|
||||||
|
options: (f.options || []).map((o) => ({ _id: uid(), key: o.key || '', label: o.label || '' })),
|
||||||
|
required: !!f.required,
|
||||||
|
purpose: f.purpose || '',
|
||||||
|
used_in: f.used_in || '',
|
||||||
|
cond: prepCond(f.cond),
|
||||||
|
});
|
||||||
|
const prepItem = (item) => {
|
||||||
|
if (item.kind === 'issue') {
|
||||||
|
return { _id: uid(), kind: 'issue', issues: [...(item.issues || [])] };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.kind === 'section') {
|
||||||
|
return {
|
||||||
|
_id: uid(),
|
||||||
|
kind: 'section',
|
||||||
|
key: item.key || '',
|
||||||
|
label: item.label || '',
|
||||||
|
description: item.description || '',
|
||||||
|
missing: !!item.missing,
|
||||||
|
used_in: item.used_in || '',
|
||||||
|
cond: prepCond(item.cond),
|
||||||
|
items: (item.items || []).map(prepField),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return prepField(item);
|
||||||
|
};
|
||||||
|
const prepArea = (a) => ({
|
||||||
|
_id: uid(),
|
||||||
|
kind: 'area',
|
||||||
|
key: a.key || 's' + random(6),
|
||||||
|
title: a.title || '',
|
||||||
|
intro: a.intro || '',
|
||||||
|
cond: prepCond(a.cond),
|
||||||
|
items: (a.items || []).map(prepItem),
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
cfg,
|
||||||
|
tree: { areas: [] },
|
||||||
|
history: [],
|
||||||
|
last: '',
|
||||||
|
modal: null,
|
||||||
|
modalNode: null,
|
||||||
|
catalogSearch: '',
|
||||||
|
announcement: '',
|
||||||
|
opener: null,
|
||||||
|
refreshTimer: null,
|
||||||
|
sortables: [],
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this.load(this.state);
|
||||||
|
this.$watch('state', (value) => {
|
||||||
|
// Der Server hat einen neuen Stand geliefert (nach dem Speichern: feste Kennungen statt tmp_…).
|
||||||
|
if (value !== this.last) {
|
||||||
|
this.load(value);
|
||||||
|
this.history = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Laden und Übergeben */
|
||||||
|
|
||||||
|
load(json) {
|
||||||
|
let data = {};
|
||||||
|
|
||||||
|
try {
|
||||||
|
data = JSON.parse(json || '{}') || {};
|
||||||
|
} catch (e) {
|
||||||
|
data = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
this.tree = { areas: (data.areas || []).map(prepArea) };
|
||||||
|
this.modal = null;
|
||||||
|
this.modalNode = null;
|
||||||
|
|
||||||
|
if (this.$refs.dialog && this.$refs.dialog.open) {
|
||||||
|
this.$refs.dialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.last = this.serialize();
|
||||||
|
},
|
||||||
|
|
||||||
|
serialize() {
|
||||||
|
return JSON.stringify({ areas: this.tree.areas }, (key, value) => (key === '_id' ? undefined : value));
|
||||||
|
},
|
||||||
|
|
||||||
|
commit() {
|
||||||
|
const json = this.serialize();
|
||||||
|
|
||||||
|
if (json === this.last) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.last = json;
|
||||||
|
this.state = json;
|
||||||
|
this.refreshSoon();
|
||||||
|
},
|
||||||
|
|
||||||
|
// Die Regelliste im Register „Weitere Regeln“ liest den Aufbau auf dem Server; deshalb nach Änderungen kurz abgleichen.
|
||||||
|
refreshSoon() {
|
||||||
|
clearTimeout(this.refreshTimer);
|
||||||
|
this.refreshTimer = setTimeout(() => this.$wire.$refresh(), 1500);
|
||||||
|
},
|
||||||
|
|
||||||
|
snapshot() {
|
||||||
|
this.history.push(this.serialize());
|
||||||
|
|
||||||
|
if (this.history.length > 40) {
|
||||||
|
this.history.shift();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
undo() {
|
||||||
|
const previous = this.history.pop();
|
||||||
|
|
||||||
|
if (previous === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rest = this.history;
|
||||||
|
this.load(previous);
|
||||||
|
this.history = rest;
|
||||||
|
this.last = '';
|
||||||
|
this.commit();
|
||||||
|
this.announce('Letzte Änderung rückgängig gemacht.');
|
||||||
|
},
|
||||||
|
|
||||||
|
announce(text) {
|
||||||
|
this.announcement = '';
|
||||||
|
this.$nextTick(() => { this.announcement = text; });
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Hilfen */
|
||||||
|
|
||||||
|
isTmp(key) {
|
||||||
|
return String(key || '').startsWith('tmp_');
|
||||||
|
},
|
||||||
|
|
||||||
|
typeOf(value) {
|
||||||
|
return this.cfg.types.find((type) => type.value === value) || { value, label: value, options: false, control: false };
|
||||||
|
},
|
||||||
|
|
||||||
|
typeLabel(value) {
|
||||||
|
return this.typeOf(value).label;
|
||||||
|
},
|
||||||
|
|
||||||
|
all() {
|
||||||
|
const out = [];
|
||||||
|
|
||||||
|
this.tree.areas.forEach((area) => {
|
||||||
|
out.push(area);
|
||||||
|
area.items.forEach((item) => {
|
||||||
|
out.push(item);
|
||||||
|
|
||||||
|
if (item.kind === 'section') {
|
||||||
|
item.items.forEach((inner) => out.push(inner));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return out;
|
||||||
|
},
|
||||||
|
|
||||||
|
find(id) {
|
||||||
|
for (let ai = 0; ai < this.tree.areas.length; ai++) {
|
||||||
|
const area = this.tree.areas[ai];
|
||||||
|
|
||||||
|
if (area._id === id) {
|
||||||
|
return { node: area, list: this.tree.areas, index: ai, parent: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let ii = 0; ii < area.items.length; ii++) {
|
||||||
|
const item = area.items[ii];
|
||||||
|
|
||||||
|
if (item._id === id) {
|
||||||
|
return { node: item, list: area.items, index: ii, parent: area };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.kind === 'section') {
|
||||||
|
for (let fi = 0; fi < item.items.length; fi++) {
|
||||||
|
if (item.items[fi]._id === id) {
|
||||||
|
return { node: item.items[fi], list: item.items, index: fi, parent: item };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
|
container(id) {
|
||||||
|
if (id === 'areas') {
|
||||||
|
return { list: this.tree.areas, node: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
const hit = this.find(id.slice(2));
|
||||||
|
|
||||||
|
return hit ? { list: hit.node.items, node: hit.node } : null;
|
||||||
|
},
|
||||||
|
|
||||||
|
summary() {
|
||||||
|
const nodes = this.all();
|
||||||
|
const fields = nodes.filter((node) => node.kind === 'field').length;
|
||||||
|
const sections = nodes.filter((node) => node.kind === 'section').length;
|
||||||
|
|
||||||
|
return this.tree.areas.length + (this.tree.areas.length === 1 ? ' Bereich' : ' Bereiche') + ' · ' + fields + (fields === 1 ? ' Feld' : ' Felder') + (sections ? ' · ' + sections + (sections === 1 ? ' Teilbereich' : ' Teilbereiche') : '');
|
||||||
|
},
|
||||||
|
|
||||||
|
hasIssue() {
|
||||||
|
return this.all().some((node) => node.kind === 'issue');
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Angaben, die noch fehlen */
|
||||||
|
|
||||||
|
fieldProblem(field) {
|
||||||
|
if (!field.label.trim()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.typeOf(field.type).options && !field.options.some((option) => option.label.trim());
|
||||||
|
},
|
||||||
|
|
||||||
|
problems() {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
this.tree.areas.forEach((area) => {
|
||||||
|
if (!area.title.trim()) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.all().forEach((node) => {
|
||||||
|
if (node.kind === 'section' && !node.label.trim()) {
|
||||||
|
count++;
|
||||||
|
} else if (node.kind === 'field' && this.fieldProblem(node)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return count;
|
||||||
|
},
|
||||||
|
|
||||||
|
optionsText(field) {
|
||||||
|
const count = field.options.length;
|
||||||
|
|
||||||
|
return count === 0 ? 'Auswahlwerte fehlen noch' : 'Auswahlwerte (' + count + '): ' + field.options.map((option) => option.label).filter(Boolean).join(', ');
|
||||||
|
},
|
||||||
|
|
||||||
|
issueText(item) {
|
||||||
|
if (!item.issues.length) {
|
||||||
|
return 'Alle angebotenen Anliegen';
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.issues.map((key) => (this.cfg.issues.find((issue) => issue.key === key) || { label: key }).label).join(', ');
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Hinzufügen und Entfernen */
|
||||||
|
|
||||||
|
addArea() {
|
||||||
|
this.snapshot();
|
||||||
|
const area = prepArea({ title: '', items: [] });
|
||||||
|
this.tree.areas.push(area);
|
||||||
|
this.afterAdd(area, '[data-fe-feld="titel"]');
|
||||||
|
},
|
||||||
|
|
||||||
|
newField(base = {}) {
|
||||||
|
return prepField({ key: 'tmp_' + random(8), type: 'text', ...base });
|
||||||
|
},
|
||||||
|
|
||||||
|
addField(target) {
|
||||||
|
this.snapshot();
|
||||||
|
const field = this.newField();
|
||||||
|
target.items.push(field);
|
||||||
|
this.afterAdd(field, '[data-fe-feld="frage"]');
|
||||||
|
},
|
||||||
|
|
||||||
|
addSection(area) {
|
||||||
|
this.snapshot();
|
||||||
|
const section = prepItem({ kind: 'section', key: 'tmp_' + random(8), label: '', items: [] });
|
||||||
|
area.items.push(section);
|
||||||
|
this.afterAdd(section, '[data-fe-feld="teil"]');
|
||||||
|
},
|
||||||
|
|
||||||
|
addIssue(area) {
|
||||||
|
if (this.hasIssue()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.snapshot();
|
||||||
|
const issue = prepItem({ kind: 'issue', issues: [] });
|
||||||
|
// Die Frage nach dem Anliegen steht üblicherweise zuoberst im Bereich.
|
||||||
|
area.items.unshift(issue);
|
||||||
|
this.afterAdd(issue, '.vw-fe-symbol');
|
||||||
|
},
|
||||||
|
|
||||||
|
afterAdd(node, selector) {
|
||||||
|
this.commit();
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const el = this.$root.querySelector('[data-fe-id="' + node._id + '"] ' + selector);
|
||||||
|
|
||||||
|
if (el) {
|
||||||
|
el.scrollIntoView({ block: 'nearest' });
|
||||||
|
el.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
insertCatalog(entry) {
|
||||||
|
const target = this.modalNode;
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.snapshot();
|
||||||
|
const field = this.newField({
|
||||||
|
key: entry.key,
|
||||||
|
name: entry.name,
|
||||||
|
label: entry.label,
|
||||||
|
help: entry.help,
|
||||||
|
type: entry.type,
|
||||||
|
options: entry.options,
|
||||||
|
purpose: entry.purpose,
|
||||||
|
used_in: entry.used_in,
|
||||||
|
});
|
||||||
|
target.items.push(field);
|
||||||
|
this.commit();
|
||||||
|
this.closeModal();
|
||||||
|
this.announce('Das Feld „' + field.label + '“ wurde eingefügt.');
|
||||||
|
},
|
||||||
|
|
||||||
|
catalogEntries() {
|
||||||
|
const used = new Set(this.all().filter((node) => node.kind === 'field').map((node) => node.key));
|
||||||
|
const term = this.catalogSearch.trim().toLowerCase();
|
||||||
|
|
||||||
|
return this.cfg.catalog.filter((entry) => !used.has(entry.key) && (term === '' || (entry.label + ' ' + entry.name).toLowerCase().includes(term)));
|
||||||
|
},
|
||||||
|
|
||||||
|
remove(node) {
|
||||||
|
const hit = this.find(node._id);
|
||||||
|
|
||||||
|
if (!hit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.snapshot();
|
||||||
|
hit.list.splice(hit.index, 1);
|
||||||
|
this.commit();
|
||||||
|
|
||||||
|
if (this.modal) {
|
||||||
|
this.closeModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.announce('Entfernt. Mit „Rückgängig“ lässt sich das zurücknehmen.');
|
||||||
|
},
|
||||||
|
|
||||||
|
typeChanged(field) {
|
||||||
|
const type = this.typeOf(field.type);
|
||||||
|
|
||||||
|
if (type.options && field.options.length === 0) {
|
||||||
|
field.options = [{ _id: uid(), key: '', label: '' }];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.type === 'boolean') {
|
||||||
|
field.options = [{ _id: uid(), key: 'ja', label: 'Ja' }, { _id: uid(), key: 'nein', label: 'Nein' }];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.purpose && !this.purposesFor(field).some((purpose) => purpose.value === field.purpose)) {
|
||||||
|
field.purpose = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.options && field.options.every((option) => !option.label.trim())) {
|
||||||
|
this.openModal('options', field);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
purposesFor(field) {
|
||||||
|
return this.cfg.purposes.filter((purpose) => purpose.types.includes(field.type));
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Auswahlwerte */
|
||||||
|
|
||||||
|
addOption() {
|
||||||
|
this.modalNode.options.push({ _id: uid(), key: '', label: '' });
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const inputs = this.$root.querySelectorAll('[data-fe-werte] input');
|
||||||
|
inputs[inputs.length - 1]?.focus();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
removeOption(index) {
|
||||||
|
this.modalNode.options.splice(index, 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
moveOption(index, delta) {
|
||||||
|
const options = this.modalNode.options;
|
||||||
|
const target = index + delta;
|
||||||
|
|
||||||
|
if (target < 0 || target >= options.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
options.splice(target, 0, options.splice(index, 1)[0]);
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Verschieben */
|
||||||
|
|
||||||
|
shift(node, delta) {
|
||||||
|
const hit = this.find(node._id);
|
||||||
|
|
||||||
|
if (!hit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = hit.index + delta;
|
||||||
|
this.snapshot();
|
||||||
|
|
||||||
|
if (target >= 0 && target < hit.list.length) {
|
||||||
|
hit.list.splice(hit.index, 1);
|
||||||
|
hit.list.splice(target, 0, node);
|
||||||
|
} else if (hit.parent && hit.parent.kind === 'section') {
|
||||||
|
// Am Rand eines Teilbereichs: das Feld verlässt ihn, direkt vor oder hinter dem Teilbereich.
|
||||||
|
const outer = this.find(hit.parent._id);
|
||||||
|
hit.list.splice(hit.index, 1);
|
||||||
|
outer.list.splice(outer.index + (delta < 0 ? 0 : 1), 0, node);
|
||||||
|
} else {
|
||||||
|
this.history.pop();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.commit();
|
||||||
|
const now = this.find(node._id);
|
||||||
|
this.announce((node.label || node.title || 'Element') + ': Position ' + (now.index + 1) + ' von ' + now.list.length + '.');
|
||||||
|
setTimeout(() => this.$root.querySelector('[data-fe-id="' + node._id + '"] .vw-fe-griff')?.focus(), 40);
|
||||||
|
},
|
||||||
|
|
||||||
|
movable(node) {
|
||||||
|
return node && node.kind !== 'area' && this.targetsFor(node).length > 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
targetsFor(node) {
|
||||||
|
const targets = [];
|
||||||
|
|
||||||
|
this.tree.areas.forEach((area, ai) => {
|
||||||
|
targets.push({ value: 'a:' + area._id, label: 'Bereich ' + (ai + 1) + (area.title.trim() ? ' „' + area.title.trim() + '“' : '') });
|
||||||
|
|
||||||
|
if (node.kind === 'field') {
|
||||||
|
area.items.filter((item) => item.kind === 'section').forEach((section) => {
|
||||||
|
targets.push({ value: 's:' + section._id, label: ' Teilbereich „' + (section.label.trim() || 'ohne Überschrift') + '“ (Bereich ' + (ai + 1) + ')' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return targets;
|
||||||
|
},
|
||||||
|
|
||||||
|
moveTo(node, destination) {
|
||||||
|
if (!destination) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hit = this.find(node._id);
|
||||||
|
const to = this.container(destination);
|
||||||
|
|
||||||
|
if (!hit || !to) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.snapshot();
|
||||||
|
hit.list.splice(hit.index, 1);
|
||||||
|
to.list.push(node);
|
||||||
|
this.commit();
|
||||||
|
this.closeModal();
|
||||||
|
this.announce('Verschoben.');
|
||||||
|
},
|
||||||
|
|
||||||
|
// Ziehen und Ablegen -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
mountList(el, id) {
|
||||||
|
if (!window.Sortable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isAreas = id === 'areas';
|
||||||
|
const inSection = id.startsWith('s:');
|
||||||
|
|
||||||
|
window.Sortable.create(el, {
|
||||||
|
group: {
|
||||||
|
name: isAreas ? 'fe-bereiche' : 'fe-elemente',
|
||||||
|
pull: true,
|
||||||
|
put: (to, from, dragged) => (isAreas ? false : (inSection ? dragged.dataset.feKind === 'field' : true)),
|
||||||
|
},
|
||||||
|
draggable: isAreas ? '[data-fe-area]' : '[data-fe-item]',
|
||||||
|
handle: isAreas ? '.vw-fe-griff-bereich' : '.vw-fe-griff',
|
||||||
|
animation: 150,
|
||||||
|
ghostClass: 'vw-fe-geist',
|
||||||
|
chosenClass: 'vw-fe-gegriffen',
|
||||||
|
dragClass: 'vw-fe-gezogen',
|
||||||
|
emptyInsertThreshold: 24,
|
||||||
|
fallbackOnBody: true,
|
||||||
|
swapThreshold: 0.6,
|
||||||
|
onEnd: (event) => this.dropped(event),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
dropped(event) {
|
||||||
|
const { item, from, to, oldDraggableIndex, newDraggableIndex } = event;
|
||||||
|
const id = item.dataset.feId;
|
||||||
|
const draggable = item.hasAttribute('data-fe-area') ? '[data-fe-area]' : '[data-fe-item]';
|
||||||
|
const target = to.dataset.feList;
|
||||||
|
|
||||||
|
if (from === to && oldDraggableIndex === newDraggableIndex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die DOM-Position zurücksetzen: Alpine zeichnet die Listen aus dem Baum neu.
|
||||||
|
item.remove();
|
||||||
|
const siblings = Array.from(from.querySelectorAll(':scope > ' + draggable));
|
||||||
|
from.insertBefore(item, siblings[oldDraggableIndex] || null);
|
||||||
|
|
||||||
|
const hit = this.find(id);
|
||||||
|
const destination = this.container(target);
|
||||||
|
|
||||||
|
if (!hit || !destination) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ein Teilbereich bleibt auf der Ebene eines Bereichs; Felder dürfen überallhin.
|
||||||
|
if (hit.node.kind === 'section' && destination.node && destination.node.kind === 'section') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.snapshot();
|
||||||
|
hit.list.splice(hit.index, 1);
|
||||||
|
destination.list.splice(Math.min(newDraggableIndex, destination.list.length), 0, hit.node);
|
||||||
|
this.commit();
|
||||||
|
this.announce((hit.node.label || hit.node.title || 'Element') + ' verschoben.');
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Dialog */
|
||||||
|
|
||||||
|
openModal(kind, node) {
|
||||||
|
this.opener = document.activeElement;
|
||||||
|
this.catalogSearch = '';
|
||||||
|
this.modal = { kind };
|
||||||
|
this.modalNode = node;
|
||||||
|
|
||||||
|
if (kind === 'cond' && node.cond.effect && node.cond.conditions.length === 0) {
|
||||||
|
this.addCond(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (!this.$refs.dialog.open) {
|
||||||
|
this.$refs.dialog.showModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Der Inhalt des Dialogs entsteht erst nach dem Öffnen; deshalb kurz warten, bis das Zielfeld da ist.
|
||||||
|
setTimeout(() => {
|
||||||
|
if (kind === 'options') {
|
||||||
|
const inputs = Array.from(this.$root.querySelectorAll('[data-fe-werte] input'));
|
||||||
|
(inputs.find((input) => input.value === '') || this.$root.querySelector('[data-fe-aktion="option-neu"]'))?.focus();
|
||||||
|
} else {
|
||||||
|
this.$refs.dialogFocus?.focus();
|
||||||
|
}
|
||||||
|
}, 60);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
closeModal() {
|
||||||
|
if (this.$refs.dialog.open) {
|
||||||
|
this.$refs.dialog.close();
|
||||||
|
} else {
|
||||||
|
this.onDialogClose();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onDialogClose() {
|
||||||
|
// Leere, nie gespeicherte Auswahlwerte fallen beim Schließen weg.
|
||||||
|
if (this.modal && this.modal.kind === 'options' && this.modalNode) {
|
||||||
|
this.modalNode.options = this.modalNode.options.filter((option) => option.label.trim() || option.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.commit();
|
||||||
|
this.modal = null;
|
||||||
|
this.modalNode = null;
|
||||||
|
|
||||||
|
if (this.opener && document.contains(this.opener)) {
|
||||||
|
this.opener.focus();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
dialogTitle() {
|
||||||
|
const node = this.modalNode;
|
||||||
|
|
||||||
|
if (!this.modal || !node) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = (node.label || node.title || '').trim();
|
||||||
|
const of = name ? ' „' + name + '“' : '';
|
||||||
|
|
||||||
|
switch (this.modal.kind) {
|
||||||
|
case 'text': return node.kind === 'field' ? 'Hilfetext' + of : (node.kind === 'area' ? 'Einleitung des Bereichs' + of : 'Erläuterung des Teilbereichs' + of);
|
||||||
|
case 'options': return 'Auswahlwerte' + of;
|
||||||
|
case 'cond': return 'Bedingung' + of;
|
||||||
|
case 'issue': return 'Frage nach dem Anliegen';
|
||||||
|
case 'more': return 'Weitere Einstellungen' + of;
|
||||||
|
case 'catalog': return 'Vorhandenes Feld einfügen';
|
||||||
|
default: return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
textKey() {
|
||||||
|
const kind = this.modalNode?.kind;
|
||||||
|
|
||||||
|
return kind === 'field' ? 'help' : (kind === 'area' ? 'intro' : 'description');
|
||||||
|
},
|
||||||
|
|
||||||
|
textLabel() {
|
||||||
|
const kind = this.modalNode?.kind;
|
||||||
|
|
||||||
|
return kind === 'field' ? 'Hilfetext (steht unter der Frage)' : (kind === 'area' ? 'Einleitung (steht unter dem Titel des Bereichs)' : 'Erläuterung (steht unter der Überschrift)');
|
||||||
|
},
|
||||||
|
|
||||||
|
textHint() {
|
||||||
|
return this.modalNode?.kind === 'field' ? 'Ein Hilfetext erklärt, was in das Feld gehört. Leer lassen, wenn die Frage reicht.' : 'Optional. Leer lassen, wenn nichts erklärt werden muss.';
|
||||||
|
},
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ Bedingungen */
|
||||||
|
|
||||||
|
hasCond(node) {
|
||||||
|
return !!node.cond.effect && node.cond.conditions.some((c) => c.source);
|
||||||
|
},
|
||||||
|
|
||||||
|
effectOptions(node) {
|
||||||
|
return this.cfg.effects[kindOfEffect[node.kind]] || {};
|
||||||
|
},
|
||||||
|
|
||||||
|
effectChanged(node) {
|
||||||
|
if (node.cond.effect) {
|
||||||
|
if (node.cond.conditions.length === 0) {
|
||||||
|
this.addCond(node);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
node.cond.conditions = [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
addCond(node) {
|
||||||
|
node.cond.conditions.push({ _id: uid(), source: '', op: 'eq', values: [] });
|
||||||
|
},
|
||||||
|
|
||||||
|
removeCond(node, index) {
|
||||||
|
node.cond.conditions.splice(index, 1);
|
||||||
|
|
||||||
|
if (node.cond.conditions.length === 0) {
|
||||||
|
node.cond.effect = '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleValue(cond, value, on) {
|
||||||
|
const has = cond.values.includes(value);
|
||||||
|
|
||||||
|
if (on && !has) {
|
||||||
|
cond.values.push(value);
|
||||||
|
} else if (!on && has) {
|
||||||
|
cond.values.splice(cond.values.indexOf(value), 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleIssue(item, key, on) {
|
||||||
|
const has = item.issues.includes(key);
|
||||||
|
|
||||||
|
if (on && !has) {
|
||||||
|
item.issues.push(key);
|
||||||
|
} else if (!on && has) {
|
||||||
|
item.issues.splice(item.issues.indexOf(key), 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Felder, auf die sich eine Bedingung stützen darf: gespeicherte Auswahl- und Ja/Nein-Felder oberhalb des Elements.
|
||||||
|
sourcesFor(node) {
|
||||||
|
const sources = [];
|
||||||
|
let issue = null;
|
||||||
|
|
||||||
|
for (const other of this.all()) {
|
||||||
|
if (other._id === node._id) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (other.kind === 'issue') {
|
||||||
|
issue = other;
|
||||||
|
} else if (other.kind === 'field' && this.typeOf(other.type).control && !this.isTmp(other.key)) {
|
||||||
|
sources.push({ value: other.key, label: other.label.trim() || other.key });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (issue) {
|
||||||
|
sources.unshift({ value: 'unteranliegen', label: 'Unteranliegen' }, { value: 'anliegen', label: 'Anliegen' });
|
||||||
|
}
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Auswahl der Grundlage; eine nicht mehr gültige Grundlage bleibt sichtbar, damit sie ersetzt werden kann.
|
||||||
|
sourceChoices(node, cond) {
|
||||||
|
const sources = this.sourcesFor(node);
|
||||||
|
|
||||||
|
if (cond.source && !sources.some((source) => source.value === cond.source)) {
|
||||||
|
sources.push({ value: cond.source, label: this.sourceLabel(cond.source) + ' (nicht mehr verfügbar)' });
|
||||||
|
}
|
||||||
|
|
||||||
|
return sources;
|
||||||
|
},
|
||||||
|
|
||||||
|
sourceLabel(source) {
|
||||||
|
if (source === 'anliegen') {
|
||||||
|
return 'Anliegen';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source === 'unteranliegen') {
|
||||||
|
return 'Unteranliegen';
|
||||||
|
}
|
||||||
|
|
||||||
|
const field = this.all().find((node) => node.kind === 'field' && node.key === source);
|
||||||
|
|
||||||
|
return field ? (field.label.trim() || source) : source;
|
||||||
|
},
|
||||||
|
|
||||||
|
sourceValues(node, source) {
|
||||||
|
if (!source) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source === 'anliegen' || source === 'unteranliegen') {
|
||||||
|
const only = (this.all().find((other) => other.kind === 'issue') || { issues: [] }).issues;
|
||||||
|
const values = [];
|
||||||
|
|
||||||
|
this.cfg.issues.forEach((issue) => {
|
||||||
|
if (only.length && !only.includes(issue.key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source === 'anliegen') {
|
||||||
|
values.push({ value: issue.key, label: issue.label });
|
||||||
|
} else {
|
||||||
|
issue.children.forEach((child) => values.push({ value: child.key, label: issue.label + ' › ' + child.label }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
const field = this.all().find((other) => other.kind === 'field' && other.key === source);
|
||||||
|
|
||||||
|
return field ? field.options.filter((option) => option.key).map((option) => ({ value: option.key, label: option.label })) : [];
|
||||||
|
},
|
||||||
|
|
||||||
|
condSourceProblem(node, cond) {
|
||||||
|
return !!cond.source && !this.sourcesFor(node).some((source) => source.value === cond.source);
|
||||||
|
},
|
||||||
|
|
||||||
|
condProblem(node) {
|
||||||
|
return !!node.cond.effect && node.cond.conditions.some((cond) => this.condSourceProblem(node, cond));
|
||||||
|
},
|
||||||
|
|
||||||
|
condText(node) {
|
||||||
|
if (!this.hasCond(node)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const effect = (this.effectOptions(node)[node.cond.effect] || '').replace(/\s*…$/, '').replace(/,\s*wenn$/, '');
|
||||||
|
const joiner = node.cond.match === 'any' ? ' oder ' : ' und ';
|
||||||
|
const parts = node.cond.conditions.filter((cond) => cond.source).map((cond) => {
|
||||||
|
const values = cond.values.map((value) => {
|
||||||
|
const found = this.sourceValues(node, cond.source).find((option) => option.value === value);
|
||||||
|
|
||||||
|
return found ? found.label : value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.sourceLabel(cond.source) + ' ' + (this.cfg.operators[cond.op] || cond.op) + ' ' + (values.join(' / ') || '…');
|
||||||
|
});
|
||||||
|
|
||||||
|
return effect + ', wenn ' + parts.join(joiner) + (this.condProblem(node) ? ' – bitte prüfen: Grundlage steht nicht oberhalb' : '');
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
@endverbatim
|
||||||
@@ -0,0 +1,396 @@
|
|||||||
|
{{--
|
||||||
|
Formularansicht des Aufbaus (ADR-62): Bereiche, Teilbereiche und Felder als Baum, im Browser bearbeitet und beim Speichern
|
||||||
|
als Text (editor_json) übergeben. Logik: form-editor-script.blade.php. Gestaltung: verwaltung/styles.blade.php (vw-fe-…).
|
||||||
|
--}}
|
||||||
|
@php
|
||||||
|
$statePath = $getStatePath();
|
||||||
|
@endphp
|
||||||
|
@once
|
||||||
|
@include('filament.communication.form-editor-script')
|
||||||
|
@endonce
|
||||||
|
|
||||||
|
<div class="vw-fe-aussen" data-fe-aussen>
|
||||||
|
@if ($errors->has($statePath))
|
||||||
|
<div class="vw-fe-fehler" role="alert" data-fe-fehler>
|
||||||
|
<strong>Das Formular lässt sich so noch nicht speichern:</strong>
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->get($statePath) as $message)
|
||||||
|
<li>{{ $message }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="vw vw-fe"
|
||||||
|
wire:ignore
|
||||||
|
data-fe-root
|
||||||
|
x-data="{ state: $wire.$entangle('{{ $statePath }}'), ...lufFormEditor(@js($config)) }"
|
||||||
|
x-on:input="commit()"
|
||||||
|
x-on:change="commit()"
|
||||||
|
>
|
||||||
|
<div class="vw-fe-leiste">
|
||||||
|
<p class="vw-fe-hinweis">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'info'])
|
||||||
|
<span>Ziehe Bereiche, Teilbereiche und Felder am Griff <b aria-hidden="true">⋮⋮</b> an eine beliebige Stelle. Mit der Tastatur: Griff wählen, dann Pfeil hoch oder runter.</span>
|
||||||
|
</p>
|
||||||
|
<div class="vw-fe-leiste-aktionen">
|
||||||
|
<span class="vw-fe-zahl" x-text="summary()"></span>
|
||||||
|
<button type="button" class="vw-btn is-small" x-on:click="undo()" x-bind:disabled="history.length === 0">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'zuruecksetzen'])
|
||||||
|
Rückgängig
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="vw-fe-zusatz" x-show="problems() > 0" x-cloak role="status">
|
||||||
|
<span x-text="problems()"></span> <span x-text="problems() === 1 ? 'Angabe fehlt noch' : 'Angaben fehlen noch'"></span> (rot umrandet). Speichern ist erst danach möglich.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="vw-sr" role="status" aria-live="polite" x-text="announcement"></p>
|
||||||
|
|
||||||
|
<div class="vw-fe-bereiche" data-fe-list="areas" x-init="mountList($el, 'areas')">
|
||||||
|
<template x-for="(area, ai) in tree.areas" x-bind:key="area._id">
|
||||||
|
<section class="vw-fe-bereich" data-fe-area x-bind:data-fe-id="area._id" x-bind:aria-label="'Bereich ' + (ai + 1)">
|
||||||
|
<header class="vw-fe-bereich-kopf">
|
||||||
|
<button type="button" class="vw-fe-griff vw-fe-griff-bereich" aria-label="Bereich verschieben: mit der Maus ziehen oder Pfeil hoch und runter" title="Bereich verschieben"
|
||||||
|
x-on:keydown.up.prevent="shift(area, -1)" x-on:keydown.down.prevent="shift(area, 1)">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'griff'])
|
||||||
|
</button>
|
||||||
|
<span class="vw-fe-nummer" x-text="ai + 1" aria-hidden="true"></span>
|
||||||
|
<label class="vw-fe-titel">
|
||||||
|
<span class="vw-sr">Titel des Bereichs</span>
|
||||||
|
<input type="text" x-model="area.title" maxlength="120" placeholder="Titel des Bereichs, z. B. Ihre Angaben" x-bind:class="{ 'is-invalid': !area.title.trim() }" x-bind:aria-invalid="!area.title.trim()" data-fe-feld="titel">
|
||||||
|
</label>
|
||||||
|
<span class="vw-fe-symbole">
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-gesetzt': area.intro.trim() }" x-on:click="openModal('text', area)" title="Einleitung des Bereichs" aria-label="Einleitung des Bereichs bearbeiten">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'frage'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-gesetzt': hasCond(area), 'is-warnung': condProblem(area) }" x-on:click="openModal('cond', area)" x-bind:title="condText(area) || 'Bedingung für den Bereich'" aria-label="Bedingung des Bereichs bearbeiten">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'verzweigung'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-on:click="openModal('more', area)" title="Weitere Einstellungen" aria-label="Weitere Einstellungen des Bereichs">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'mehr'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol is-gefahr" x-on:click="remove(area)" title="Bereich entfernen" aria-label="Bereich entfernen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'papierkorb'])
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</header>
|
||||||
|
<p class="vw-fe-bedingung" x-show="hasCond(area)" x-cloak>
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'verzweigung'])
|
||||||
|
<span x-text="condText(area)"></span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="vw-fe-inhalt" x-bind:data-fe-list="'a:' + area._id" x-bind:data-leer="area.items.length === 0 ? 'Dieser Bereich ist noch leer. Füge ein Feld hinzu oder ziehe eines hierher.' : false" x-init="mountList($el, 'a:' + area._id)">
|
||||||
|
<template x-for="item in area.items" x-bind:key="item._id">
|
||||||
|
<div class="vw-fe-element" data-fe-item x-bind:data-fe-id="item._id" x-bind:data-fe-kind="item.kind">
|
||||||
|
{{-- Feld im Bereich --}}
|
||||||
|
<template x-if="item.kind === 'field'">
|
||||||
|
<div class="vw-fe-feld" x-bind:class="{ 'is-ungueltig': fieldProblem(item) }">
|
||||||
|
@include('filament.communication.form-editor-feld', ['f' => 'item'])
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Frage nach dem Anliegen --}}
|
||||||
|
<template x-if="item.kind === 'issue'">
|
||||||
|
<div class="vw-fe-feld vw-fe-anliegen">
|
||||||
|
<button type="button" class="vw-fe-griff" aria-label="Frage nach dem Anliegen verschieben: ziehen oder Pfeil hoch und runter" title="Verschieben"
|
||||||
|
x-on:keydown.up.prevent="shift(item, -1)" x-on:keydown.down.prevent="shift(item, 1)">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'griff'])
|
||||||
|
</button>
|
||||||
|
<div class="vw-fe-anliegen-text">
|
||||||
|
<strong>Frage nach dem Anliegen</strong>
|
||||||
|
<span x-text="issueText(item)"></span>
|
||||||
|
</div>
|
||||||
|
<span class="vw-fe-symbole">
|
||||||
|
<button type="button" class="vw-fe-symbol is-gesetzt" x-on:click="openModal('issue', item)" title="Angebotene Anliegen" aria-label="Angebotene Anliegen wählen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'liste'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-on:click="openModal('more', item)" title="Weitere Einstellungen" aria-label="Weitere Einstellungen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'mehr'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol is-gefahr" x-on:click="remove(item)" title="Frage entfernen" aria-label="Frage nach dem Anliegen entfernen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'papierkorb'])
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Teilbereich mit eigenen Feldern --}}
|
||||||
|
<template x-if="item.kind === 'section'">
|
||||||
|
<div class="vw-fe-teil" data-fe-section>
|
||||||
|
<header class="vw-fe-teil-kopf">
|
||||||
|
<button type="button" class="vw-fe-griff" aria-label="Teilbereich verschieben: ziehen oder Pfeil hoch und runter" title="Teilbereich verschieben"
|
||||||
|
x-on:keydown.up.prevent="shift(item, -1)" x-on:keydown.down.prevent="shift(item, 1)">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'griff'])
|
||||||
|
</button>
|
||||||
|
<span class="vw-fe-art">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'teilbereich'])
|
||||||
|
Teilbereich
|
||||||
|
</span>
|
||||||
|
<label class="vw-fe-titel">
|
||||||
|
<span class="vw-sr">Überschrift des Teilbereichs</span>
|
||||||
|
<input type="text" x-model="item.label" maxlength="200" placeholder="Überschrift des Teilbereichs" x-bind:readonly="item.missing" x-bind:class="{ 'is-invalid': !item.label.trim() }" x-bind:aria-invalid="!item.label.trim()" data-fe-feld="teil">
|
||||||
|
</label>
|
||||||
|
<span class="vw-fe-symbole">
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-gesetzt': item.description.trim() }" x-on:click="openModal('text', item)" title="Erläuterung des Teilbereichs" aria-label="Erläuterung des Teilbereichs bearbeiten">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'frage'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-bind:class="{ 'is-gesetzt': hasCond(item), 'is-warnung': condProblem(item) }" x-on:click="openModal('cond', item)" x-bind:title="condText(item) || 'Bedingung für den Teilbereich'" aria-label="Bedingung des Teilbereichs bearbeiten">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'verzweigung'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-on:click="openModal('more', item)" title="Weitere Einstellungen" aria-label="Weitere Einstellungen des Teilbereichs">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'mehr'])
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-fe-symbol is-gefahr" x-on:click="remove(item)" title="Teilbereich mit seinen Feldern entfernen" aria-label="Teilbereich entfernen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'papierkorb'])
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</header>
|
||||||
|
<p class="vw-fe-bedingung" x-show="hasCond(item)" x-cloak>
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'verzweigung'])
|
||||||
|
<span x-text="condText(item)"></span>
|
||||||
|
</p>
|
||||||
|
<p class="vw-fe-notiz" x-show="item.used_in" x-cloak>Dieser Teilbereich wird auch in anderen Formularen verwendet: <span x-text="item.used_in"></span>. Änderungen an seinen Feldern gelten dort mit deren nächster Veröffentlichung.</p>
|
||||||
|
<p class="vw-fe-notiz is-warnung" x-show="item.missing" x-cloak>Diese Feldgruppe gibt es im Katalog nicht mehr. Entferne den Teilbereich oder lege ihn neu an.</p>
|
||||||
|
|
||||||
|
<div class="vw-fe-teil-inhalt" x-bind:data-fe-list="'s:' + item._id" x-bind:data-leer="item.items.length === 0 ? 'Noch kein Feld. Ziehe Felder hierher oder füge eines hinzu.' : false" x-init="mountList($el, 's:' + item._id)">
|
||||||
|
<template x-for="inner in item.items" x-bind:key="inner._id">
|
||||||
|
<div class="vw-fe-element" data-fe-item x-bind:data-fe-id="inner._id" data-fe-kind="field">
|
||||||
|
<div class="vw-fe-feld" x-bind:class="{ 'is-ungueltig': fieldProblem(inner) }">
|
||||||
|
@include('filament.communication.form-editor-feld', ['f' => 'inner'])
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<footer class="vw-fe-fuss">
|
||||||
|
<button type="button" class="vw-btn is-small is-line" x-on:click="addField(item)">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'plus'])
|
||||||
|
Neues Feld im Teilbereich
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-btn is-small" x-on:click="openModal('catalog', item)">Vorhandenes Feld einfügen</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="vw-fe-fuss">
|
||||||
|
<button type="button" class="vw-btn is-small is-line" x-on:click="addField(area)" data-fe-aktion="feld">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'plus'])
|
||||||
|
Neues Feld
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-btn is-small" x-on:click="openModal('catalog', area)">Vorhandenes Feld einfügen</button>
|
||||||
|
<button type="button" class="vw-btn is-small" x-on:click="addSection(area)" data-fe-aktion="teilbereich">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'teilbereich'])
|
||||||
|
Teilbereich
|
||||||
|
</button>
|
||||||
|
<button type="button" class="vw-btn is-small" x-on:click="addIssue(area)" x-show="!hasIssue()" x-cloak>
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'liste'])
|
||||||
|
Frage nach dem Anliegen
|
||||||
|
</button>
|
||||||
|
</footer>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="vw-fe-leer-bereich" x-show="tree.areas.length === 0" x-cloak>
|
||||||
|
<p>Das Formular hat noch keinen Bereich. Im mehrstufigen Dialog ist jeder Bereich ein Schritt, im langen Formular stehen alle Bereiche untereinander.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="vw-fe-ende">
|
||||||
|
<button type="button" class="vw-btn is-line" x-on:click="addArea()" data-fe-aktion="bereich">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'plus'])
|
||||||
|
Bereich hinzufügen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Ein Dialog für Hilfetext, Auswahlwerte, Bedingung, Einstellungen und Katalog --}}
|
||||||
|
<dialog class="vw-fe-dialog" x-ref="dialog" x-on:close="onDialogClose()" x-on:click="if ($event.target === $refs.dialog) closeModal()" aria-labelledby="vw-fe-dialog-titel">
|
||||||
|
<div class="vw-fe-dialog-karte" x-show="modal" x-cloak>
|
||||||
|
<header class="vw-fe-dialog-kopf">
|
||||||
|
<h2 id="vw-fe-dialog-titel" x-text="dialogTitle()"></h2>
|
||||||
|
<button type="button" class="vw-btn is-icon is-small" x-on:click="closeModal()" aria-label="Schließen">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'x'])
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="vw-fe-dialog-inhalt" x-bind:data-fe-dialog="modal ? modal.kind : ''">
|
||||||
|
{{-- Text: Hilfetext, Einleitung, Erläuterung --}}
|
||||||
|
<template x-if="modal && modal.kind === 'text' && modalNode">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<label class="vw-fe-etikett">
|
||||||
|
<span x-text="textLabel()"></span>
|
||||||
|
<textarea rows="5" x-model="modalNode[textKey()]" x-bind:maxlength="modalNode.kind === 'field' ? 600 : (modalNode.kind === 'area' ? 600 : 600)" x-ref="dialogFocus"></textarea>
|
||||||
|
</label>
|
||||||
|
<p class="vw-fe-notiz" x-text="textHint()"></p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Auswahlwerte --}}
|
||||||
|
<template x-if="modal && modal.kind === 'options' && modalNode">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<p class="vw-fe-notiz">Jeder Wert behält seine feste interne Kennung; eine Umbenennung beschädigt keine bisherigen Anfragen.</p>
|
||||||
|
<ol class="vw-fe-werte" data-fe-werte>
|
||||||
|
<template x-for="(option, oi) in modalNode.options" x-bind:key="option._id">
|
||||||
|
<li class="vw-fe-wert">
|
||||||
|
<input type="text" x-model="option.label" maxlength="120" placeholder="Bezeichnung des Auswahlwerts" x-bind:class="{ 'is-invalid': !option.label.trim() }" x-bind:aria-label="'Auswahlwert ' + (oi + 1)">
|
||||||
|
<button type="button" class="vw-fe-symbol" x-on:click="moveOption(oi, -1)" x-bind:disabled="oi === 0" aria-label="Nach oben" title="Nach oben">@include('filament.verwaltung.icon', ['name' => 'hoch'])</button>
|
||||||
|
<button type="button" class="vw-fe-symbol" x-on:click="moveOption(oi, 1)" x-bind:disabled="oi === modalNode.options.length - 1" aria-label="Nach unten" title="Nach unten">@include('filament.verwaltung.icon', ['name' => 'runter'])</button>
|
||||||
|
<button type="button" class="vw-fe-symbol is-gefahr" x-on:click="removeOption(oi)" aria-label="Auswahlwert entfernen" title="Entfernen">@include('filament.verwaltung.icon', ['name' => 'x'])</button>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
</ol>
|
||||||
|
<button type="button" class="vw-btn is-small is-line" x-on:click="addOption()" data-fe-aktion="option-neu">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'plus'])
|
||||||
|
Auswahlwert hinzufügen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Bedingung --}}
|
||||||
|
<template x-if="modal && modal.kind === 'cond' && modalNode">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<label class="vw-fe-etikett">
|
||||||
|
<span>Wirkung</span>
|
||||||
|
<select x-model="modalNode.cond.effect" x-on:change="effectChanged(modalNode)" x-ref="dialogFocus" data-fe-feld="wirkung">
|
||||||
|
<option value="">Keine Bedingung</option>
|
||||||
|
<template x-for="(label, value) in effectOptions(modalNode)" x-bind:key="value">
|
||||||
|
<option x-bind:value="value" x-text="label" x-bind:selected="modalNode.cond.effect === value"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p class="vw-fe-notiz" x-show="!modalNode.cond.effect">Ohne Wirkung gilt das Element immer. Wähle eine Wirkung, um es von einer Antwort abhängig zu machen.</p>
|
||||||
|
|
||||||
|
<template x-if="modalNode.cond.effect">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<label class="vw-fe-etikett" x-show="modalNode.cond.conditions.length > 1">
|
||||||
|
<span>Es müssen zutreffen</span>
|
||||||
|
<select x-model="modalNode.cond.match">
|
||||||
|
<option value="all">alle Bedingungen</option>
|
||||||
|
<option value="any">mindestens eine Bedingung</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p class="vw-fe-notiz" x-show="sourcesFor(modalNode).length === 0">Als Grundlage stehen Auswahlfelder, Ja/Nein-Felder und die Frage nach dem Anliegen zur Verfügung, die im Formular weiter oben stehen und schon einmal gespeichert wurden.</p>
|
||||||
|
|
||||||
|
<template x-for="(cond, ci) in modalNode.cond.conditions" x-bind:key="cond._id">
|
||||||
|
<fieldset class="vw-fe-bed" x-bind:class="{ 'is-ungueltig': condSourceProblem(modalNode, cond) }">
|
||||||
|
<legend x-text="ci === 0 ? 'Wenn …' : (modalNode.cond.match === 'any' ? 'oder …' : 'und …')"></legend>
|
||||||
|
<div class="vw-fe-bed-zeile">
|
||||||
|
<label class="vw-fe-etikett">
|
||||||
|
<span class="vw-sr">Grundlage</span>
|
||||||
|
<select x-model="cond.source" x-on:change="cond.values = []" data-fe-feld="grundlage">
|
||||||
|
<option value="">Grundlage wählen …</option>
|
||||||
|
<template x-for="source in sourceChoices(modalNode, cond)" x-bind:key="source.value">
|
||||||
|
<option x-bind:value="source.value" x-text="source.label" x-bind:selected="cond.source === source.value"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label class="vw-fe-etikett">
|
||||||
|
<span class="vw-sr">Vergleich</span>
|
||||||
|
<select x-model="cond.op">
|
||||||
|
<template x-for="(label, value) in cfg.operators" x-bind:key="value">
|
||||||
|
<option x-bind:value="value" x-text="label" x-bind:selected="cond.op === value"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<button type="button" class="vw-fe-symbol is-gefahr" x-on:click="removeCond(modalNode, ci)" aria-label="Bedingung entfernen" title="Bedingung entfernen">@include('filament.verwaltung.icon', ['name' => 'x'])</button>
|
||||||
|
</div>
|
||||||
|
<p class="vw-fe-notiz is-warnung" x-show="condSourceProblem(modalNode, cond)" x-cloak>Diese Grundlage steht nicht mehr oberhalb oder gibt es nicht mehr. Wähle eine andere oder entferne die Bedingung.</p>
|
||||||
|
<div class="vw-fe-werteliste" x-show="cond.source" x-cloak>
|
||||||
|
<template x-for="value in sourceValues(modalNode, cond.source)" x-bind:key="value.value">
|
||||||
|
<label class="vw-fe-wahl">
|
||||||
|
<input type="checkbox" x-bind:value="value.value" x-bind:checked="cond.values.includes(value.value)" x-on:change="toggleValue(cond, value.value, $event.target.checked)">
|
||||||
|
<span x-text="value.label"></span>
|
||||||
|
</label>
|
||||||
|
</template>
|
||||||
|
<p class="vw-fe-notiz" x-show="sourceValues(modalNode, cond.source).length === 0">Für diese Grundlage gibt es noch keine gespeicherten Werte. Speichere das Formular, dann stehen neue Auswahlwerte hier zur Verfügung.</p>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</template>
|
||||||
|
<button type="button" class="vw-btn is-small is-line" x-on:click="addCond(modalNode)" data-fe-aktion="bedingung">
|
||||||
|
@include('filament.verwaltung.icon', ['name' => 'plus'])
|
||||||
|
Bedingung hinzufügen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Anliegen --}}
|
||||||
|
<template x-if="modal && modal.kind === 'issue' && modalNode">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<p class="vw-fe-notiz">Welche Anliegen dieses Formular kennt. Nichts angekreuzt: alle angebotenen. Ein Anfragegrund im Widget kann daraus eines vorwählen; die Frage entfällt dann. Anliegen pflegst du unter „Einstellungen → Anliegen“.</p>
|
||||||
|
<div class="vw-fe-werteliste">
|
||||||
|
<template x-for="issue in cfg.issues" x-bind:key="issue.key">
|
||||||
|
<label class="vw-fe-wahl">
|
||||||
|
<input type="checkbox" x-bind:value="issue.key" x-bind:checked="modalNode.issues.includes(issue.key)" x-on:change="toggleIssue(modalNode, issue.key, $event.target.checked)">
|
||||||
|
<span x-text="issue.label"></span>
|
||||||
|
</label>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Weitere Einstellungen --}}
|
||||||
|
<template x-if="modal && modal.kind === 'more' && modalNode">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<template x-if="modalNode.kind === 'field'">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<label class="vw-fe-etikett">
|
||||||
|
<span>Verwendung in der Anfrageübersicht</span>
|
||||||
|
<select x-model="modalNode.purpose" x-ref="dialogFocus">
|
||||||
|
<option value="">Keine besondere Verwendung</option>
|
||||||
|
<template x-for="purpose in purposesFor(modalNode)" x-bind:key="purpose.value">
|
||||||
|
<option x-bind:value="purpose.value" x-text="purpose.label" x-bind:selected="modalNode.purpose === purpose.value"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p class="vw-fe-notiz">Welche Angabe der Posteingang als Name, E-Mail-Adresse oder Nachricht zeigt. Jedes Formular braucht ein Feld „E-Mail-Adresse für Rückfragen“.</p>
|
||||||
|
<p class="vw-fe-notiz" x-show="modalNode.used_in" x-cloak>Dieses Feld wird auch in diesen Formularen verwendet: <span x-text="modalNode.used_in"></span>. Eine Änderung gilt dort mit der nächsten Veröffentlichung.</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<label class="vw-fe-etikett" x-show="movable(modalNode)">
|
||||||
|
<span>Verschieben nach</span>
|
||||||
|
<select x-on:change="moveTo(modalNode, $event.target.value); $event.target.value = ''" data-fe-feld="verschieben">
|
||||||
|
<option value="">Position wählen …</option>
|
||||||
|
<template x-for="target in targetsFor(modalNode)" x-bind:key="target.value">
|
||||||
|
<option x-bind:value="target.value" x-text="target.label"></option>
|
||||||
|
</template>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<p class="vw-fe-notiz" x-show="movable(modalNode)">Das Element wird am Ende des gewählten Bereichs oder Teilbereichs eingefügt. Feinere Positionen stellst du durch Ziehen oder mit den Pfeiltasten am Griff ein.</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{-- Vorhandenes Feld aus dem Katalog --}}
|
||||||
|
<template x-if="modal && modal.kind === 'catalog' && modalNode">
|
||||||
|
<div class="vw-fe-formular">
|
||||||
|
<label class="vw-fe-etikett">
|
||||||
|
<span>Suchen</span>
|
||||||
|
<input type="search" x-model="catalogSearch" placeholder="Frage oder Name des Feldes" x-ref="dialogFocus">
|
||||||
|
</label>
|
||||||
|
<ul class="vw-fe-katalog">
|
||||||
|
<template x-for="entry in catalogEntries()" x-bind:key="entry.key">
|
||||||
|
<li>
|
||||||
|
<button type="button" class="vw-fe-katalog-eintrag" x-on:click="insertCatalog(entry)">
|
||||||
|
<strong x-text="entry.label"></strong>
|
||||||
|
<span x-text="typeLabel(entry.type) + (entry.used_in ? ' · auch in: ' + entry.used_in : '')"></span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
</ul>
|
||||||
|
<p class="vw-fe-notiz" x-show="catalogEntries().length === 0">Kein weiteres Feld gefunden. Alle passenden Felder stehen schon im Formular.</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="vw-fe-dialog-fuss">
|
||||||
|
<button type="button" class="vw-btn is-primary" x-on:click="closeModal()" data-fe-aktion="fertig">Fertig</button>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
x-on:keydown.alt.arrow-down.prevent="$wire.movePart({{ $index }}, 1)">
|
x-on:keydown.alt.arrow-down.prevent="$wire.movePart({{ $index }}, 1)">
|
||||||
<span class="vw-bild is-klein">
|
<span class="vw-bild is-klein">
|
||||||
@if (! empty($member['image']))
|
@if (! empty($member['image']))
|
||||||
<img src="{{ $member['image'] }}" alt="" loading="lazy">
|
<img src="{{ $member['image'] }}" alt="" loading="lazy" decoding="async">
|
||||||
@else
|
@else
|
||||||
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($member['tone'] ?? null)])</span>
|
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($member['tone'] ?? null)])</span>
|
||||||
@endif
|
@endif
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
@forelse ($kinder as $kind)
|
@forelse ($kinder as $kind)
|
||||||
<div class="vw-quellenzeile">
|
<div class="vw-quellenzeile">
|
||||||
<span class="vw-bild is-mini">
|
<span class="vw-bild is-mini">
|
||||||
@if (! empty($kind['image']))<img src="{{ $kind['image'] }}" alt="" loading="lazy">@else<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($kind['tone'])])</span>@endif
|
@if (! empty($kind['image']))<img src="{{ $kind['image'] }}" alt="" loading="lazy" decoding="async">@else<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($kind['tone'])])</span>@endif
|
||||||
</span>
|
</span>
|
||||||
<span><strong>{{ $kind['title'] }}</strong><br><span class="vw-feld-hilfe">{{ $kind['kind'] }}@if ($kind['role'] !== '') · {{ $kind['role'] }}@endif</span></span>
|
<span><strong>{{ $kind['title'] }}</strong><br><span class="vw-feld-hilfe">{{ $kind['kind'] }}@if ($kind['role'] !== '') · {{ $kind['role'] }}@endif</span></span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -25,6 +25,12 @@
|
|||||||
'schluessel' => '<circle cx="8" cy="14" r="4.5"/><path d="M11.3 10.8L20 2.5M16.5 6l2.5 2.5M14 8.5l2 2"/>',
|
'schluessel' => '<circle cx="8" cy="14" r="4.5"/><path d="M11.3 10.8L20 2.5M16.5 6l2.5 2.5M14 8.5l2 2"/>',
|
||||||
'etikett' => '<path d="M3 12V4h8l10 10-8 8z"/><circle cx="7.5" cy="8.5" r="1.4"/>',
|
'etikett' => '<path d="M3 12V4h8l10 10-8 8z"/><circle cx="7.5" cy="8.5" r="1.4"/>',
|
||||||
'filter' => '<path d="M4 5h16l-6.2 7.4V19l-3.6-1.8v-4.8z"/>',
|
'filter' => '<path d="M4 5h16l-6.2 7.4V19l-3.6-1.8v-4.8z"/>',
|
||||||
|
'frage' => '<circle cx="12" cy="12" r="9"/><path d="M9.5 9.2a2.6 2.6 0 0 1 5 .9c0 1.7-2.5 2.1-2.5 3.9M12 16.8v.2"/>',
|
||||||
|
'liste' => '<path d="M9 6h11M9 12h11M9 18h11"/><circle cx="4.8" cy="6" r="1"/><circle cx="4.8" cy="12" r="1"/><circle cx="4.8" cy="18" r="1"/>',
|
||||||
|
'verzweigung' => '<circle cx="6" cy="5.5" r="2"/><circle cx="6" cy="18.5" r="2"/><circle cx="18" cy="9" r="2"/><path d="M6 7.5v9M18 11c0 3.5-4 3-10.5 6.2"/>',
|
||||||
|
'papierkorb' => '<path d="M4 7h16M10 11v6M14 11v6M6 7l1 12.5h10L18 7M9 7V4.5h6V7"/>',
|
||||||
|
'teilbereich' => '<rect x="3" y="4" width="18" height="16" rx="2" stroke-dasharray="3 2.5"/><path d="M7 9h10M7 13h6"/>',
|
||||||
|
'bereich' => '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/>',
|
||||||
'zuruecksetzen' => '<path d="M4 12a8 8 0 1 0 2.4-5.7L4 8.5M4 4v4.5h4.5"/>',
|
'zuruecksetzen' => '<path d="M4 12a8 8 0 1 0 2.4-5.7L4 8.5M4 4v4.5h4.5"/>',
|
||||||
];
|
];
|
||||||
$name = $name ?? 'info';
|
$name = $name ?? 'info';
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
@endunless
|
@endunless
|
||||||
<span class="vw-bild">
|
<span class="vw-bild">
|
||||||
@if (! empty($row['image']))
|
@if (! empty($row['image']))
|
||||||
<img src="{{ $row['image'] }}" alt="" loading="lazy">
|
<img src="{{ $row['image'] }}" alt="" loading="lazy" decoding="async">
|
||||||
@else
|
@else
|
||||||
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($row['output'])])</span>
|
<span class="vw-bild-ersatz">@include('filament.verwaltung.icon', ['name' => $symbol($row['output'])])</span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -708,4 +708,136 @@
|
|||||||
.vw-symbolfeld-kacheln { grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr)); }
|
.vw-symbolfeld-kacheln { grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr)); }
|
||||||
.vw-symbolfeld-panel { max-height: 18rem; }
|
.vw-symbolfeld-panel { max-height: 18rem; }
|
||||||
}
|
}
|
||||||
|
/* Formularansicht des Aufbaus (Formular-Editor, ADR-62): Bereiche als Karten, Teilbereiche als eingerahmte Einheit darin */
|
||||||
|
.vw-fe { display: grid; gap: 1rem; min-width: 0; }
|
||||||
|
.vw-fe-aussen { display: grid; gap: 0.75rem; min-width: 0; }
|
||||||
|
.vw-fe-fehler { border: 1px solid var(--vw-error); background: var(--vw-error-soft); color: var(--vw-error); padding: 0.75rem 1rem; border-radius: var(--vw-radius); }
|
||||||
|
.vw-fe-fehler ul { margin: 0.35rem 0 0; padding-left: 1.25rem; }
|
||||||
|
.vw-fe-leiste { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; justify-content: space-between; }
|
||||||
|
.vw-fe-hinweis { display: flex; gap: 0.5rem; align-items: flex-start; max-width: 48rem; color: var(--vw-quiet); font-size: var(--vw-small); }
|
||||||
|
.vw-fe-hinweis svg { width: 1.1rem; height: 1.1rem; flex: none; margin-top: 0.15rem; }
|
||||||
|
.vw-fe-leiste-aktionen { display: flex; gap: 0.75rem; align-items: center; margin-left: auto; }
|
||||||
|
.vw-fe-zahl { color: var(--vw-quiet); font-size: var(--vw-small); }
|
||||||
|
.vw-fe-zusatz { color: var(--vw-error); font-weight: 600; font-size: var(--vw-small); }
|
||||||
|
|
||||||
|
.vw-fe-bereiche { container-type: inline-size; container-name: fe; display: grid; gap: 1.5rem; min-width: 0; }
|
||||||
|
.vw-fe-bereich { border: 1px solid var(--vw-line-strong); border-left: 6px solid var(--vw-pine); border-radius: var(--vw-radius); background: var(--vw-surface); box-shadow: 0 2px 6px rgb(3 37 81 / 8%); min-width: 0; }
|
||||||
|
.vw-fe-bereich-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.6rem; padding: 0.7rem 0.9rem 0.7rem 0.5rem; background: var(--vw-paper); border-bottom: 1px solid var(--vw-line); border-radius: 0 var(--vw-radius) 0 0; }
|
||||||
|
.vw-fe-nummer { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--vw-pine); color: #fff; font-weight: 700; }
|
||||||
|
.vw-fe-titel { flex: 1 1 12rem; min-width: 0; }
|
||||||
|
.vw-fe-bereich-kopf .vw-fe-titel input { font-size: 1.15rem; font-weight: 700; }
|
||||||
|
.vw-fe-teil-kopf .vw-fe-titel input { font-weight: 650; }
|
||||||
|
|
||||||
|
.vw-fe input[type="text"], .vw-fe input[type="search"], .vw-fe select, .vw-fe textarea {
|
||||||
|
width: 100%; min-height: var(--vw-target); padding: 0.4rem 0.65rem; border: 1px solid var(--vw-line-strong); border-radius: var(--vw-radius-small);
|
||||||
|
background: #fff; color: var(--vw-ink); font: inherit; line-height: 1.35;
|
||||||
|
}
|
||||||
|
.vw-fe textarea { resize: vertical; }
|
||||||
|
.vw-fe select:disabled { background: var(--vw-paper); color: var(--vw-quiet); cursor: not-allowed; }
|
||||||
|
.vw-fe input[readonly] { background: var(--vw-paper); }
|
||||||
|
.vw-fe .is-invalid { border-color: var(--vw-error); background: var(--vw-error-soft); box-shadow: inset 0 0 0 1px var(--vw-error); }
|
||||||
|
|
||||||
|
.vw-fe-griff { display: grid; place-items: center; flex: none; width: 2rem; min-height: 2.25rem; padding: 0; border: 0; border-radius: var(--vw-radius-small); background: transparent; color: var(--vw-muted); cursor: grab; touch-action: none; }
|
||||||
|
.vw-fe-griff:hover { background: var(--vw-paper); color: var(--vw-ink); }
|
||||||
|
.vw-fe-griff:active { cursor: grabbing; }
|
||||||
|
.vw-fe-griff svg { width: 1.15rem; height: 1.15rem; }
|
||||||
|
|
||||||
|
.vw-fe-symbole { display: flex; flex: none; align-items: center; gap: 0.15rem; }
|
||||||
|
.vw-fe-symbol {
|
||||||
|
position: relative; display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 1px solid transparent; border-radius: var(--vw-radius-small);
|
||||||
|
background: transparent; color: var(--vw-muted); cursor: pointer;
|
||||||
|
}
|
||||||
|
.vw-fe-symbol svg { width: 1.2rem; height: 1.2rem; }
|
||||||
|
.vw-fe-symbol:hover { border-color: var(--vw-line-strong); color: var(--vw-ink); background: #fff; }
|
||||||
|
.vw-fe-symbol:disabled { opacity: 0.35; cursor: not-allowed; }
|
||||||
|
.vw-fe-symbol.is-gesetzt { border-color: #b9d6a3; background: var(--vw-pine-soft); color: var(--vw-pine-dark); }
|
||||||
|
.vw-fe-symbol.is-warnung { border-color: #ecc77a; background: var(--vw-warn-soft); color: var(--vw-warn); }
|
||||||
|
.vw-fe-symbol.is-gefahr:hover { border-color: var(--vw-error); background: var(--vw-error-soft); color: var(--vw-error); }
|
||||||
|
.vw-fe-symbol.is-versteckt { visibility: hidden; }
|
||||||
|
.vw-fe-zaehler { position: absolute; right: -0.15rem; top: -0.3rem; min-width: 1.1rem; padding: 0 0.25rem; border-radius: 999px; background: var(--vw-pine); color: #fff; font-size: 0.7rem; font-weight: 700; line-height: 1.1rem; text-align: center; }
|
||||||
|
.vw-fe-symbol.is-warnung .vw-fe-zaehler { background: var(--vw-warn); }
|
||||||
|
|
||||||
|
.vw-fe-inhalt { position: relative; display: grid; gap: 0.5rem; padding: 0.9rem; min-height: 4.5rem; align-content: start; }
|
||||||
|
.vw-fe-feld { background: #fff; border: 1px solid var(--vw-line); border-radius: var(--vw-radius-small); padding: 0.4rem 0.5rem 0.4rem 0.3rem; }
|
||||||
|
.vw-fe-feld.is-ungueltig { border-color: var(--vw-error); }
|
||||||
|
.vw-fe-zeile {
|
||||||
|
display: grid; gap: 0.4rem 0.6rem; align-items: center;
|
||||||
|
grid-template-columns: auto minmax(0, 1fr) 13rem 5.6rem auto; grid-template-areas: "griff frage typ pflicht symbole";
|
||||||
|
}
|
||||||
|
.vw-fe-zeile > .vw-fe-griff { grid-area: griff; }
|
||||||
|
.vw-fe-frage { grid-area: frage; min-width: 0; }
|
||||||
|
.vw-fe-typ { grid-area: typ; min-width: 0; }
|
||||||
|
.vw-fe-pflicht { grid-area: pflicht; display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; font-size: var(--vw-small); font-weight: 600; cursor: pointer; }
|
||||||
|
.vw-fe-pflicht input { width: 1.1rem; height: 1.1rem; accent-color: var(--vw-pine); }
|
||||||
|
.vw-fe-zeile > .vw-fe-symbole { grid-area: symbole; }
|
||||||
|
@container fe (max-width: 46rem) {
|
||||||
|
.vw-fe-zeile { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "griff frage frage" ". typ typ" ". pflicht symbole"; }
|
||||||
|
.vw-fe-zeile > .vw-fe-symbole { justify-self: end; }
|
||||||
|
}
|
||||||
|
@container fe (max-width: 30rem) {
|
||||||
|
.vw-fe-zeile { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "griff frage" ". typ" ". pflicht" ". symbole"; }
|
||||||
|
.vw-fe-zeile > .vw-fe-symbole { justify-self: start; }
|
||||||
|
}
|
||||||
|
.vw-fe-bedingung { display: flex; align-items: flex-start; gap: 0.4rem; margin: 0.4rem 0.4rem 0.1rem 2.4rem; padding: 0.3rem 0.6rem; border: 1px solid var(--vw-info-line); border-radius: var(--vw-radius-small); background: var(--vw-info); color: var(--vw-quiet); font-size: var(--vw-small); }
|
||||||
|
.vw-fe-bedingung svg { width: 1rem; height: 1rem; flex: none; margin-top: 0.15rem; color: var(--vw-select-line); }
|
||||||
|
.vw-fe-bedingung.is-info { background: var(--vw-paper); border-color: var(--vw-line); }
|
||||||
|
.vw-fe-bereich > .vw-fe-bedingung { margin: 0.6rem 0.9rem 0 0.9rem; }
|
||||||
|
.vw-fe-teil > .vw-fe-bedingung { margin: 0.1rem 0.7rem 0.3rem 2.6rem; background: #fff; }
|
||||||
|
|
||||||
|
.vw-fe-anliegen .vw-fe-anliegen-text { display: grid; flex: 1 1 auto; min-width: 0; }
|
||||||
|
.vw-fe-anliegen .vw-fe-anliegen-text span { color: var(--vw-quiet); font-size: var(--vw-small); }
|
||||||
|
.vw-fe-anliegen { display: flex; align-items: center; gap: 0.5rem; background: var(--vw-paper); }
|
||||||
|
|
||||||
|
.vw-fe-teil { border: 1px solid #c8dbec; border-left: 5px solid var(--vw-select-line); border-radius: var(--vw-radius); background: #f3f8fc; }
|
||||||
|
.vw-fe-teil-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.5rem; padding: 0.5rem 0.6rem 0.4rem 0.3rem; }
|
||||||
|
.vw-fe-art { display: inline-flex; align-items: center; gap: 0.3rem; flex: none; color: var(--vw-select-line); font-size: var(--vw-small); font-weight: 700; }
|
||||||
|
.vw-fe-art svg { width: 1.15rem; height: 1.15rem; }
|
||||||
|
.vw-fe-teil-inhalt { position: relative; display: grid; gap: 0.5rem; padding: 0.2rem 0.7rem 0.7rem 1.4rem; min-height: 4.5rem; align-content: start; }
|
||||||
|
.vw-fe-teil .vw-fe-fuss { border-top: 0; padding: 0 0.7rem 0.7rem 1.4rem; }
|
||||||
|
.vw-fe-notiz { color: var(--vw-quiet); font-size: var(--vw-small); }
|
||||||
|
.vw-fe-teil > .vw-fe-notiz { margin: 0 0.7rem 0.4rem 2.6rem; }
|
||||||
|
.vw-fe-notiz.is-warnung { color: var(--vw-warn); font-weight: 600; }
|
||||||
|
|
||||||
|
.vw-fe-fuss { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.7rem 0.9rem; border-top: 1px dashed var(--vw-line-strong); }
|
||||||
|
.vw-fe-inhalt[data-leer]::before, .vw-fe-teil-inhalt[data-leer]::before {
|
||||||
|
content: attr(data-leer); display: grid; place-items: center; min-height: 3.5rem; padding: 0.5rem; border: 2px dashed var(--vw-line-strong); border-radius: var(--vw-radius-small);
|
||||||
|
color: var(--vw-muted); font-size: var(--vw-small); text-align: center; pointer-events: none;
|
||||||
|
}
|
||||||
|
.vw-fe-leer-bereich { padding: 1.5rem; border: 2px dashed var(--vw-line-strong); border-radius: var(--vw-radius); color: var(--vw-muted); text-align: center; }
|
||||||
|
.vw-fe-ende { display: flex; }
|
||||||
|
|
||||||
|
.vw-fe-geist { background: rgb(252 209 10 / 24%); outline: 2px dashed var(--vw-yellow); outline-offset: 2px; border-radius: var(--vw-radius-small); }
|
||||||
|
.vw-fe-geist > * { opacity: 0.5; }
|
||||||
|
.vw-fe-gezogen { box-shadow: 0 10px 28px rgb(3 37 81 / 22%); background: #fff; }
|
||||||
|
.vw-fe-gegriffen { cursor: grabbing; }
|
||||||
|
|
||||||
|
/* Dialog für Hilfetext, Auswahlwerte, Bedingung, weitere Einstellungen und Katalog */
|
||||||
|
.vw-fe-dialog { margin: auto; width: min(44rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); padding: 0; border: 0; border-radius: 0.75rem; background: var(--vw-surface); color: var(--vw-ink); box-shadow: 0 24px 60px rgb(3 37 81 / 30%); }
|
||||||
|
.vw-fe-dialog::backdrop { background: rgb(3 37 81 / 42%); }
|
||||||
|
.vw-fe-dialog-karte { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); }
|
||||||
|
.vw-fe-dialog-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem 0.6rem; }
|
||||||
|
.vw-fe-dialog-kopf h2 { font-size: 1.3rem; }
|
||||||
|
.vw-fe-dialog-inhalt { min-height: 0; overflow: auto; padding: 0.4rem 1.25rem 1rem; }
|
||||||
|
.vw-fe-dialog-fuss { display: flex; justify-content: flex-end; padding: 0.75rem 1.25rem 1rem; border-top: 1px solid var(--vw-line); }
|
||||||
|
.vw-fe-formular { display: grid; gap: 0.9rem; }
|
||||||
|
.vw-fe-etikett { display: grid; gap: 0.3rem; font-weight: 650; }
|
||||||
|
.vw-fe-werte { display: grid; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
|
||||||
|
.vw-fe-wert { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 0.3rem; align-items: center; }
|
||||||
|
.vw-fe-bed { display: grid; gap: 0.6rem; margin: 0; padding: 0.4rem 0.8rem 0.8rem; border: 1px solid var(--vw-line-strong); border-radius: var(--vw-radius-small); }
|
||||||
|
.vw-fe-bed.is-ungueltig { border-color: var(--vw-warn); background: var(--vw-warn-soft); }
|
||||||
|
.vw-fe-bed legend { padding: 0 0.3rem; font-weight: 700; }
|
||||||
|
.vw-fe-bed-zeile { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 0.5rem; align-items: end; }
|
||||||
|
.vw-fe-werteliste { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
||||||
|
.vw-fe-wahl { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.25rem; padding: 0.25rem 0.8rem; border: 1px solid var(--vw-line-strong); border-radius: 999px; background: #fff; cursor: pointer; }
|
||||||
|
.vw-fe-wahl:has(input:checked) { border-color: var(--vw-pine); background: var(--vw-pine-soft); color: var(--vw-pine-dark); font-weight: 650; }
|
||||||
|
.vw-fe-wahl input { accent-color: var(--vw-pine); }
|
||||||
|
.vw-fe-katalog { display: grid; gap: 0.3rem; max-height: 22rem; margin: 0; padding: 0; overflow: auto; list-style: none; }
|
||||||
|
.vw-fe-katalog-eintrag { display: grid; gap: 0.1rem; width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--vw-line); border-radius: var(--vw-radius-small); background: #fff; color: var(--vw-ink); font: inherit; text-align: left; cursor: pointer; }
|
||||||
|
.vw-fe-katalog-eintrag:hover { border-color: var(--vw-pine); background: var(--vw-pine-soft); }
|
||||||
|
.vw-fe-katalog-eintrag span { color: var(--vw-quiet); font-size: var(--vw-small); }
|
||||||
|
@media (max-width: 40rem) {
|
||||||
|
.vw-fe-bed-zeile { grid-template-columns: minmax(0, 1fr) auto; }
|
||||||
|
.vw-fe-bed-zeile > :nth-child(2) { grid-column: 1; }
|
||||||
|
.vw-fe-dialog { width: calc(100vw - 1rem); }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
<div class="mb-player player">
|
<div class="mb-player player">
|
||||||
@include('content.video', [
|
@include('content.video', [
|
||||||
'playback' => ['mode' => $entry['playback'] ?? 'file', 'url' => $entry['url']],
|
'playback' => ['mode' => $entry['playback'] ?? 'file', 'url' => $entry['url']],
|
||||||
'poster' => \App\Domain\Media\ThumbnailRef::url('member.thumbnail', 'element', $entry['version']->element->id, $entry['version']->element->thumbnail_path),
|
'poster' => \App\Domain\Media\ThumbnailRef::url('member.thumbnail', 'element', $entry['version']->element->id, $entry['version']->element->thumbnail_path, 'mittel', $entry['version']->element->updated_at),
|
||||||
])
|
])
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-actions">
|
<div class="mb-actions">
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<header class="mb-detail-head">
|
<header class="mb-detail-head">
|
||||||
<div class="mb-detail-visual">
|
<div class="mb-detail-visual">
|
||||||
@if ($picture)
|
@if ($picture)
|
||||||
<img src="{{ route('member.thumbnail', ['kind' => $picture['kind'], 'subject' => $picture['subject']]) }}" alt="{{ $picture['alt'] ?: '' }}">
|
<img src="{{ route('member.thumbnail', ['kind' => $picture['kind'], 'subject' => $picture['subject'], 'g' => 'mittel']) }}" alt="{{ $picture['alt'] ?: '' }}">
|
||||||
@else
|
@else
|
||||||
<span class="mb-card-placeholder" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.($is_module ? 'rectangle-stack' : 'squares-2x2')" /></span>
|
<span class="mb-card-placeholder" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.($is_module ? 'rectangle-stack' : 'squares-2x2')" /></span>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
])>
|
])>
|
||||||
@if ($item['imageUrl'])
|
@if ($item['imageUrl'])
|
||||||
<div class="card-media">
|
<div class="card-media">
|
||||||
<img class="card-image" src="{{ $item['imageUrl'] }}" alt="" loading="lazy" decoding="async">
|
<img class="card-image" src="{{ $item['imageUrl'] }}" @if (! empty($item['imageSrcset'])) srcset="{{ $item['imageSrcset'] }}" sizes="(min-width: 900px) 40vw, 100vw" @endif alt="" loading="lazy" decoding="async">
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%"
|
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%"
|
||||||
@if ($videoUrl !== null) data-hero-video data-clip-src="{{ $videoUrl }}" data-clip-title="{{ $videoTitle }}" @endif>
|
@if ($videoUrl !== null) data-hero-video data-clip-src="{{ $videoUrl }}" data-clip-title="{{ $videoTitle }}" @endif>
|
||||||
@if ($layout === 'photo-split' && $imageUrl)
|
@if ($layout === 'photo-split' && $imageUrl)
|
||||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
<img class="lf-hero__photo" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="100vw"@endif alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
||||||
@endif
|
@endif
|
||||||
@if ($videoUrl !== null)
|
@if ($videoUrl !== null)
|
||||||
<video class="lf-hero__video" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
<video class="lf-hero__video" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
@endif
|
@endif
|
||||||
@if ($imageUrl)
|
@if ($imageUrl)
|
||||||
<div class="lf-bt__media" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
<div class="lf-bt__media" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
||||||
<img class="lf-bt__image" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
<img class="lf-bt__image" src="{{ $imageUrl }}" @if (! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="100vw" @endif alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
||||||
@include('widgets.partials.card-clip')
|
@include('widgets.partials.card-clip')
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||||
@if ($imageUrl !== null || $libraryImage !== null)
|
@if ($imageUrl !== null || $libraryImage !== null)
|
||||||
<div class="lf-pc__visual" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
<div class="lf-pc__visual" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
||||||
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" @if ($imageUrl !== null && ! empty($imageSrcset)) srcset="{{ $imageSrcset }}" sizes="(min-width: 900px) 50vw, 100vw" @endif alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||||
@include('widgets.partials.card-clip')
|
@include('widgets.partials.card-clip')
|
||||||
@if ($show['kind'] && $subject->badge !== null && empty($bare))
|
@if ($show['kind'] && $subject->badge !== null && empty($bare))
|
||||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||||
|
|||||||
@@ -28,7 +28,13 @@
|
|||||||
use App\Http\Controllers\WebsiteMediaController;
|
use App\Http\Controllers\WebsiteMediaController;
|
||||||
use App\Http\Middleware\EnsureCheckoutOpen;
|
use App\Http\Middleware\EnsureCheckoutOpen;
|
||||||
use App\Http\Middleware\EnsureShopVisible;
|
use App\Http\Middleware\EnsureShopVisible;
|
||||||
|
use App\Http\Middleware\SanitizeIntendedUrl;
|
||||||
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||||
|
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||||
|
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
||||||
|
use Illuminate\Session\Middleware\StartSession;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||||
|
|
||||||
Route::get('/', [PageController::class, 'home'])->name('home');
|
Route::get('/', [PageController::class, 'home'])->name('home');
|
||||||
Route::get('/sitemap.xml', [PageController::class, 'sitemap'])->name('sitemap');
|
Route::get('/sitemap.xml', [PageController::class, 'sitemap'])->name('sitemap');
|
||||||
@@ -38,7 +44,19 @@
|
|||||||
Route::get('/pakete/{bundle}', [PublicCatalogController::class, 'package'])->whereNumber('bundle')->name('public.package');
|
Route::get('/pakete/{bundle}', [PublicCatalogController::class, 'package'])->whereNumber('bundle')->name('public.package');
|
||||||
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
||||||
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
||||||
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])->whereNumber('element')->name('website.media');
|
// Öffentliche Medien brauchen weder Sitzung noch Cookies: Ohne sie legt die Anfrage keine Sitzungszeile an, setzt kein Cookie
|
||||||
|
// und darf von Browsern und Zwischenspeichern behalten werden.
|
||||||
|
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])
|
||||||
|
->whereNumber('element')
|
||||||
|
->withoutMiddleware([
|
||||||
|
EncryptCookies::class,
|
||||||
|
AddQueuedCookiesToResponse::class,
|
||||||
|
StartSession::class,
|
||||||
|
ShareErrorsFromSession::class,
|
||||||
|
PreventRequestForgery::class,
|
||||||
|
SanitizeIntendedUrl::class,
|
||||||
|
])
|
||||||
|
->name('website.media');
|
||||||
|
|
||||||
// Schalter 1 (Shop sichtbar): Übersicht, Produktseiten und die Hinweisseite. Schalter 2 (Checkout offen): Warenkorb und
|
// Schalter 1 (Shop sichtbar): Übersicht, Produktseiten und die Hinweisseite. Schalter 2 (Checkout offen): Warenkorb und
|
||||||
// Kasse; ist der Shop nur sichtbar, führen sie auf die Hinweisseite (EnsureCheckoutOpen).
|
// Kasse; ist der Shop nur sichtbar, führen sie auf die Hinweisseite (EnsureCheckoutOpen).
|
||||||
|
|||||||
@@ -0,0 +1,353 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteIntake;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Filament\Support\MediaLibrary;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bildfassungen (docs/architektur/bildvarianten.md): klein, mittel und voll für die Verwaltung, Breiten für die Website,
|
||||||
|
* Auslieferung mit Zwischenspeicherung und Ausweichen auf die volle Datei.
|
||||||
|
*/
|
||||||
|
class BildvariantenTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Storage::fake('cms_incoming');
|
||||||
|
Storage::fake('media_derived');
|
||||||
|
Storage::fake('media_public');
|
||||||
|
Storage::fake('media_originals');
|
||||||
|
Cache::flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_variants_are_written_next_to_the_main_file_and_never_enlarged(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put('vorschau/element-1.jpg', $this->jpeg(2000, 1000));
|
||||||
|
|
||||||
|
$written = ImageVariants::generate($disk, 'vorschau/element-1.jpg');
|
||||||
|
|
||||||
|
$this->assertSame(['vorschau/element-1-klein.jpg', 'vorschau/element-1-mittel.jpg'], $written);
|
||||||
|
$this->assertSame([360, 180], array_slice(getimagesizefromstring($disk->get('vorschau/element-1-klein.jpg')), 0, 2));
|
||||||
|
$this->assertSame([960, 480], array_slice(getimagesizefromstring($disk->get('vorschau/element-1-mittel.jpg')), 0, 2));
|
||||||
|
$this->assertLessThan(strlen($disk->get('vorschau/element-1.jpg')), strlen($disk->get('vorschau/element-1-klein.jpg')));
|
||||||
|
|
||||||
|
$disk->put('vorschau/element-2.jpg', $this->jpeg(640, 320));
|
||||||
|
$this->assertSame(['vorschau/element-2-klein.jpg'], ImageVariants::generate($disk, 'vorschau/element-2.jpg'));
|
||||||
|
$disk->assertMissing('vorschau/element-2-mittel.jpg');
|
||||||
|
|
||||||
|
// Wird die Hauptdatei durch ein kleineres Bild ersetzt, verschwindet die zu große Fassung.
|
||||||
|
$disk->put('vorschau/element-1.jpg', $this->jpeg(300, 150));
|
||||||
|
ImageVariants::generate($disk, 'vorschau/element-1.jpg');
|
||||||
|
$disk->assertMissing('vorschau/element-1-klein.jpg');
|
||||||
|
$disk->assertMissing('vorschau/element-1-mittel.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_unreadable_files_produce_no_variants_and_no_error(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put('vorschau/kaputt.jpg', 'kein-bild');
|
||||||
|
|
||||||
|
$this->assertSame([], ImageVariants::generate($disk, 'vorschau/kaputt.jpg'));
|
||||||
|
$this->assertSame([], ImageVariants::generate($disk, 'vorschau/fehlt.jpg'));
|
||||||
|
$this->assertSame('vorschau/kaputt.jpg', ImageVariants::resolve($disk, 'vorschau/kaputt.jpg', 'klein'));
|
||||||
|
$this->assertSame('vorschau/kaputt.jpg', ImageVariants::resolve($disk, 'vorschau/kaputt.jpg', '../x'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_deriving_a_thumbnail_creates_the_variants_and_changes_the_version(): void
|
||||||
|
{
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', 'Park');
|
||||||
|
$version = app(ContentService::class)->publishElementVersion($element, null, ['file' => 'inhalte/park.jpg']);
|
||||||
|
Storage::disk('media_derived')->put('inhalte/park.jpg', $this->jpeg(3000, 1500));
|
||||||
|
$this->assertNotNull($version);
|
||||||
|
|
||||||
|
$before = now()->subDay();
|
||||||
|
ContentElement::query()->whereKey($element->id)->update(['updated_at' => $before]);
|
||||||
|
|
||||||
|
app(ThumbnailDeriver::class)->forElement($element->refresh());
|
||||||
|
$element->refresh();
|
||||||
|
|
||||||
|
$this->assertSame('vorschau/element-'.$element->id.'.jpg', $element->thumbnail_path);
|
||||||
|
$this->assertSame(2400, getimagesizefromstring(Storage::disk('media_derived')->get($element->thumbnail_path))[0]);
|
||||||
|
Storage::disk('media_derived')->assertExists('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
Storage::disk('media_derived')->assertExists('vorschau/element-'.$element->id.'-mittel.jpg');
|
||||||
|
$this->assertTrue($element->updated_at->greaterThan($before), 'Die Version der Adresse ändert sich mit dem Bild.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_library_card_serves_the_requested_size_with_a_fallback_and_caches_by_version(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
ImageVariants::generate($disk, $element->thumbnail_path);
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
|
||||||
|
$klein = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']));
|
||||||
|
$klein->assertOk();
|
||||||
|
$this->assertSame($disk->get('vorschau/element-'.$element->id.'-klein.jpg'), $klein->streamedContent());
|
||||||
|
$this->assertStringContainsString('must-revalidate', (string) $klein->headers->get('Cache-Control'));
|
||||||
|
$this->assertNotNull($klein->headers->get('ETag'));
|
||||||
|
|
||||||
|
$voll = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id]));
|
||||||
|
$this->assertSame($disk->get($element->thumbnail_path), $voll->streamedContent());
|
||||||
|
|
||||||
|
$versioned = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein', 'v' => 1700000000]));
|
||||||
|
$cache = (string) $versioned->headers->get('Cache-Control');
|
||||||
|
$this->assertStringContainsString('immutable', $cache);
|
||||||
|
$this->assertStringContainsString('private', $cache);
|
||||||
|
$this->assertStringContainsString('max-age=31536000', $cache);
|
||||||
|
|
||||||
|
$again = $this->actingAs($editor, 'staff')->get(
|
||||||
|
route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']),
|
||||||
|
['If-None-Match' => $klein->headers->get('ETag')],
|
||||||
|
);
|
||||||
|
$again->assertStatus(304);
|
||||||
|
|
||||||
|
$disk->delete('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
$fallback = $this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']));
|
||||||
|
$this->assertSame($disk->get($element->thumbnail_path), $fallback->streamedContent(), 'Ohne Fassung gilt die Hauptdatei.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_missing_variant_is_derived_by_the_queue_once_per_day(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
Queue::fake();
|
||||||
|
|
||||||
|
$url = route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']);
|
||||||
|
$this->actingAs($editor, 'staff')->get($url)->assertOk();
|
||||||
|
$this->actingAs($editor, 'staff')->get($url)->assertOk();
|
||||||
|
$this->actingAs($editor, 'staff')->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id]))->assertOk();
|
||||||
|
|
||||||
|
Queue::assertPushed(DeriveImageVariants::class, 1);
|
||||||
|
$disk->assertMissing('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_card_route_stays_closed_for_visitors_and_ignores_unknown_sizes(): void
|
||||||
|
{
|
||||||
|
[$element] = $this->elementWithThumbnail(800, 400);
|
||||||
|
|
||||||
|
$this->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => 'klein']))->assertRedirect();
|
||||||
|
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$this->actingAs($editor, 'staff')
|
||||||
|
->get(route('editorial.card', ['kind' => 'element', 'subject' => $element->id, 'g' => '../../etc']))
|
||||||
|
->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_adresses_carry_size_and_version(): void
|
||||||
|
{
|
||||||
|
[$element] = $this->elementWithThumbnail(800, 400);
|
||||||
|
$element->refresh();
|
||||||
|
$card = app(MediaLibrary::class)->cardFor($element, false);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('g=klein', (string) $card['image']);
|
||||||
|
$this->assertStringContainsString('v='.$element->updated_at->getTimestamp(), (string) $card['image']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_released_image_gets_website_widths_and_serves_them_with_long_caching_and_no_cookie(): void
|
||||||
|
{
|
||||||
|
$medium = $this->releasedImage('Lara im Park', 2600, 1300);
|
||||||
|
$path = $medium->website_public_path;
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->assertExists(ImageVariants::publicPath($path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
$presentation = app(WebsiteMedia::class)->present($medium);
|
||||||
|
$this->assertNotNull($presentation);
|
||||||
|
$this->assertStringContainsString('v='.$medium->website_released_at->getTimestamp(), $presentation->url);
|
||||||
|
$this->assertStringContainsString('w=640', (string) $presentation->srcset);
|
||||||
|
$this->assertStringContainsString('1920w', (string) $presentation->srcset);
|
||||||
|
$this->assertStringContainsString('w=1920', $presentation->urlForWidth(1920));
|
||||||
|
$this->assertSame($presentation->url, $presentation->urlForWidth(999));
|
||||||
|
|
||||||
|
$small = $this->get(route('website.media', ['element' => $medium, 'w' => 640, 'v' => $medium->website_released_at->getTimestamp()]));
|
||||||
|
$small->assertOk();
|
||||||
|
$this->assertSame(640, getimagesizefromstring($small->streamedContent())[0]);
|
||||||
|
$cache = (string) $small->headers->get('Cache-Control');
|
||||||
|
$this->assertStringContainsString('public', $cache);
|
||||||
|
$this->assertStringContainsString('immutable', $cache);
|
||||||
|
$this->assertEmpty($small->headers->getCookies(), 'Öffentliche Bilder setzen kein Cookie.');
|
||||||
|
|
||||||
|
$stale = $this->get(route('website.media', ['element' => $medium, 'v' => 1]));
|
||||||
|
$this->assertStringNotContainsString('immutable', (string) $stale->headers->get('Cache-Control'));
|
||||||
|
|
||||||
|
$full = $this->get(route('website.media', ['element' => $medium]));
|
||||||
|
$this->assertSame(2400, getimagesizefromstring($full->streamedContent())[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_released_image_without_widths_falls_back_to_the_full_file_and_asks_the_queue_once(): void
|
||||||
|
{
|
||||||
|
$medium = $this->releasedImage('Bestand', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->delete(ImageVariants::publicPath($medium->website_public_path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
Queue::fake();
|
||||||
|
|
||||||
|
$first = $this->get(route('website.media', ['element' => $medium, 'w' => 1280]));
|
||||||
|
$this->assertSame(2400, getimagesizefromstring($first->streamedContent())[0]);
|
||||||
|
$this->get(route('website.media', ['element' => $medium, 'w' => 640]))->assertOk();
|
||||||
|
|
||||||
|
Queue::assertPushed(DeriveWebsiteVariants::class, 1);
|
||||||
|
|
||||||
|
Queue::fake([]);
|
||||||
|
(new DeriveWebsiteVariants($medium->id))->handle();
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->assertExists(ImageVariants::publicPath($medium->website_public_path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->get(route('website.media', ['element' => $medium, 'w' => 4000]))->assertOk();
|
||||||
|
$this->get(route('website.media', ['element' => $medium, 'w' => '../x']))->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_withdrawing_a_release_removes_the_widths_too(): void
|
||||||
|
{
|
||||||
|
$medium = $this->releasedImage('Zurück', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
$widthUrl = route('website.media', ['element' => $medium, 'w' => 640]);
|
||||||
|
$this->get($widthUrl)->assertOk();
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($medium);
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->assertMissing('website/'.$medium->id.'/datei-'.$width.'.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
$public->assertMissing('website/'.$medium->id.'/datei.jpg');
|
||||||
|
$this->get($widthUrl)->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_images_with_transparency_formats_keep_no_widths(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_public');
|
||||||
|
$disk->put('website/9/datei.png', $this->jpeg(2600, 1300));
|
||||||
|
|
||||||
|
$this->assertSame([], ImageVariants::generatePublic($disk, $disk, 'website/9/datei.png', 'website/9/datei.png'));
|
||||||
|
$disk->assertMissing('website/9/datei-640.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_picker_options_do_not_query_per_entry(): void
|
||||||
|
{
|
||||||
|
foreach (range(1, 2) as $number) {
|
||||||
|
$this->releasedImage('Bild '.$number, 800, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::enableQueryLog();
|
||||||
|
app(WebsiteImage::class)->options();
|
||||||
|
$few = count(DB::getQueryLog());
|
||||||
|
|
||||||
|
foreach (range(3, 10) as $number) {
|
||||||
|
$this->releasedImage('Bild '.$number, 800, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::flushQueryLog();
|
||||||
|
$options = app(WebsiteImage::class)->options();
|
||||||
|
$many = count(DB::getQueryLog());
|
||||||
|
|
||||||
|
$this->assertCount(10, $options);
|
||||||
|
$this->assertSame($few, $many, 'Die Zahl der Abfragen wächst nicht mit der Zahl der Einträge.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_command_backfills_existing_images_through_the_queue(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
$medium = $this->releasedImage('Alt', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
foreach ([640, 1280, 1920] as $width) {
|
||||||
|
$public->delete(ImageVariants::publicPath($medium->website_public_path, $width));
|
||||||
|
}
|
||||||
|
|
||||||
|
$disk->assertMissing('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
|
||||||
|
Queue::fake();
|
||||||
|
$this->artisan('media:varianten')->assertSuccessful();
|
||||||
|
Queue::assertPushed(DeriveImageVariants::class, fn (DeriveImageVariants $job): bool => $job->path === $element->thumbnail_path);
|
||||||
|
Queue::assertPushed(DeriveWebsiteVariants::class, fn (DeriveWebsiteVariants $job): bool => $job->elementId === $medium->id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_command_can_backfill_at_once(): void
|
||||||
|
{
|
||||||
|
[$element, $disk] = $this->elementWithThumbnail(2000, 1000);
|
||||||
|
$medium = $this->releasedImage('Alt', 2600, 1300);
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
$public->delete(ImageVariants::publicPath($medium->website_public_path, 640));
|
||||||
|
|
||||||
|
$this->artisan('media:varianten', ['--now' => true])->assertSuccessful();
|
||||||
|
|
||||||
|
$disk->assertExists('vorschau/element-'.$element->id.'-klein.jpg');
|
||||||
|
$public->assertExists(ImageVariants::publicPath($medium->website_public_path, 640));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_derive_job_refuses_foreign_paths(): void
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put('inhalte/geheim.jpg', $this->jpeg(2000, 1000));
|
||||||
|
|
||||||
|
(new DeriveImageVariants('inhalte/geheim.jpg'))->handle();
|
||||||
|
(new DeriveImageVariants('vorschau/../inhalte/geheim.jpg'))->handle();
|
||||||
|
|
||||||
|
$disk->assertMissing('inhalte/geheim-klein.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{0: ContentElement, 1: Filesystem}
|
||||||
|
*/
|
||||||
|
private function elementWithThumbnail(int $width, int $height): array
|
||||||
|
{
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', 'Bild '.Str::random(4));
|
||||||
|
$element->forceFill(['thumbnail_path' => 'vorschau/element-'.$element->id.'.jpg'])->save();
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$disk->put($element->thumbnail_path, $this->jpeg($width, $height));
|
||||||
|
|
||||||
|
return [$element->refresh(), $disk];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function releasedImage(string $title, int $width, int $height): ContentElement
|
||||||
|
{
|
||||||
|
$path = 'cms/'.Str::slug($title).'-'.Str::lower(Str::random(4)).'.jpg';
|
||||||
|
Storage::disk('cms_incoming')->put($path, $this->jpeg($width, $height));
|
||||||
|
|
||||||
|
$element = app(WebsiteIntake::class)->acceptImage($path, $title, 'Foto: Lara und Felix', $title)->refresh();
|
||||||
|
$this->assertNotNull($element->website_released_at, 'Das Bild ist freigegeben.');
|
||||||
|
|
||||||
|
return $element;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function jpeg(int $width, int $height): string
|
||||||
|
{
|
||||||
|
$image = imagecreatetruecolor($width, $height);
|
||||||
|
imagefill($image, 0, 0, (int) imagecolorallocate($image, 200, 120, 40));
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($image);
|
||||||
|
|
||||||
|
return (string) ob_get_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,7 +80,7 @@ public function test_the_trailer_lies_over_the_card_image_when_there_is_one(): v
|
|||||||
$this->publish('/trailer-bild', [$this->mediaCard($film, ['image' => $image->id])]);
|
$this->publish('/trailer-bild', [$this->mediaCard($film, ['image' => $image->id])]);
|
||||||
|
|
||||||
$card = $this->card($this->get('/trailer-bild')->assertOk()->getContent());
|
$card = $this->card($this->get('/trailer-bild')->assertOk()->getContent());
|
||||||
$this->assertStringContainsString('<img class="lf-pc__image" src="'.route('website.media', $image).'"', $card);
|
$this->assertStringContainsString('<img class="lf-pc__image" src="'.app(WebsiteMedia::class)->present($image->id)->url.'"', $card);
|
||||||
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||||
$this->assertStringNotContainsString('lf-pc__visual--panel', $card);
|
$this->assertStringNotContainsString('lf-pc__visual--panel', $card);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ public function test_an_image_can_stand_alone_without_any_text(): void
|
|||||||
|
|
||||||
$this->assertStringContainsString('lf-bt--without-text', $html);
|
$this->assertStringContainsString('lf-bt--without-text', $html);
|
||||||
$this->assertStringNotContainsString('lf-bt__copy', $html, 'Ohne Text gibt es keine leere Textspalte.');
|
$this->assertStringNotContainsString('lf-bt__copy', $html, 'Ohne Text gibt es keine leere Textspalte.');
|
||||||
$this->assertStringContainsString('<img class="lf-bt__image" src="'.route('website.media', $image).'" alt="Gruppe im Park"', $html);
|
$this->assertStringContainsString('<img class="lf-bt__image" src="'.app(WebsiteMedia::class)->present($image->id)->url.'"', $html);
|
||||||
|
$this->assertStringContainsString('alt="Gruppe im Park"', $html);
|
||||||
|
$this->assertStringContainsString('srcset="', $html);
|
||||||
|
|
||||||
$normalized = app(WidgetRegistry::class)->normalize($this->widget([], ['image' => $image->id])[0]['slots']);
|
$normalized = app(WidgetRegistry::class)->normalize($this->widget([], ['image' => $image->id])[0]['slots']);
|
||||||
$this->assertSame($image->id, $normalized[0]['refs']['image']);
|
$this->assertSame($image->id, $normalized[0]['refs']['image']);
|
||||||
|
|||||||