Merge feature/prozess-konfigurator: visueller Prozesskonfigurator mit fachlichen Prozessblöcken
Deploy FeWo mit PipelineManager / deploy (push) Successful in 6m52s

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
LarsandClaude committed 2026-11-14 17:25:16 +01:00
commit 86965d6d45
9 files changed
+773 -185

No files matched your search

@@ -20,6 +20,7 @@
use App\Process\ChannelProcessConfiguration;
use App\Process\ConfigurationImpact;
use App\Process\Models\ProcessModel;
use App\Process\ProcessBlocks;
use App\Process\ProcessCatalogue;
use App\Process\ProcessLanes;
use App\Process\ProcessProfile;
@@ -27,6 +28,7 @@
use App\Process\Restriction;
use App\Process\Templates\FunctionTemplate;
use App\Process\Templates\TemplateArea;
use App\Process\Templates\TemplateComposer;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
@@ -62,30 +64,90 @@ class ChannelProcess extends Page
/** The landlord confirmed that stored settings the chosen model overrides are removed. */
public bool $acknowledge = false;
/** The business block opened in the detail panel ('' = none). */
public string $block = '';
public function mount(int|string $record): void
{
$this->record = $this->resolveRecord($record);
$configuration = app(ChannelProcessConfiguration::class);
foreach ($configuration->intakes($this->record) as $intake) {
$current = $configuration->current($this->record, $intake);
$stored = (array) (($this->record->process_overrides ?? [])[$intake->value] ?? []);
// The current (saved or derived) model stays selected even if it is not admissible: the page explains why instead of
// switching silently to another one.
$model = $current['model'];
$this->drafts[$intake->value] = [
'model' => $model,
'variant' => $current['variant'],
'steps' => (array) ($stored['steps'] ?? []),
'templates' => (array) ($stored['templates'] ?? []),
'settings' => array_map(fn (mixed $value): mixed => is_bool($value) ? ($value ? '1' : '0') : $value, array_intersect_key($stored, array_flip(array_map(fn (ProcessSetting $setting): string => $setting->value, ProcessSetting::cases())))),
'derived' => $current['derived'],
];
$this->drafts[$intake->value] = $this->storedDraft($intake);
}
$this->intake = (string) array_key_first($this->drafts);
$this->capabilityDraft = $this->record->isWebsite() ? [] : collect(app(ChannelCapabilities::class)->resolve($this->record))
$this->block = '';
$this->capabilityDraft = $this->storedCapabilities();
}
/**
* The draft as it is stored (or derived) now – the reference for "unsaved changes" and for discarding them.
* The current (saved or derived) model stays selected even if it is not admissible: the page explains why instead of
* switching silently to another one.
*
* @return array<string, mixed>
*/
private function storedDraft(IntakeKind $intake): array
{
$current = app(ChannelProcessConfiguration::class)->current($this->record, $intake);
$stored = (array) (($this->record->process_overrides ?? [])[$intake->value] ?? []);
return [
'model' => $current['model'],
'variant' => $current['variant'],
'steps' => (array) ($stored['steps'] ?? []),
'templates' => (array) ($stored['templates'] ?? []),
'settings' => array_map(fn (mixed $value): mixed => is_bool($value) ? ($value ? '1' : '0') : $value, array_intersect_key($stored, array_flip(array_map(fn (ProcessSetting $setting): string => $setting->value, ProcessSetting::cases())))),
'derived' => $current['derived'],
];
}
/**
* @return array<string, string>
*/
private function storedCapabilities(): array
{
return $this->record->isWebsite() ? [] : collect(app(ChannelCapabilities::class)->resolve($this->record))
->map(fn (Capability $capability): string => $capability->value === null ? '' : ($capability->value ? '1' : '0'))->all();
}
/**
* Whether the draft of the current intake kind differs from what is stored (nothing is saved by looking or selecting).
*/
public function dirty(): bool
{
$normalise = fn (array $draft): array => [
'model' => $draft['model'],
'variant' => $draft['variant'],
'steps' => array_filter((array) $draft['steps']),
'templates' => (array) $draft['templates'],
'settings' => array_filter((array) $draft['settings'], fn (mixed $value): bool => $value !== null && $value !== ''),
];
return $normalise($this->drafts[$this->intake]) != $normalise($this->storedDraft(IntakeKind::from($this->intake)))
|| $this->capabilityDraft != $this->storedCapabilities();
}
/**
* Throws the unsaved changes away and shows the stored configuration again.
*/
public function discard(): void
{
$intake = $this->intake;
$this->acknowledge = false;
$this->mount($this->record->getKey());
$this->intake = $intake;
}
public function selectBlock(string $block): void
{
$this->block = $this->block === $block ? '' : $block;
}
public function updatedIntake(): void
{
$this->block = '';
}
/**
* The draft of the current intake kind including the capabilities shown (they decide which models fit).
*
@@ -338,6 +400,74 @@ public function profile(): ProcessProfile
return app(ChannelProcessConfiguration::class)->profileWith($this->record, IntakeKind::from($this->intake), $this->draft());
}
/**
* The business blocks of the course with what is effective in each: values and their origin, the template chosen for
* its decision, what depends on what (derived from the resolved plan, see {@see ProcessBlocks}), the steps that can
* be configured here and the fixed ones (no controls, shown as one line), gaps the template names, open problems.
*
* @return array<string, array<string, mixed>>
*/
public function blocks(): array
{
$intake = IntakeKind::from($this->intake);
$configuration = app(ChannelProcessConfiguration::class);
$profile = $this->profile();
$model = $this->model();
$rows = $configuration->preview($this->record, $intake, $this->draft());
$templates = app(TemplateComposer::class)->classes($configuration->templatesOf($model, $this->draft()));
$steps = collect($this->steps())->keyBy('module');
$conflicts = collect($this->conflicts())->map(fn (array $conflict): string => $conflict['setting']->value)->all();
$problems = $this->problems();
$blocks = [];
foreach (app(ProcessBlocks::class)->of($rows) as $key => $block) {
$template = $block['area'] === null ? null : ($templates[$block['area']->value] ?? null);
$settings = array_values(array_filter($block['settings'], fn (ProcessSetting $setting): bool => in_array($intake, $setting->channelIntakes(), true)));
$blockSteps = array_values(array_filter(array_map(fn (array $row): ?array => $steps[$row['module']] ?? null, $block['modules'])));
$configurable = array_values(array_filter($blockSteps, fn (array $step): bool => $step['on'] && ($step['optional'] || $step['mode_setting'] || ($step['performer_setting'] && count($step['performer_options']) > 1) || $step['parameters'] !== [])
|| (! $step['on'] && $step['optional'])));
$fixed = array_values(array_filter($blockSteps, fn (array $step): bool => $step['on'] && ! in_array($step, $configurable, true)));
$blocks[$key] = [...$block,
'facts' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $settings),
'template' => $template,
'extensions' => $template === null ? [] : $template::extensions(),
'configurable' => $configurable,
'fixed' => $fixed,
'off' => array_values(array_filter($blockSteps, fn (array $step): bool => ! $step['on'])),
'attention' => count(array_filter($settings, fn (ProcessSetting $setting): bool => in_array($setting->value, $conflicts, true))),
'problems' => $this->blockProblems($problems, $block['label'], $template, $settings),
];
}
return $blocks;
}
/**
* The problems of the draft that concern a block: they name its template or one of its settings.
*
* @param list<string> $problems
* @param class-string<FunctionTemplate>|null $template
* @param list<ProcessSetting> $settings
* @return list<string>
*/
private function blockProblems(array $problems, string $label, ?string $template, array $settings): array
{
return array_values(array_filter($problems, fn (string $problem): bool => ($template !== null && str_contains($problem, $template::label()))
|| collect($settings)->contains(fn (ProcessSetting $setting): bool => str_contains($problem, $setting->question()))));
}
/**
* Problems of the draft that belong to no block (shown above the blocks).
*
* @return list<string>
*/
public function problemsOutsideBlocks(): array
{
$inBlocks = collect($this->blocks())->flatMap(fn (array $block): array => $block['problems'])->all();
return array_values(array_diff($this->problems(), $inBlocks));
}
/**
* The step cards: preview row + controls of each step.
*
+125
View File
@@ -0,0 +1,125 @@
<?php
namespace App\Process;
use App\Enums\ProcessSetting;
use App\Process\Modules\ModuleDefinition;
use App\Process\Templates\TemplateArea;
/**
* The business blocks of a resolved course (docs/Prozessarchitektur P01–P05) as the configurator's main view shows them:
* a grouping of modules for the reader, nothing more. What a block depends on is derived from the hard and soft
* dependencies of the modules that are really in the plan and apply (the facts the {@see ProcessRunner} uses, the same
* as {@see ProcessLanes}) – there is no hand-written order between blocks and no arrow between merely adjacent phases.
* Pure: it reads, it never changes anything.
*/
final class ProcessBlocks
{
/**
* Grouping of the modules and the settings a block reports. A module that is in no block would show up under "other",
* so a new module is never lost (a test keeps the catalogue and this table in step).
*
* @var array<string, array{label: string, phase: string, area: ?TemplateArea, modules: list<string>, settings: list<ProcessSetting>}>
*/
public const BLOCKS = [
'intake' => ['label' => 'Eingang und Gastdaten', 'phase' => 'P01', 'area' => null,
'modules' => ['intake.record', 'guest.details', 'guest.data_request', 'guest.address_check', 'guest.loyalty_status', 'pricing.loyalty_discount'],
'settings' => [ProcessSetting::FormRequiresAddress, ProcessSetting::DataRequest, ProcessSetting::DataRequestReminderHours]],
'availability' => ['label' => 'Verfügbarkeit und Reservierung', 'phase' => 'P01', 'area' => null,
'modules' => ['availability.check', 'hold', 'binding.portal', 'channels.block'],
'settings' => [ProcessSetting::PreReservation, ProcessSetting::HoldHours, ProcessSetting::ClarificationHoldAutoMinutes]],
'answer' => ['label' => 'Antwort und Angebot', 'phase' => 'P02', 'area' => TemplateArea::InquiryAnswer,
'modules' => ['offer.information', 'offer.binding', 'offer.acceptance'],
'settings' => [ProcessSetting::InquiryAnswer, ProcessSetting::Processing, ProcessSetting::GuestLinkValidDays]],
'portal_wait' => ['label' => 'Bestätigung des Portals', 'phase' => 'P02', 'area' => null,
'modules' => ['portal.confirmation'],
'settings' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
'documents' => ['label' => 'Dokumentation', 'phase' => 'P03', 'area' => TemplateArea::ContractDocuments,
'modules' => ['documents.send', 'documents.booking_notice', 'documents.stay_confirmation'],
'settings' => [ProcessSetting::Documents, ProcessSetting::ContractDelivery, ProcessSetting::BookingNotice, ProcessSetting::ContractTemplate]],
'finance' => ['label' => 'Finanzabwicklung', 'phase' => 'P03', 'area' => TemplateArea::Collection,
'modules' => ['payments.monitor', 'payments.internal', 'portal.payout'],
'settings' => [ProcessSetting::Payments]],
'communication' => ['label' => 'Gastkommunikation und Aufenthalt', 'phase' => 'P04', 'area' => TemplateArea::GuestCommunication,
'modules' => ['arrival.details', 'arrival.info', 'stay', 'review.request'],
'settings' => [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ReviewRequestSender]],
'closure' => ['label' => 'Aufgaben und Abschluss', 'phase' => 'P05', 'area' => null,
'modules' => ['case.tasks', 'change.proposal', 'case.closure', 'case.settlement'],
'settings' => []],
];
public const OTHER = 'other';
public function __construct(private ProcessCatalogue $catalogue) {}
/**
* The blocks of the course the preview rows describe. A block without a step in the plan is left out.
*
* @param list<array{module: string, label: string, on: bool, reason: ?string, template: ?string}> $rows ChannelProcessConfiguration::preview
* @return array<string, array{key: string, label: string, phase: string, area: ?TemplateArea, settings: list<ProcessSetting>, modules: list<array{module: string, label: string, on: bool, reason: ?string, template: ?string}>, active: bool, waits_for: list<array{block: string, label: string, steps: list<string>}>, after: list<array{block: string, label: string}>, independent: bool, events: list<string>, scheduled: list<string>, conditional: list<array{label: string, reason: ?string}>, may_wait: list<string>}>
*/
public function of(array $rows): array
{
$blockOf = [];
foreach (self::BLOCKS as $key => $block) {
foreach ($block['modules'] as $module) {
$blockOf[$module] = $key;
}
}
$other = ['label' => 'Weitere Schritte', 'phase' => 'P03', 'area' => null, 'modules' => [], 'settings' => []];
$blocks = [];
foreach ($rows as $row) {
$key = $blockOf[$row['module']] ?? self::OTHER;
$blocks[$key] ??= [...(self::BLOCKS[$key] ?? $other), 'key' => $key, 'modules' => []];
$blocks[$key]['modules'][] = $row;
}
// Presentation order is the table's, the plan decides which blocks exist.
$blocks = array_merge(array_intersect_key(array_flip([...array_keys(self::BLOCKS), self::OTHER]), $blocks), $blocks);
$active = [];
foreach ($rows as $row) {
if ($row['on']) {
$active[$row['module']] = $row;
}
}
foreach ($blocks as $key => &$block) {
$block['active'] = collect($block['modules'])->contains('on', true);
$block = [...$block, 'waits_for' => [], 'after' => [], 'events' => [], 'scheduled' => [], 'conditional' => [], 'may_wait' => []];
foreach ($block['modules'] as $row) {
$definition = $this->catalogue->modules()[$row['module']]::definition();
if (! $row['on']) {
continue;
}
foreach ($definition->requires as $dependency) {
$targetBlock = $blockOf[$dependency->module] ?? self::OTHER;
if ($dependency->module === 'intake.record' || ! isset($active[$dependency->module]) || $targetBlock === $key) {
continue;
}
$list = $dependency->hard ? 'waits_for' : 'after';
$label = $blocks[$targetBlock]['label'] ?? self::BLOCKS[$targetBlock]['label'] ?? $other['label'];
$entry = $block[$list][$targetBlock] ?? ['block' => $targetBlock, 'label' => $label, 'steps' => []];
$entry['steps'][] = $active[$dependency->module]['label'];
$block[$list][$targetBlock] = $entry;
}
if ($definition->toggle === ModuleDefinition::TOGGLE_EVENT_DRIVEN) {
$block['events'][] = $row['label'];
} elseif ($definition->triggers !== [] && collect($definition->triggers)->every(fn (string $trigger): bool => str_starts_with($trigger, 'schedule:'))) {
$block['scheduled'][] = $row['label'];
}
if ($definition->toggle === ModuleDefinition::TOGGLE_CONDITIONAL) {
$block['conditional'][] = ['label' => $row['label'], 'reason' => $definition->condition];
}
foreach ($definition->waits as $wait) {
$block['may_wait'][] = ['guest' => 'den Gast', 'portal' => 'das Portal', 'landlord' => 'Sie', 'time' => 'eine Frist'][$wait] ?? $wait;
}
}
$block['waits_for'] = array_values($block['waits_for']);
$block['after'] = array_values($block['after']);
$block['may_wait'] = array_values(array_unique($block['may_wait']));
$block['independent'] = $block['active'] && $block['waits_for'] === [];
}
unset($block);
return $blocks;
}
}
+7
View File
@@ -1,5 +1,12 @@
# Projektstand
## Nachtrag (05.11.2026): Visueller Prozesskonfigurator (Branch `feature/prozess-konfigurator`)
- **Befund Steuerung:** Für neue Vorgänge gibt es eine maßgebliche Definition: den beim Eingang eingefrorenen `ProcessPlan` (`CaseRecorder` → `ProcessPlan::freeze`), den der `ProcessRunner` liest. Die Modelle A1–A5 wirken nur (a) in alten Fällen mit eingefrorenem oder abgeleitetem Plan und (b) als Adapter `ProcessCatalogue::derivedModel` für Kanäle, in denen noch kein Modell gewählt wurde; dort ist der Plan eine reine Funktion des aufgelösten Profils. Ein gewähltes Modell wird nie durch das abgeleitete ersetzt. Scheduler, Actions und Ereignisse führen aus, entscheiden aber über `ProcessPlan::of($booking)`. Nachweis: `VisualProcessConfiguratorTest::test_the_derived_legacy_model_is_only_used_where_nothing_is_chosen`.
- **Konfiguratorseite (Kanal › Ablauf):** Hauptansicht sind fachliche Prozessblöcke (`App\Process\ProcessBlocks`; die Zuordnung der Module zu Blöcken dient nur der Darstellung, ein Test hält Katalog und Tabelle gleich). Je Block: gewählte Schablone, wirksame Werte mit Herkunft, harte/weiche Abhängigkeiten zu anderen Blöcken, ereignis-/zeitgesteuert, bedingt – abgeleitet aus denselben Abhängigkeiten wie im Runner. Klick öffnet das Detailpanel: Schablonenwahl mit Folgenanalyse, Verbindungen, einstellbare Schritte (Schalter, Ausführung, Zuständigkeit, Parameter), feste Schritte nur als eine Zeile, „noch nicht vorhanden“ aus den Erweiterungen der Schablone.
- **Entwurf:** Auswählen/Öffnen speichert nichts; `dirty()` zeigt ungespeicherte Änderungen, „Änderungen verwerfen“ (`discard`), der Tester bekommt denselben Entwurf. Die endlose Einzelschrittliste ist entfernt; die Basisprozess-Auswahl ist eingeklappt, sobald das Modell Schablonen hat. Widersprüche zu gespeicherten Altwerten bleiben bestätigungspflichtige Konflikte (Test C).
- Tests: `VisualProcessConfiguratorTest` (A Webseite, B Destination Solutions inkl. Vergleich Blöcke = eingefrorener Plan, C Konflikt, D Bestandsfall, E Blockzuordnung/Erreichbarkeit); Feature-Suite 946/946. Nicht auf dem Testsystem geprüft, nicht gepusht.
## Nachtrag (05.11.2026): Anfrage-Basisprozess und Schablonen für alle Vorfälle
**Branch `feature/anfrage-basisprozess`** – [SCHABLONENKATALOG.md](Prozessarchitektur/SCHABLONENKATALOG.md) §9–10.
@@ -0,0 +1,80 @@
@php
$muted = 'color:#6b7280;font-size:.8rem';
$card = 'border:1px solid rgba(128,128,128,.3);border-radius:.5rem;padding:.75rem 1rem;margin-bottom:.6rem';
$decision = collect($this->decisions())->first(fn (array $candidate): bool => $block['area'] !== null && $candidate['area'] === $block['area']);
$areaImpacts = $block['area'] === null ? [] : array_values(array_filter($this->templateImpacts(), fn (array $impact): bool => $impact['area'] === $block['area']->label()));
@endphp
<x-filament::section :heading="'Einstellungen: '.$block['label']" :description="'Phase '.$block['phase'].' · Änderungen bleiben ein Entwurf, bis Sie speichern.'" wire:key="block-detail-{{ $this->intake }}-{{ $block['key'] }}">
@foreach ($block['problems'] as $problem)
<p style="color:#b91c1c;font-size:.85rem;margin-bottom:.4rem">{{ $problem }}</p>
@endforeach
@if ($decision)
<h3 style="font-weight:600;margin:.2rem 0 .3rem">{{ $decision['area']->label() }} <span style="{{ $muted }}">– {{ $decision['area']->question() }}</span></h3>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));gap:.6rem" role="radiogroup" aria-label="{{ $decision['area']->label() }}">
@foreach ($decision['options'] as $option)
@php($template = $option['template'])
<div style="{{ $card }};{{ $option['selected'] ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $option['admissible'] ? '' : 'opacity:.85;background:rgba(128,128,128,.07)' }}" wire:key="template-{{ $this->intake }}-{{ $option['key'] }}">
<button type="button" role="radio" aria-checked="{{ $option['selected'] ? 'true' : 'false' }}" @disabled(! $option['admissible']) wire:click="chooseTemplate('{{ $decision['area']->value }}', '{{ $option['key'] }}')" style="text-align:left;width:100%">
<strong>{{ $template::label() }}</strong>
<div style="font-size:.85rem;margin-top:.3rem">{{ $template::purpose() }}</div>
</button>
<ul style="{{ $muted }};margin-top:.4rem;list-style:disc;padding-left:1.1rem">
@foreach ($template::dimensions() as $dimension => $statement)<li><strong>{{ $dimension }}:</strong> {{ $statement }}</li>@endforeach
</ul>
@foreach ($option['restrictions'] as $restriction)
<p style="color:#b45309;font-size:.8rem;margin-top:.4rem"><strong>Passt gerade nicht ({{ $restriction->kind }}):</strong> {{ $restriction->reason }}@if ($restriction->alternative) <br>Zulässig ist stattdessen: {{ $restriction->alternative }}.@endif @if ($restriction->change) <br>{{ $restriction->change }}.@endif</p>
@endforeach
@foreach ($option['hints'] as $hint)<p style="{{ $muted }};margin-top:.3rem">{{ $hint }}</p>@endforeach
</div>
@endforeach
</div>
@foreach ($areaImpacts as $impact)
<div style="font-size:.85rem;margin:.4rem 0 .8rem" data-impact="{{ $impact['area'] }}">
<strong>Was der Wechsel bedeutet:</strong> {{ $impact['from'] ?? 'bisher keine Schablone' }} → <strong>{{ $impact['to'] }}</strong>
@if ($impact['responsibility'])<div>Verantwortung: {{ $impact['responsibility']['from'] }} → {{ $impact['responsibility']['to'] }}</div>@endif
@if ($impact['removed'] !== [])<div>Entfällt: {{ implode(', ', $impact['removed']) }}</div>@endif
@if ($impact['added'] !== [])<div>Kommt hinzu: {{ implode(', ', $impact['added']) }}</div>@endif
@if ($impact['kept'] !== [])<div style="{{ $muted }}">Bleibt mit allen Einstellungen: {{ implode(', ', $impact['kept']) }}</div>@endif
@foreach ($impact['switches_lost'] as $lost)<div style="color:#b45309">Ihr gespeicherter Schalter für „{{ $lost }}“ hat dann keinen Bezug mehr.</div>@endforeach
@foreach ($impact['settings_replaced'] as $text)<div style="color:#b45309">{{ $text }}</div>@endforeach
@foreach ($impact['needs'] as $need)<div style="{{ $muted }}">{{ $need }}</div>@endforeach
</div>
@endforeach
@endif
@if ($block['extensions'] !== [])
<p style="{{ $muted }};margin:.4rem 0">Noch nicht vorhanden (hier gibt es dafür keine Einstellung): {{ implode('; ', $block['extensions']) }}.</p>
@endif
<h3 style="font-weight:600;margin:.8rem 0 .2rem">Verbindungen</h3>
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">
@forelse ($block['waits_for'] as $dependency)
<li>Wartet auf <strong>{{ $dependency['label'] }}</strong> ({{ implode(', ', array_unique($dependency['steps'])) }}) – harte Abhängigkeit</li>
@empty
<li>Wartet auf keinen anderen Block – läuft unabhängig.</li>
@endforelse
@foreach ($block['after'] as $dependency)<li>Soll nach <strong>{{ $dependency['label'] }}</strong> ({{ implode(', ', array_unique($dependency['steps'])) }}) – weiche Abhängigkeit, blockiert nicht</li>@endforeach
@if ($block['may_wait'] !== [])<li>Kann warten auf: {{ implode(', ', $block['may_wait']) }}</li>@endif
@if ($block['events'] !== [])<li>Reagiert auf Ereignisse: {{ implode(', ', $block['events']) }}</li>@endif
@if ($block['scheduled'] !== [])<li>Zeitgesteuert: {{ implode(', ', $block['scheduled']) }}</li>@endif
@foreach ($block['conditional'] as $conditional)<li>Bedingt: {{ $conditional['label'] }}@if ($conditional['reason']) – nur wenn {{ $conditional['reason'] }}@endif</li>@endforeach
</ul>
@if ($block['configurable'] !== [])
<h3 style="font-weight:600;margin:.8rem 0 0">Einstellbare Schritte</h3>
@foreach ($block['configurable'] as $step)
@include('filament.resources.channels.channel-process-step', ['step' => $step])
@endforeach
@endif
@if ($block['fixed'] !== [])
<p style="{{ $muted }};margin-top:.6rem">Feste Schritte ohne eigene Einstellung: {{ implode(', ', array_column($block['fixed'], 'label')) }}.</p>
@endif
@if ($block['off'] !== [])
<p style="{{ $muted }};margin-top:.3rem">Entfällt hier: {{ implode('; ', array_map(fn (array $step): string => $step['label'].($step['reason'] ? ' ('.$step['reason'].')' : ''), $block['off'])) }}.</p>
@endif
@if ($block['configurable'] === [] && $block['facts'] === [] && $decision === null)
<p style="{{ $muted }}">Dieser Block hat keine eigenen Einstellungen.</p>
@endif
</x-filament::section>
@@ -0,0 +1,67 @@
@php
$muted = 'color:#6b7280;font-size:.8rem';
$input = 'border:1px solid rgba(128,128,128,.4);border-radius:.375rem;padding:.3rem .45rem;background:transparent';
$performers = ['system' => 'System', 'landlord' => 'Sie', 'guest' => 'Gast', 'portal' => 'Portal', 'service_provider' => 'Dienstleister', 'none' => 'niemand'];
$waitLabels = ['guest' => 'Gast', 'portal' => 'Portal', 'landlord' => 'Sie', 'time' => 'Frist'];
@endphp
<div style="border-top:1px solid rgba(128,128,128,.25);padding:.6rem 0;{{ $step['on'] ? '' : 'opacity:.65' }}" wire:key="step-{{ $this->intake }}-{{ $step['module'] }}">
<div style="display:flex;justify-content:space-between;gap:.5rem;align-items:center">
<strong style="font-size:.9rem">{{ $step['label'] }}
@if ($step['tester_only'])<span style="color:#b45309;font-size:.75rem"> · nur im Prozess-Tester</span>@endif
@if ($step['inserted'])<span style="{{ $muted }}"> · Zusatzschritt der Variante</span>@endif
</strong>
@if ($step['optional'])
<x-filament::button size="xs" :color="($this->drafts[$this->intake]['steps'][$step['module']]['on'] ?? true) === false ? 'gray' : 'success'" wire:click="toggleStep('{{ $step['module'] }}')">
{{ ($this->drafts[$this->intake]['steps'][$step['module']]['on'] ?? true) === false ? 'aus' : 'an' }}
</x-filament::button>
@endif
</div>
<div style="font-size:.85rem;margin-top:.2rem">{{ $step['purpose'] }}</div>
<div style="{{ $muted }};margin-top:.2rem">
@if ($step['needs'] !== []) wartet auf: {{ implode(', ', $step['needs']) }} · @elseif ($step['on']) läuft unabhängig · @endif
@if ($step['after'] !== []) soll nach: {{ implode(', ', $step['after']) }} · @endif
@if ($step['condition']) nur wenn: {{ $step['condition'] }} · @endif
Wer: {{ $performers[$step['performer']] ?? $step['performer'] ?? '–' }}
@if ($step['waits'] !== []) · kann warten auf: {{ implode(', ', array_map(fn ($wait) => $waitLabels[$wait] ?? $wait, $step['waits'])) }}@endif
@if ($step['triggers'] !== [] && $this->expert()) · Auslöser: {{ implode(', ', $step['triggers']) }}@endif
@if (! $step['on'] && $step['reason']) · <em>übersprungen: {{ $step['reason'] }}</em>@endif
@if ($this->expert()) · <code>{{ $step['module'] }}</code> v{{ $step['version'] }}@endif
</div>
@if ($step['mode_setting'] && $step['mode_options'] !== [])
<label style="display:block;font-size:.85rem;margin-top:.4rem">Ausführung
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['mode_setting']->value }}" style="{{ $input }};margin-left:.4rem">
<option value="">wie Standard</option>
@foreach ($step['mode_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
</select>
<span style="{{ $muted }}">wirksam: {{ $this->setting($step['mode_setting'], $this->profile())['value'] }} ({{ $this->setting($step['mode_setting'], $this->profile())['source'] }})</span>
</label>
@endif
@if ($step['performer_setting'] && count($step['performer_options']) > 1)
<label style="display:block;font-size:.85rem;margin-top:.4rem">Wer sendet
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['performer_setting']->value }}" style="{{ $input }};margin-left:.4rem">
<option value="">wie Standard</option>
@foreach ($step['performer_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
</select>
<span style="{{ $muted }}">wirksam: {{ $this->setting($step['performer_setting'], $this->profile())['value'] }} ({{ $this->setting($step['performer_setting'], $this->profile())['source'] }})</span>
</label>
@endif
@foreach ($step['parameters'] as $parameter)
<label style="display:block;font-size:.85rem;margin-top:.4rem">{{ $parameter['question'] }}
@if ($parameter['options'])
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" style="{{ $input }};margin-left:.4rem">
<option value="">wie geerbt</option>
@foreach ($parameter['options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
</select>
@else
<input type="text" wire:model.live.debounce.600ms="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" placeholder="{{ $parameter['value'] }}" style="{{ $input }};width:8rem;margin-left:.4rem">
@endif
<span style="{{ $muted }}">wirksam: {{ $parameter['value'] }} ({{ $parameter['source'] }})</span>
@if ($parameter['set'])
<button type="button" wire:click="inherit('{{ $parameter['key'] }}')" style="{{ $muted }};text-decoration:underline">auf geerbten Wert zurücksetzen</button>
@endif
</label>
@endforeach
</div>
@@ -52,6 +52,15 @@
</x-filament::section>
@endif
@if ($conflicts = $this->conflicts())
<div style="{{ $card }};margin-bottom:.8rem;border-color:#b45309">
<strong>Bisherige Einstellungen widersprechen dem gewählten Ablauf</strong>
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">@foreach ($conflicts as $conflict)<li>{{ $conflict['text'] }}</li>@endforeach</ul>
<label style="font-size:.85rem"><input type="checkbox" wire:model.live="acknowledge"> Ich bestätige: Diese bisherigen Einstellungen werden beim Speichern entfernt und im Verlauf des Kanals festgehalten.</label>
</div>
@endif
<details @if (! $composable || $draft['derived']) open @endif style="margin-bottom:1rem"><summary style="cursor:pointer;font-weight:600">Basisprozess: {{ $model::label() }}</summary>
<x-filament::section :heading="$this->question()" :description="$draft['derived'] ? 'Noch nicht gewählt: abgeleitet aus Ihren bisherigen Einstellungen. Gespeichert wird erst, wenn Sie speichern.' : null">
@if ($models === [])
<p>Für diese Eingangsart gibt es keine Ablaufmodelle.</p>
@@ -78,11 +87,12 @@
@endforeach
</div>
@if ($conflicts = $this->conflicts())
<div style="{{ $card }};margin-top:.8rem;border-color:#b45309">
<strong>Bisherige Einstellungen widersprechen diesem Modell</strong>
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">@foreach ($conflicts as $conflict)<li>{{ $conflict['text'] }}</li>@endforeach</ul>
<label style="font-size:.85rem"><input type="checkbox" wire:model.live="acknowledge"> Ich bestätige: Diese bisherigen Einstellungen werden beim Speichern entfernt und im Verlauf des Kanals festgehalten.</label>
@if ($composable && ($presets = $this->presets()) !== [])
<div style="color:#6b7280;font-size:.8rem;margin-top:.6rem">Bekannte Kombinationen als Ausgangspunkt:
@foreach ($presets as $archetype => $preset)
<button type="button" wire:click="applyPreset('{{ $archetype }}')" style="text-decoration:underline;margin-left:.4rem">{{ $preset['label'] }}</button>
@endforeach
</div>
@endif
@@ -101,67 +111,66 @@
</div>
@endif
</x-filament::section>
</details>
@if ($composable)
@php($decisions = $this->decisions())
<x-filament::section heading="Geschäftsentscheidungen" description="Wählen Sie je Bereich die passende Funktionsschablone. Die Einzelschritte jeder Schablone bleiben darunter einzeln einstellbar.">
@if (($presets = $this->presets()) !== [])
<div style="{{ $muted }};margin-bottom:.6rem">Bekannte Kombinationen als Ausgangspunkt:
@foreach ($presets as $archetype => $preset)
<button type="button" wire:click="applyPreset('{{ $archetype }}')" style="text-decoration:underline;margin-left:.4rem">{{ $preset['label'] }}</button>
@endforeach
</div>
@endif
@foreach ($decisions as $decision)
<h3 style="font-weight:600;margin:.6rem 0 .3rem">{{ $decision['area']->label() }} <span style="{{ $muted }}">– {{ $decision['area']->question() }}</span></h3>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(20rem,1fr));gap:.6rem" role="radiogroup" aria-label="{{ $decision['area']->label() }}">
@foreach ($decision['options'] as $option)
@php($template = $option['template'])
<div style="{{ $card }};{{ $option['selected'] ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $option['admissible'] ? '' : 'opacity:.85;background:rgba(128,128,128,.07)' }}" wire:key="template-{{ $this->intake }}-{{ $option['key'] }}">
<button type="button" role="radio" aria-checked="{{ $option['selected'] ? 'true' : 'false' }}" @disabled(! $option['admissible']) wire:click="chooseTemplate('{{ $decision['area']->value }}', '{{ $option['key'] }}')" style="text-align:left;width:100%">
<strong>{{ $template::label() }}</strong>
<div style="font-size:.85rem;margin-top:.3rem">{{ $template::purpose() }}</div>
</button>
<ul style="{{ $muted }};margin-top:.4rem;list-style:disc;padding-left:1.1rem">
@foreach ($template::dimensions() as $dimension => $statement)<li><strong>{{ $dimension }}:</strong> {{ $statement }}</li>@endforeach
</ul>
<div style="{{ $muted }};margin-top:.3rem">Schritte: {{ implode(', ', $option['modules']) }}@if ($template::extensions() !== []) · noch nicht vorhanden: {{ implode('; ', $template::extensions()) }}@endif</div>
@foreach ($option['restrictions'] as $restriction)
<p style="color:#b45309;font-size:.8rem;margin-top:.4rem"><strong>Passt gerade nicht ({{ $restriction->kind }}):</strong> {{ $restriction->reason }}@if ($restriction->alternative) <br>Zulässig ist stattdessen: {{ $restriction->alternative }}.@endif @if ($restriction->change) <br>{{ $restriction->change }}.@endif</p>
@endforeach
@foreach ($option['hints'] as $hint)<p style="{{ $muted }};margin-top:.3rem">{{ $hint }}</p>@endforeach
</div>
@endforeach
</div>
@endforeach
</x-filament::section>
@if ($templateImpacts = $this->templateImpacts())
<x-filament::section heading="Was der Wechsel bedeutet" description="Nichts davon wird still geändert – Sie sehen jede Folge, bevor Sie speichern.">
@foreach ($templateImpacts as $impact)
<div style="font-size:.9rem;margin-bottom:.8rem">
<strong>{{ $impact['area'] }}:</strong> {{ $impact['from'] ?? 'bisher keine Schablone' }} → <strong>{{ $impact['to'] }}</strong>
@if ($impact['responsibility'])<div>Verantwortung: {{ $impact['responsibility']['from'] }} → {{ $impact['responsibility']['to'] }}</div>@endif
@if ($impact['removed'] !== [])<div>Entfällt: {{ implode(', ', $impact['removed']) }}</div>@endif
@if ($impact['added'] !== [])<div>Kommt hinzu: {{ implode(', ', $impact['added']) }}</div>@endif
@if ($impact['kept'] !== [])<div style="{{ $muted }}">Bleibt mit allen Einstellungen: {{ implode(', ', $impact['kept']) }}</div>@endif
@foreach ($impact['switches_lost'] as $lost)<div style="color:#b45309">Ihr gespeicherter Schalter für „{{ $lost }}“ hat dann keinen Bezug mehr.</div>@endforeach
@foreach ($impact['settings_replaced'] as $text)<div style="color:#b45309">{{ $text }}</div>@endforeach
@foreach ($impact['needs'] as $need)<div style="{{ $muted }}">{{ $need }}</div>@endforeach
</div>
@endforeach
</x-filament::section>
@endif
@if ($this->dirty())
<div style="{{ $card }};border-color:#b45309;display:flex;justify-content:space-between;align-items:center;gap:.6rem" role="status">
<span style="font-size:.9rem"><strong>Ungespeicherte Änderungen.</strong> Der Prozess unten zeigt Ihren Entwurf; der Tester verwendet ihn ebenfalls. Gespeichert wird erst mit „Speichern“.</span>
<x-filament::button size="xs" color="gray" wire:click="discard">Änderungen verwerfen</x-filament::button>
</div>
@endif
@if ($problems !== [])
@if (($loose = $this->problemsOutsideBlocks()) !== [])
<x-filament::section heading="Nicht zulässig">
<ul style="color:#b91c1c;font-size:.9rem;list-style:disc;padding-left:1.2rem">
@foreach ($problems as $problem)<li>{{ $problem }}</li>@endforeach
@foreach ($loose as $problem)<li>{{ $problem }}</li>@endforeach
</ul>
</x-filament::section>
@endif
@php($blocks = $this->blocks())
<x-filament::section heading="Der Geschäftsprozess" description="Fachliche Blöcke – keine feste Reihenfolge. Was wartet, ergibt sich aus den Abhängigkeiten dieses Ablaufs. Klicken Sie einen Block an, um ihn einzustellen.">
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(17rem,1fr));gap:.7rem">
@foreach ($blocks as $key => $block)
<div style="{{ $card }};margin:0;{{ $this->block === $key ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $block['active'] ? '' : 'opacity:.6' }}" wire:key="block-{{ $this->intake }}-{{ $key }}">
<button type="button" wire:click="selectBlock('{{ $key }}')" aria-expanded="{{ $this->block === $key ? 'true' : 'false' }}" aria-controls="block-detail" style="text-align:left;width:100%">
<div style="{{ $muted }}">{{ $block['phase'] }}</div>
<strong>{{ $block['label'] }}</strong>
@if ($block['template'])<div style="font-size:.85rem">{{ $block['template']::label() }}</div>@endif
<ul style="font-size:.82rem;margin-top:.35rem;list-style:none;padding:0">
@foreach ($block['facts'] as $fact)
<li><span style="{{ $muted }}">{{ $fact['question'] }}</span> <strong>{{ $fact['value'] }}</strong> <span style="{{ $muted }}">({{ $fact['source'] }})</span></li>
@endforeach
</ul>
<div style="font-size:.8rem;margin-top:.4rem">
@if (! $block['active'])
<span style="{{ $muted }}">Entfällt in diesem Ablauf.</span>
@else
@forelse ($block['waits_for'] as $dependency)
<div style="color:#b45309">⏳ wartet auf {{ $dependency['label'] }}</div>
@empty
<div style="color:#15803d">⇉ läuft unabhängig</div>
@endforelse
@foreach ($block['after'] as $dependency)<div style="{{ $muted }}">↳ soll nach {{ $dependency['label'] }}</div>@endforeach
@if ($block['events'] !== [])<div style="{{ $muted }}">⚡ ereignisgesteuert: {{ implode(', ', $block['events']) }}</div>@endif
@if ($block['scheduled'] !== [])<div style="{{ $muted }}">⏱ zeitgesteuert: {{ implode(', ', $block['scheduled']) }}</div>@endif
@foreach ($block['conditional'] as $conditional)<div style="{{ $muted }}">? bedingt: {{ $conditional['label'] }}</div>@endforeach
@endif
@if ($block['problems'] !== [] || $block['attention'] > 0)<div style="color:#b91c1c">⚠ Klärung nötig</div>@endif
</div>
</button>
</div>
@endforeach
</div>
<p style="{{ $muted }};margin-top:.5rem">Gilt für neue Vorgänge. Laufende Vorgänge dieses Kanals ({{ $this->runningCases() }}) behalten ihren bisherigen Ablauf.</p>
</x-filament::section>
<div id="block-detail">
@if ($this->block !== '' && isset($blocks[$this->block]))
@include('filament.resources.channels.channel-process-block', ['block' => $blocks[$this->block]])
@endif
</div>
@if ($impacts = $this->impacts())
<x-filament::section heading="Was die Abschaltung bedeutet">
@foreach ($impacts as $impact)
@@ -174,111 +183,19 @@
</x-filament::section>
@endif
@php($lanes = $this->lanes())
<x-filament::section heading="4 · Ablauf im Zusammenhang" description="Aus den tatsächlichen Abhängigkeiten dieses Ablaufs – so führt ihn das System aus.">
@php($laneTitles = ['parallel' => 'Läuft sofort, unabhängig voneinander', 'waiting' => 'Wartet auf andere Schritte', 'event' => 'Ereignisgesteuert (reagiert, wenn etwas eintrifft)', 'later' => 'Zeitgesteuert (zu seiner Zeit)', 'off' => 'Entfällt hier'])
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));gap:.6rem">
@foreach ($laneTitles as $lane => $title)
@if ($lanes[$lane] !== [])
<div style="{{ $card }}">
<strong style="font-size:.85rem">{{ $title }}</strong>
<ul style="font-size:.85rem;list-style:disc;padding-left:1.1rem;margin-top:.3rem">
@foreach ($lanes[$lane] as $item)
<li>{{ $item['label'] }}@if (! empty($item['after'])) <span style="{{ $muted }}">– nach: {{ implode(', ', $item['after']) }}</span>@endif @if ($item['note']) <span style="{{ $muted }}">({{ $item['note'] }})</span>@endif</li>
@endforeach
</ul>
</div>
@endif
@endforeach
</div>
<x-filament::section heading="Ablauf prüfen" description="Spielt einen ausgedachten Vorgang mit genau diesem – auch ungespeicherten – Entwurf durch, ohne Wirkung auf echte Daten.">
<x-filament::button color="gray" wire:click="test">Ablauf testen</x-filament::button>
@if ($this->expert())
<details style="margin-top:.8rem"><summary style="cursor:pointer;font-size:.9rem">Alle Schritte dieses Ablaufs ({{ count($steps) }})</summary>
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem;margin-top:.4rem">
@foreach ($steps as $step)
<li style="{{ $step['on'] ? '' : 'color:#9ca3af;text-decoration:line-through' }}">
{{ $step['label'] }}
<span style="{{ $muted }}">– {{ $step['on'] ? ($performers[$step['performer']] ?? $step['performer'] ?? '').($step['mode'] ? ', '.(\App\Enums\ProcessingMode::tryFrom($step['mode'])?->getLabel() ?? \App\Enums\DataRequestMode::tryFrom($step['mode'])?->getLabel() ?? $step['mode']) : '') : 'übersprungen: '.$step['reason'] }}</span>
</li>
@endforeach
</ul>
</details>
@endif
</x-filament::section>
<div style="display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:1rem;align-items:start">
<details @if (! $composable) open @endif>
<summary style="cursor:pointer;font-weight:600;margin-bottom:.4rem">Einzelschritte einstellen ({{ count($steps) }} Schritte)</summary>
@foreach (collect($steps)->groupBy('phase') as $phase => $group)
<h3 style="font-weight:600;margin:.6rem 0 .3rem">{{ $phases[$phase] ?? $phase }}</h3>
@foreach ($group as $index => $step)
<div style="{{ $card }};{{ $step['on'] ? '' : 'opacity:.6' }}" wire:key="step-{{ $this->intake }}-{{ $step['module'] }}">
<div style="display:flex;justify-content:space-between;gap:.5rem;align-items:center">
<strong>{{ $step['label'] }}
@if ($step['tester_only'])<span style="color:#b45309;font-size:.75rem"> · nur im Prozess-Tester</span>@endif
@if ($step['inserted'])<span style="{{ $muted }}"> · Zusatzschritt der Variante</span>@endif
@if ($step['template'] ?? null)<span style="{{ $muted }}"> · Schablone: {{ $step['template'] }}</span>@endif
</strong>
@if ($step['optional'])
<x-filament::button size="xs" :color="($draft['steps'][$step['module']]['on'] ?? true) === false ? 'gray' : 'success'" wire:click="toggleStep('{{ $step['module'] }}')">
{{ ($draft['steps'][$step['module']]['on'] ?? true) === false ? 'aus' : 'an' }}
</x-filament::button>
@else
<span style="{{ $muted }}" title="Pflichtschritt – nicht abschaltbar">🔒 Pflicht</span>
@endif
</div>
<div style="font-size:.85rem;margin-top:.25rem">{{ $step['purpose'] }}</div>
<div style="{{ $muted }};margin-top:.25rem">
@if ($step['needs'] !== []) braucht zuerst: {{ implode(', ', $step['needs']) }} · @elseif ($step['on']) läuft unabhängig · @endif
@if ($step['after'] !== []) soll nach: {{ implode(', ', $step['after']) }} · @endif
@if ($step['condition']) nur wenn: {{ $step['condition'] }} · @endif
@if ($step['executions'] !== [] && ! $step['optional']) So darf das erfüllt werden: {{ implode(', ', $step['executions']) }}@if ($step['why']) – {{ $step['why'] }}@endif · @endif
Wer: {{ $performers[$step['performer']] ?? $step['performer'] ?? '–' }}
@if ($step['waits'] !== []) · kann warten auf: {{ implode(', ', array_map(fn ($wait) => ['guest' => 'Gast', 'portal' => 'Portal', 'landlord' => 'Sie', 'time' => 'Frist'][$wait] ?? $wait, $step['waits'])) }}@endif
@if (! $step['on'] && $step['reason']) · <em>übersprungen: {{ $step['reason'] }}</em>@endif
@if ($this->expert()) · <code>{{ $step['module'] }}</code> v{{ $step['version'] }}@endif
</div>
@if ($step['mode_setting'] && $step['mode_options'] !== [])
<label style="display:block;font-size:.85rem;margin-top:.4rem">Ausführung
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['mode_setting']->value }}" style="{{ $input }};margin-left:.4rem">
<option value="">wie Standard</option>
@foreach ($step['mode_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
</select>
<span style="{{ $muted }}">{{ $this->setting($step['mode_setting'], $this->profile())['source'] }}</span>
</label>
@endif
@if ($step['performer_setting'] && count($step['performer_options']) > 1)
<label style="display:block;font-size:.85rem;margin-top:.4rem">Wer sendet
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['performer_setting']->value }}" style="{{ $input }};margin-left:.4rem">
<option value="">wie Standard</option>
@foreach ($step['performer_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
</select>
<span style="{{ $muted }}">im Rahmen des Modells wählbar, ohne Modellwechsel</span>
</label>
@endif
@foreach ($step['parameters'] as $parameter)
<label style="display:block;font-size:.85rem;margin-top:.4rem">{{ $parameter['question'] }}
@if ($parameter['options'])
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" style="{{ $input }};margin-left:.4rem">
<option value="">wie geerbt</option>
@foreach ($parameter['options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
</select>
@else
<input type="text" wire:model.live.debounce.600ms="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" placeholder="{{ $parameter['value'] }}" style="{{ $input }};width:8rem;margin-left:.4rem">
@endif
<span style="{{ $muted }}">wirksam: {{ $parameter['value'] }} ({{ $parameter['source'] }})</span>
@if ($parameter['set'])
<button type="button" wire:click="inherit('{{ $parameter['key'] }}')" style="{{ $muted }};text-decoration:underline">auf geerbten Wert zurücksetzen</button>
@endif
</label>
@endforeach
</div>
@endforeach
@endforeach
</details>
<x-filament::section heading="Vorschau: ein neuer Vorgang" description="Mit den aktuellen, auch ungespeicherten Einstellungen. Es wird nichts gespeichert und nichts ausgeführt.">
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">
@foreach ($steps as $step)
<li style="{{ $step['on'] ? '' : 'color:#9ca3af;text-decoration:line-through' }}">
{{ $step['label'] }}
<span style="{{ $muted }}">– {{ $step['on'] ? ($performers[$step['performer']] ?? $step['performer'] ?? '').($step['mode'] ? ', '.(\App\Enums\ProcessingMode::tryFrom($step['mode'])?->getLabel() ?? \App\Enums\DataRequestMode::tryFrom($step['mode'])?->getLabel() ?? $step['mode']) : '') : 'übersprungen: '.$step['reason'] }}</span>
</li>
@endforeach
</ul>
<p style="{{ $muted }};margin-top:.6rem">Gilt für neue Vorgänge. Laufende Vorgänge dieses Kanals ({{ $this->runningCases() }}) behalten ihren bisherigen Ablauf.</p>
<x-filament::button color="gray" wire:click="test" style="margin-top:.6rem">Ablauf testen</x-filament::button>
<p style="{{ $muted }}">Spielt einen ausgedachten Vorgang mit genau dieser Einstellung durch – ohne Wirkung auf echte Daten.</p>
</x-filament::section>
</div>
</x-filament-panels::page>
@@ -193,9 +193,9 @@ public function test_the_page_shows_the_steps_with_their_settings_and_saves(): v
Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])
->assertSee('Wie wird eine Anfrage über')
->assertSee('Angebot mit Vorreservierung')
->assertSee('Der Geschäftsprozess')
->call('selectBlock', 'intake')
->assertSee('Fehlende Angaben beim Gast anfragen')
->assertSee('Pflicht')
->assertSee('Vorschau: ein neuer Vorgang')
->set('drafts.inquiry.settings.hold_hours', '24')
->assertSee('hier gesetzt')
->call('save')
@@ -65,15 +65,16 @@ public function test_the_page_shows_the_business_decisions_first_and_keeps_the_s
Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])
->call('chooseModel', 'external.booking')
->assertSee('Geschäftsentscheidungen')
->assertSee('Der Geschäftsprozess')
->call('selectBlock', 'finance')
->assertSee('Wer zieht das Geld des Gastes ein?')
->assertSee('Eigenes Inkasso')
->assertSee('Portal-Inkasso')
->assertSee('Eigene Vertragsdokumentation')
->assertSee('Externe Vertragsunterlagen')
->assertSee('Mehrstufige Mahnungen', escape: false)
->assertSee('Einzelschritte einstellen')
->assertSee('Zahlungen des Gastes');
->assertSee('Zahlungen des Gastes')
->call('selectBlock', 'documents')
->assertSee('Eigene Vertragsdokumentation')
->assertSee('Externe Vertragsunterlagen');
}
public function test_an_archetype_moves_to_the_base_process_with_the_same_combination_and_saves(): void
@@ -101,7 +102,7 @@ public function test_a_template_the_portal_cannot_support_cannot_be_chosen_and_s
$page->call('chooseTemplate', 'collection', 'collection.own');
$this->assertSame('collection.portal', $page->get('drafts')['booking']['templates']['collection'], 'refused: FeWo-direkt collects the money');
$page->assertSee('Passt gerade nicht')->assertSee('Zieht das Portal das Geld des Gastes ein?');
$page->call('selectBlock', 'finance')->assertSee('Passt gerade nicht')->assertSee('Zieht das Portal das Geld des Gastes ein?');
// The landlord corrects the capability first: now the template fits.
$page->set('capabilityDraft.collects_payment', '0')->call('chooseTemplate', 'collection', 'collection.own');
@@ -0,0 +1,261 @@
<?php
namespace Tests\Feature\Process;
use App\Actions\ConfigureChannelProcess;
use App\Actions\TakeOverExternalBooking;
use App\Enums\IntakeKind;
use App\Enums\ProcessSetting;
use App\Filament\Resources\Channels\Pages\ChannelProcess;
use App\Models\Booking;
use App\Models\Channel;
use App\Models\Property;
use App\Models\User;
use App\Process\ProcessBlocks;
use App\Process\ProcessCatalogue;
use App\Process\ProcessPlan;
use App\Process\ProcessSettings;
use App\Support\Content;
use App\Support\Settings;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Database\Seeders\SiteSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Mail\MailManager;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
use PHPUnit\Framework\Attributes\Group;
use Tests\TestCase;
/**
* The visual configurator: business blocks derived from the resolved plan, configuration inside the block, drafts that
* stay drafts, one authoritative process definition for new cases.
*/
#[Group('configurator')]
class VisualProcessConfiguratorTest extends TestCase
{
use RefreshDatabase;
private Property $property;
protected function setUp(): void
{
parent::setUp();
$this->travelTo(CarbonImmutable::parse('2026-10-23 18:00'));
$this->seed([PropertySeeder::class, SiteSeeder::class]);
$this->property = Property::sole();
Storage::fake('local');
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
config(['mail.default' => 'array']);
Mail::swap(new MailManager($this->app));
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org']);
Http::preventStrayRequests();
$this->actingAs(User::factory()->create());
}
/** Test A: own website – answer and reservation changed in the blocks, overview follows, draft is tested, then saved */
public function test_a_website_request_is_configured_in_the_blocks_and_the_overview_follows(): void
{
$website = Channel::websiteOf($this->property);
$page = Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])
->call('chooseModel', 'inquiry.request')
->call('selectBlock', 'answer')
->assertSee('Verbindliches Angebot')
->call('chooseTemplate', 'inquiry_answer', 'inquiry.binding_offer');
$blocks = $page->instance()->blocks();
$this->assertSame('Verbindliches Angebot', $blocks['answer']['template']::label());
$this->assertTrue($page->instance()->dirty(), 'a changed draft is shown as unsaved');
$this->assertNull($website->fresh()->process_overrides['inquiry']['model'] ?? null, 'nothing is saved by choosing');
// The offer waits for exactly what it needs; data collection and availability do not wait for it.
$this->assertContains('Eingang und Gastdaten', array_column($blocks['answer']['waits_for'], 'label'));
$this->assertContains('Verfügbarkeit und Reservierung', array_column($blocks['answer']['waits_for'], 'label'));
$this->assertTrue($blocks['intake']['independent']);
$this->assertTrue($blocks['availability']['independent']);
$this->assertSame([], $blocks['availability']['waits_for']);
$reserving = collect($blocks['availability']['facts'])->firstWhere('key', 'pre_reservation');
$this->assertSame('ja', mb_strtolower(substr($reserving['value'], 0, 2)), 'the offer suggests holding the dates at the request');
$page->call('selectBlock', 'availability')->set('drafts.inquiry.settings.pre_reservation', '0')->set('drafts.inquiry.settings.data_request_mode', 'manual');
$blocks = $page->instance()->blocks();
$this->assertContains('Reservierung des Zeitraums', array_column($blocks['availability']['off'], 'label'), 'the hold step drops out of the overview at once');
$this->assertSame('hier gesetzt', collect($blocks['availability']['facts'])->firstWhere('key', 'pre_reservation')['source']);
$this->assertStringContainsString('selbst nach', mb_strtolower(collect($blocks['intake']['facts'])->firstWhere('key', 'data_request_mode')['value']), 'the data request mode is shown in its block');
// The tester gets the very same unsaved draft.
$page->call('test');
$draft = session('process-tester.draft.'.$website->id.'.inquiry');
$this->assertSame('inquiry.request', $draft['model']);
$this->assertSame('inquiry.binding_offer', $draft['templates']['inquiry_answer']);
$this->assertSame('0', $draft['settings']['pre_reservation']);
$page->call('save')->assertNotified('Ablauf gespeichert');
$saved = $website->fresh()->process_overrides['inquiry'];
$this->assertSame(['inquiry.request', 'inquiry.binding_offer'], [$saved['model'], $saved['templates']['inquiry_answer']]);
$this->assertFalse($saved['pre_reservation']);
$this->assertFalse($page->instance()->dirty(), 'after saving the stored configuration is shown');
}
public function test_selecting_never_saves_and_changes_can_be_discarded(): void
{
$website = Channel::websiteOf($this->property);
$page = Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])->call('selectBlock', 'availability');
$this->assertFalse($page->instance()->dirty(), 'opening a block changes nothing');
$page->set('drafts.inquiry.settings.hold_hours', '12');
$this->assertTrue($page->instance()->dirty());
$this->assertNull(($website->fresh()->process_overrides['inquiry'] ?? [])['hold_hours'] ?? null);
$page->call('discard');
$this->assertFalse($page->instance()->dirty());
$this->assertArrayNotHasKey('hold_hours', $page->get('drafts')['inquiry']['settings']);
}
/** Test B: Destination Solutions – own collection, external contract documents, own booking notice, waiting for the portal */
public function test_destination_solutions_blocks_templates_modules_and_the_frozen_plan_agree(): void
{
$ds = $this->portal('Destination Solution');
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, [
'model' => 'external.booking',
'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.external'],
'settings' => ['await_portal_confirmation' => '1', 'booking_notice' => 'automatic'],
'capabilities' => ['collects_payment' => '0', 'provides_contract_documents' => '1'],
]);
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->fresh()->getRouteKey()])->set('intake', 'booking');
$blocks = $page->instance()->blocks();
$this->assertSame('Eigenes Inkasso', $blocks['finance']['template']::label());
$this->assertSame('Externe Vertragsunterlagen', $blocks['documents']['template']::label());
$this->assertContains('Bestätigung des Portals', array_column($blocks['documents']['waits_for'], 'label'), 'the documents wait for the portal confirmation');
$this->assertTrue($blocks['finance']['independent'], 'collecting the money does not wait for it');
$this->assertTrue($blocks['communication']['independent'], 'neither does the guest communication');
$this->assertContains('Zahlungen des Gastes', array_column($blocks['finance']['fixed'], 'label'));
$this->assertContains('Mehrstufige Mahnungen (rechtliche Ausgestaltung offen)', $blocks['finance']['extensions']);
$this->assertSame('automatic', collect($blocks['documents']['facts'])->firstWhere('key', 'booking_notice') ? 'automatic' : null);
// What the overview shows is what a new case gets.
$booking = $this->takeOver($ds->fresh(), 'DS-1');
$plan = ProcessPlan::of($booking);
$shown = collect($blocks)->flatMap(fn (array $block): array => collect($block['modules'])->where('on', true)->pluck('module')->all())->sort()->values()->all();
$this->assertSame(collect(array_keys($plan->modules))->sort()->values()->all(), $shown);
$this->assertEqualsCanonicalizing(['collection' => 'collection.own@1', 'contract_documents' => 'contract_docs.external@1'], array_intersect_key($plan->templates, ['collection' => 1, 'contract_documents' => 1]));
$this->assertSame('landlord', $booking->process()->payments()->value);
$this->assertSame('portal', $booking->process()->documents()->value);
}
/** Test C: a stored legacy setting contradicts the chosen template – one definition, controlled adoption */
public function test_a_contradicting_legacy_setting_becomes_a_conflict_and_never_a_second_definition(): void
{
$website = Channel::websiteOf($this->property);
$website->update(['process_overrides' => ['inquiry' => ['model' => 'a1.offer', 'pre_reservation' => true]]]);
$page = Livewire::test(ChannelProcess::class, ['record' => $website->fresh()->getRouteKey()])
->call('chooseModel', 'inquiry.request')
->call('chooseTemplate', 'inquiry_answer', 'inquiry.information');
$conflicts = collect($page->instance()->conflicts())->map(fn (array $conflict): string => $conflict['setting']->value)->all();
$this->assertContains('pre_reservation', $conflicts);
$this->assertGreaterThan(0, $page->instance()->blocks()['availability']['attention'], 'the block that is affected is marked');
$page->assertSee('Bisherige Einstellungen widersprechen');
$page->call('save')->assertNotified('Nicht gespeichert');
$this->assertSame('a1.offer', $website->fresh()->process_overrides['inquiry']['model'], 'refused: still exactly the old definition');
$page->set('acknowledge', true)->call('save')->assertNotified('Ablauf gespeichert');
$saved = $website->fresh()->process_overrides['inquiry'];
$this->assertSame('inquiry.request', $saved['model']);
$this->assertArrayNotHasKey('pre_reservation', $saved, 'the stale legacy value is gone, not hidden behind the template');
$plan = ProcessPlan::freeze(app(ProcessSettings::class)->forWebsite($this->property), ProcessPlan::configurationOf($website->fresh(), IntakeKind::Inquiry));
$this->assertSame([ProcessPlan::CONFIGURED, 'inquiry.request', 'inquiry.information@1'], [$plan->source, $plan->model, $plan->templates['inquiry_answer']]);
$this->assertFalse(app(ProcessSettings::class)->forWebsite($this->property)->preReservation());
}
/** Test D: cases of the historical models keep their frozen plan when the channel is reconfigured */
public function test_historical_cases_keep_their_frozen_plan(): void
{
$fewo = $this->portal('FeWo-direkt', 'mixed');
app(ConfigureChannelProcess::class)->handle($fewo, IntakeKind::Booking, ['model' => 'a4.portal_booking', 'capabilities' => ['collects_payment' => '1']]);
$old = $this->takeOver($fewo->fresh(), 'FD-ALT');
$frozen = $old->fresh()->profile;
$this->assertSame('a4.portal_booking', ProcessPlan::of($old)->model);
$page = Livewire::test(ChannelProcess::class, ['record' => $fewo->fresh()->getRouteKey()])->set('intake', 'booking')->call('applyPreset', 'a4.portal_booking');
$page->call('save')->assertNotified('Ablauf gespeichert');
$this->assertSame($frozen, $old->fresh()->profile);
$this->assertSame('a4.portal_booking', ProcessPlan::of($old->fresh())->model);
$this->assertSame('external.booking', ProcessPlan::of($this->takeOver($fewo->fresh(), 'FD-NEU', '2027-09-10'))->model);
}
/** Test E: the main view has few blocks, every module sits in exactly one of them, every control is reachable */
public function test_every_module_is_in_a_block_and_every_control_is_reachable_there(): void
{
$catalogue = app(ProcessCatalogue::class);
$grouped = collect(ProcessBlocks::BLOCKS)->flatMap(fn (array $block): array => $block['modules'])->all();
$this->assertSame([], array_values(array_diff(array_keys($catalogue->modules()), $grouped)), 'a new module needs a block');
$this->assertSame($grouped, array_values(array_unique($grouped)), 'no module is in two blocks');
$ds = $this->portal('Destination Solution');
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking')->call('chooseModel', 'external.booking');
$blocks = $page->instance()->blocks();
$this->assertLessThanOrEqual(8, count($blocks), 'a handful of blocks, not 28 modules');
$this->assertNotContains(ProcessBlocks::OTHER, array_keys($blocks));
$reachable = [];
foreach ($blocks as $block) {
foreach ($block['configurable'] as $step) {
foreach ([$step['mode_setting'], $step['performer_setting'], ...array_map(fn (array $parameter) => ProcessSetting::from($parameter['key']), $step['parameters'])] as $setting) {
if ($setting !== null) {
$reachable[$step['module']][$setting->value] = true;
}
}
}
}
// Whatever the configurator can save for a step is offered inside the block of that step.
foreach ($page->instance()->steps() as $step) {
if (! $step['on']) {
continue;
}
$offered = array_filter([$step['mode_setting']?->value, ...(count($step['performer_options']) > 1 ? [$step['performer_setting']?->value] : []), ...array_column($step['parameters'], 'key')]);
foreach ($offered as $setting) {
$this->assertArrayHasKey($setting, $reachable[$step['module']] ?? [], $step['module'].' / '.$setting.' is not reachable in its block');
}
}
}
/** One authoritative definition: the derived legacy model is only an adapter for channels without a chosen model */
public function test_the_derived_legacy_model_is_only_used_where_nothing_is_chosen(): void
{
$users = collect(['app/Process', 'app/Actions', 'app/Filament', 'app/Console'])
->flatMap(fn (string $directory): array => collect(app('files')->allFiles(base_path($directory)))->map(fn ($file) => $file->getPathname())->all())
->filter(fn (string $path): bool => str_contains(file_get_contents($path), 'derivedModel('))
->map(fn (string $path): string => basename($path))->sort()->values()->all();
$this->assertSame(['ChannelProcessConfiguration.php', 'ProcessCatalogue.php', 'ProcessPlan.php'], $users, 'only plan resolution and the configurator show the adapter');
$website = Channel::websiteOf($this->property);
app(ConfigureChannelProcess::class)->handle($website, IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']]);
$profile = app(ProcessSettings::class)->forWebsite($this->property);
$plan = ProcessPlan::freeze($profile, ProcessPlan::configurationOf($website->fresh(), IntakeKind::Inquiry));
$this->assertSame([ProcessPlan::CONFIGURED, 'inquiry.request'], [$plan->source, $plan->model], 'a chosen model is never replaced by the derived one');
}
private function portal(string $name, string $model = 'portal_booking'): Channel
{
return Channel::factory()->for($this->property)->create(['name' => $name, 'booking_model' => $model, 'import_enabled' => false, 'settings' => ['import_url' => 'https://portal.example/'.md5($name).'.ics']]);
}
private function takeOver(Channel $channel, string $reference, string $arrival = '2027-07-10'): Booking
{
$arrival = CarbonImmutable::parse($arrival);
return app(TakeOverExternalBooking::class)->handle($this->property, $channel, $arrival, $arrival->addDays(7), ['portal_reference' => $reference]);
}
}