MVP 1.0 (ohne Shop) #1

Merged
Lars merged 149 commits from develop into main 2026-11-20 21:58:42 +01:00
3 changed files with 79 additions and 7 deletions
Showing only changes of commit 77ebb0c1d5 - Show all commits

No files matched your search

+57 -4
View File
@@ -2,10 +2,12 @@
namespace App\Filament\Support;
use App\Domain\Cms\Sections\SectionLayouts;
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\WidgetRegistry;
use App\Domain\Cms\Widgets\WidgetRenderer;
use App\Domain\Cms\Widgets\WidgetType;
use Filament\Actions\Action;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Builder\Block;
use Filament\Forms\Components\Hidden;
@@ -20,6 +22,7 @@
use Filament\Schemas\Components\Text;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\View;
use Filament\Support\Enums\Width;
use Illuminate\Foundation\Vite;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
@@ -82,8 +85,23 @@ public static function slotBuilder(string $name = 'widget'): Builder
->deletable()
->collapsible(false)
->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus'))
->editAction(fn ($action) => $action->modalHeading('Widget bearbeiten')->modalWidth('4xl')->modalSubmitActionLabel('Übernehmen')->tooltip('Widget bearbeiten'))
->deleteAction(fn ($action) => $action->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
// Baustein konfigurieren (Dokument 12, CMS-R03/R11): großer Kontext mit Vorschau. „Zur Seite“ übernimmt die
// Eingaben in den Seitenentwurf; Verwerfen ist eine ausdrückliche Handlung, Esc und Klick daneben verwerfen
// nichts still. Eine Bearbeitung direkt in der Seite war gemessen deutlich langsamer (Abnahme Teil C).
->editAction(fn (Action $action) => $action
->label('Konfigurieren')
->icon('heroicon-o-adjustments-horizontal')
->button()
->size('sm')
->color('gray')
->modalHeading(fn (Builder $component, array $arguments): string => self::configureHeading($component, (string) ($arguments['item'] ?? '')))
->modalDescription('Inhalt, Medien und Darstellung dieses Bausteins. „Zur Seite“ übernimmt die Eingaben in den Seitenentwurf; gespeichert wird über „Entwurf speichern“.')
->modalWidth(Width::Screen)
->modalSubmitActionLabel('Zur Seite')
->modalCancelActionLabel('Änderungen verwerfen')
->closeModalByClickingAway(false)
->closeModalByEscaping(false))
->deleteAction(fn ($action) => $action->label('Entfernen')->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
->columnSpanFull();
}
@@ -146,11 +164,14 @@ public static function block(WidgetType $type): Block
]);
}
// Auf breiten Schirmen stehen Inhalt/Medien/Darstellung und die Bausteinvorschau nebeneinander.
$schema = [
Hidden::make('id'),
...$variantField,
Tabs::make('Widget')->tabs($tabs)->contained(false),
self::livePreview($type),
Grid::make(['default' => 1, 'xl' => 5])->schema([
Tabs::make('Widget')->tabs($tabs)->contained(false)->columnSpan(['default' => 1, 'xl' => 3]),
self::livePreview($type)->columnSpan(['default' => 1, 'xl' => 2]),
]),
];
}
@@ -167,6 +188,35 @@ public static function block(WidgetType $type): Block
->preview('filament.cms.widget-preview');
}
/**
* „Programmkarte konfigurieren · Abschnitt 2 · Platz 2 · 1 Einheit“ aus dem Zustandspfad des Platzes.
*/
public static function configureHeading(Builder $component, string $itemKey): string
{
$registry = app(WidgetRegistry::class);
$type = $component->getRawState()[$itemKey]['type'] ?? null;
$heading = ($registry->has($type) ? $registry->get($type)->label() : 'Baustein').' konfigurieren';
if (preg_match('/sections\.([^.]+)\.slots\.([^.]+)\.widget$/', (string) $component->getStatePath(), $match) !== 1) {
return $heading;
}
$sections = $component->getLivewire()->data['sections'] ?? [];
$sectionIndex = array_search($match[1], array_map('strval', array_keys(is_array($sections) ? $sections : [])), true);
$slots = is_array($sections[$match[1]]['slots'] ?? null) ? $sections[$match[1]]['slots'] : [];
$slotIndex = array_search($match[2], array_map('strval', array_keys($slots)), true);
if ($sectionIndex === false || $slotIndex === false) {
return $heading;
}
$layout = $sections[$match[1]]['layout'] ?? SectionLayouts::DEFAULT;
$units = SectionLayouts::units(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT)[$slotIndex] ?? null;
return $heading.' · Abschnitt '.($sectionIndex + 1).' · Platz '.($slotIndex + 1)
.($units !== null ? ' · '.$units.' '.($units === 1 ? 'Einheit' : 'Einheiten') : '');
}
/**
* Gespeicherte Bausteine (Altformat oder Hülle) als Builder-Zustand.
*
@@ -305,6 +355,9 @@ private static function livePreview(WidgetType $type): Section
->hiddenLabel()
->options($widths)
->default($default)
// Beim Bearbeiten fehlt der Wert (er wird nicht gespeichert); ohne ihn zeigte die Vorschau die
// Vorgabe, ohne dass ein Knopf als gewählt markiert war.
->afterStateHydrated(fn (ToggleButtons $component, mixed $state) => filled($state) ? null : $component->state($default))
->inline()
->live()
->dehydrated(false)
@@ -460,9 +460,10 @@
.vw-bestand-ansicht { margin-left: 0; }
}
/* Gefüllte Filament-Hauptknöpfe (Seitenkopf, Formularfuß) wie .vw-btn.is-primary */
/* Nur Knöpfe und Links; Auswahlfelder (ToggleButtons sind <label>) behalten Filaments Gewählt/Nicht-gewählt-Darstellung. */
:is(button, a).fi-btn.fi-color-primary:not(.fi-outlined) { background: var(--vw-pine); color: #fff; }
:is(button, a).fi-btn.fi-color-primary:not(.fi-outlined):hover { background: var(--vw-pine-dark); color: #fff; }
/* Nur Aktionsknöpfe in Seitenkopf, Dialogfuß und Aktionsleisten. Auswahlfelder und Knopfgruppen in Formularen
(z. B. Raster, Darstellung, Vorschaubreite) behalten Filaments Gewählt/Nicht-gewählt-Darstellung. */
:is(.fi-header, .fi-modal-footer, .fi-sc-actions) :is(button, a).fi-btn.fi-color-primary:not(.fi-outlined) { background: var(--vw-pine); color: #fff; }
:is(.fi-header, .fi-modal-footer, .fi-sc-actions) :is(button, a).fi-btn.fi-color-primary:not(.fi-outlined):hover { background: var(--vw-pine-dark); color: #fff; }
@container (max-width: 52rem) {
.vw-zeile { grid-template-columns: 1.5rem var(--vw-thumb-small) minmax(0, 1fr); grid-template-areas: "griff bild text" "griff aktionen aktionen"; }
+18
View File
@@ -6,6 +6,7 @@
use App\Filament\Resources\Pages\Pages\CreatePage;
use App\Filament\Resources\Pages\Pages\EditPage;
use App\Models\User;
use Filament\Actions\Testing\TestAction;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
@@ -127,6 +128,23 @@ public function test_the_create_form_keeps_raster_and_design_in_every_section():
->assertDontSee('Zur Seite');
}
public function test_configuring_a_block_names_it_and_its_place_and_returns_to_the_page(): void
{
$page = Page::query()->where('path', '/praevention')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$sectionKey = array_key_first($component->get('data.sections'));
$slotKey = array_key_first($component->get("data.sections.$sectionKey.slots"));
$widgetKey = array_key_first($component->get("data.sections.$sectionKey.slots.$slotKey.widget"));
$edit = TestAction::make('edit')->schemaComponent("sections.$sectionKey.slots.$slotKey.widget")->arguments(['item' => $widgetKey]);
$component->assertSee('Konfigurieren')->mountAction($edit);
$action = $component->instance()->getMountedAction();
$this->assertSame('Überschrift und Einleitung konfigurieren · Abschnitt 1 · Platz 1 · 4 Einheiten', $action->getModalHeading());
$this->assertSame('Zur Seite', $action->getModalSubmitActionLabel());
$this->assertFalse($action->isModalClosedByEscaping());
$this->assertFalse($action->isModalClosedByClickingAway());
}
private function editor(): User
{
$editor = User::factory()->redakteur()->create();