From 374fd95576d11381d9c8c47b847f8d3780fb143b Mon Sep 17 00:00:00 2001 From: Lars Date: Fri, 27 Nov 2026 22:55:40 +0100 Subject: [PATCH] Zeige das Widget Anfrage in der Vorschau des Seiteneditors und gib der Fassungsliste deutsche Texte Co-Authored-By: Claude Sonnet 5.5 --- .../VersionsRelationManager.php | 3 +++ app/Filament/Support/TemplateEditor.php | 5 ++--- resources/css/components/lf-anfrage.css | 20 +++++++++++++++++++ resources/js/inquiry-embed.js | 6 ++++++ resources/js/inquiry-widget.js | 20 +++++++++++++++++++ resources/views/widgets/inquiry.blade.php | 4 ++++ vite.config.js | 2 +- 7 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 resources/js/inquiry-embed.js diff --git a/app/Filament/Resources/Communication/Templates/RelationManagers/VersionsRelationManager.php b/app/Filament/Resources/Communication/Templates/RelationManagers/VersionsRelationManager.php index fe20b15..15a038c 100644 --- a/app/Filament/Resources/Communication/Templates/RelationManagers/VersionsRelationManager.php +++ b/app/Filament/Resources/Communication/Templates/RelationManagers/VersionsRelationManager.php @@ -33,6 +33,9 @@ public function table(Table $table): Table $template = $this->getOwnerRecord(); return $table + ->heading('Fassungen') + ->emptyStateHeading('Noch keine Fassung veröffentlicht') + ->emptyStateDescription('Mit „Veröffentlichen“ entsteht die erste Fassung.') ->columns([ TextColumn::make('version')->label('Fassung')->prefix('Nr. '), TextColumn::make('published_at')->label('Veröffentlicht')->dateTime('d.m.Y H:i'), diff --git a/app/Filament/Support/TemplateEditor.php b/app/Filament/Support/TemplateEditor.php index 9399df4..0f825ea 100644 --- a/app/Filament/Support/TemplateEditor.php +++ b/app/Filament/Support/TemplateEditor.php @@ -80,7 +80,6 @@ private static function structure(): array ->blockNumbers(false) ->reorderableWithButtons() ->collapsible() - ->collapsed() ->live(), ]) ->reorderableWithButtons() @@ -98,7 +97,7 @@ private static function blocks(): array { return [ Block::make('field') - ->label(fn (?array $state): string => 'Feld: '.(($state['label'] ?? '') ?: 'neu').self::fieldBadges($state)) + ->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()), @@ -149,7 +148,7 @@ private static function blocks(): array self::condition('field'), ]), Block::make('section') - ->label(fn (?array $state): string => 'Teilbereich: '.(($state['label'] ?? '') ?: 'neu').(filled($state['cond']['effect'] ?? null) ? ' (Bedingung)' : '')) + ->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()), diff --git a/resources/css/components/lf-anfrage.css b/resources/css/components/lf-anfrage.css index 828873a..9853f11 100644 --- a/resources/css/components/lf-anfrage.css +++ b/resources/css/components/lf-anfrage.css @@ -740,3 +740,23 @@ @media (prefers-reduced-motion: reduce) { transition: none !important; } } + +/* Vorschau im Seiteneditor: der geöffnete Dialog als gerahmtes Beispiel statt als Dialog über der Seite. */ +.iw-sample-note { + margin: var(--space-3) 0 var(--space-2); + font-size: 0.9em; + color: var(--color-text-muted); +} + +.iw-dialog--sample { + display: flex; + flex-direction: column; + width: auto; + max-height: none; + border: 2px dashed var(--color-border-strong); + box-shadow: none; +} + +.iw-dialog--sample .iw-body { + overflow: visible; +} diff --git a/resources/js/inquiry-embed.js b/resources/js/inquiry-embed.js new file mode 100644 index 0000000..7786fe9 --- /dev/null +++ b/resources/js/inquiry-embed.js @@ -0,0 +1,6 @@ +/* + * Einstieg für Vorschauen, die nur Stile laden (Iframes im Seiteneditor): bringt das Anfrageformular und das Widget + * „Anfrage“ zum Laufen. Die öffentliche Seite und die Seitenvorschau laden dasselbe über app.js. + */ +import './inquiry-form.js'; +import './inquiry-widget.js'; diff --git a/resources/js/inquiry-widget.js b/resources/js/inquiry-widget.js index a902d4a..c38b0d6 100644 --- a/resources/js/inquiry-widget.js +++ b/resources/js/inquiry-widget.js @@ -50,6 +50,10 @@ class InquiryWidget { this.active = null; this.sent = false; this.modal = this.config.open === 'modal'; + // In den Vorschau-Iframes des Seiteneditors (srcdoc, kleine feste Fläche) ist ein echter Dialog nicht darstellbar: + // Dort steht der geöffnete Dialog als gerahmtes Beispiel unter dem Button. Auf der Seite und in der Seitenvorschau + // öffnet der Button den echten Dialog. + this.sample = this.modal && this.config.preview && Boolean(window.frameElement?.hasAttribute?.('srcdoc')); } start() { @@ -64,6 +68,10 @@ class InquiryWidget { this.choose(preselected.key, false); } + if (this.sample) { + return; + } + if (this.modal) { // Ein Button der Seite mit ?grund=… will den Dialog sofort sehen; ohne Vorwahl öffnet der Besucher selbst. if (preselected) { @@ -93,6 +101,18 @@ class InquiryWidget { } this.root.classList.add('is-modal'); + + if (this.sample) { + this.opener = h('button', { type: 'button', class: 'button iw-opener', text: this.config.openLabel }); + this.root.append( + this.opener, + h('p', { class: 'iw-sample-note', text: 'Vorschau: So sieht der geöffnete Dialog aus.' }), + h('div', { class: 'iw-dialog iw-dialog--sample', role: 'group', 'aria-label': this.config.openLabel }, h('div', { class: 'iw-dialog-head' }, h('span', { class: 'iw-close', 'aria-hidden': 'true' }, '×')), this.body), + ); + + return; + } + this.opener = h('button', { type: 'button', class: 'button iw-opener', diff --git a/resources/views/widgets/inquiry.blade.php b/resources/views/widgets/inquiry.blade.php index bdab325..0c65808 100644 --- a/resources/views/widgets/inquiry.blade.php +++ b/resources/views/widgets/inquiry.blade.php @@ -39,3 +39,7 @@

@endif @endif +@if ($context->preview) + {{-- Vorschau-Iframes im Seiteneditor laden nur Stile: Das Skript lässt das Formular dort wie auf der Seite erscheinen. --}} + @vite('resources/js/inquiry-embed.js') +@endif diff --git a/vite.config.js b/vite.config.js index 9270b47..2fe327e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -6,7 +6,7 @@ import tailwindcss from '@tailwindcss/vite'; export default defineConfig({ plugins: [ laravel({ - input: ['resources/css/app.css', 'resources/js/app.js'], + input: ['resources/css/app.css', 'resources/js/app.js', 'resources/js/inquiry-embed.js'], refresh: true, fonts: [ // Vorläufige Markenschriften (Website-Zielkonzept 7.2, nicht freigegeben); beim Build lokal abgelegt.