Kanalkonfigurator und Prozess-Tester auf Schablonenbasis
Geschäftsentscheidungen zuerst (Schablonen je Bereich, Voreinstellungen A3–A5), Einzelschritte eingeklappt, Auswirkungsanalyse beim Schablonenwechsel, unbestätigte Portal-Fähigkeiten gekennzeichnet. Tester-Bericht nennt Schablonen, unabhängig laufende Schritte und fehlende Nachweise; alle vier Kombinationen sind als Szenario getestet. Doku: SCHABLONEN.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e95ba4f986
commit
c46f4a032b
12 files changed
+810
-10
No files matched your search
@@ -15,11 +15,14 @@
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
use App\Process\ConfigurationImpact;
|
||||
use App\Process\Models\ExternalBookingModel;
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Process\ProcessSettings;
|
||||
use App\Process\Restriction;
|
||||
use App\Process\Templates\FunctionTemplate;
|
||||
use App\Process\Templates\TemplateArea;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||
@@ -46,7 +49,7 @@ class ChannelProcess extends Page
|
||||
|
||||
public string $intake = 'inquiry';
|
||||
|
||||
/** @var array<string, array{model: string, variant: string, steps: array<string, array{on?: bool}>, settings: array<string, mixed>}> */
|
||||
/** @var array<string, array{model: string, variant: string, steps: array<string, array{on?: bool}>, settings: array<string, mixed>, templates: array<string, string>}> */
|
||||
public array $drafts = [];
|
||||
|
||||
/** @var array<string, string> capability key => '1' | '0' | '' (unknown); saving confirms what is shown */
|
||||
@@ -69,6 +72,7 @@ public function mount(int|string $record): void
|
||||
'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'],
|
||||
];
|
||||
@@ -140,7 +144,124 @@ public function models(): array
|
||||
*/
|
||||
public function conflicts(): array
|
||||
{
|
||||
return app(ChannelProcessConfiguration::class)->conflicts($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]['model']);
|
||||
return app(ChannelProcessConfiguration::class)->conflicts($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]['model'], $this->drafts[$this->intake]['templates']);
|
||||
}
|
||||
|
||||
/**
|
||||
* The models offered as a choice: the archetypes A3–A5 are presets of the base process, so they only appear while one
|
||||
* of them is the current choice (then with the hint to move to the templates).
|
||||
*
|
||||
* @param array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}> $models
|
||||
* @return array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}>
|
||||
*/
|
||||
public function visibleModels(array $models): array
|
||||
{
|
||||
return array_filter($models, fn (array $option, string $key): bool => ! $option['model']::isLegacy() || $key === $this->drafts[$this->intake]['model'], ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the chosen model composes function templates (otherwise its course is fixed).
|
||||
*/
|
||||
public function composable(): bool
|
||||
{
|
||||
return $this->model()->slots() !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The business decisions of the chosen base process: per slot the templates with fit, selection and what each stands
|
||||
* for. The first view of the configurator; the single steps stay below.
|
||||
*
|
||||
* @return list<array{area: TemplateArea, selected: ?string, options: list<array{key: string, template: class-string<FunctionTemplate>, admissible: bool, selected: bool, restrictions: list<Restriction>, hints: list<string>, unconfirmed: list<string>, modules: list<string>}>}>
|
||||
*/
|
||||
public function decisions(): array
|
||||
{
|
||||
$model = $this->model();
|
||||
if ($model->slots() === []) {
|
||||
return [];
|
||||
}
|
||||
$configuration = app(ChannelProcessConfiguration::class);
|
||||
$catalogue = app(ProcessCatalogue::class);
|
||||
$resolved = $configuration->templatesOf($model, $this->draft());
|
||||
$options = $configuration->templateOptions($this->record, $model, $this->capabilityDraft);
|
||||
$decisions = [];
|
||||
foreach ($model->slots() as $area) {
|
||||
$selected = isset($resolved[$area->value]) ? explode('@', $resolved[$area->value])[0] : null;
|
||||
$decisions[] = [
|
||||
'area' => $area,
|
||||
'selected' => $selected,
|
||||
'options' => array_values(array_map(fn (array $option, string $key): array => [
|
||||
...$option,
|
||||
'key' => $key,
|
||||
'selected' => $key === $selected,
|
||||
'modules' => array_map(fn (string $module): string => $catalogue->modules()[$module]::definition()->label, $option['template']::modules()),
|
||||
], $options[$area->value] ?? [], array_keys($options[$area->value] ?? []))),
|
||||
];
|
||||
}
|
||||
|
||||
return $decisions;
|
||||
}
|
||||
|
||||
/**
|
||||
* The archetypes as known combinations (presets) the landlord can start from.
|
||||
*
|
||||
* @return array<string, array{label: string, templates: array<string, string>}>
|
||||
*/
|
||||
public function presets(): array
|
||||
{
|
||||
$presets = [];
|
||||
foreach (app(ProcessCatalogue::class)->models() as $key => $candidate) {
|
||||
if ($candidate::isLegacy() && in_array(IntakeKind::from($this->intake), $candidate::intakes(), true)) {
|
||||
$presets[$key] = ['label' => $candidate::label(), 'templates' => $candidate::presetTemplates()];
|
||||
}
|
||||
}
|
||||
|
||||
return $presets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chooses the template of an area. Switches of steps that drop out of the course are removed from the draft; the
|
||||
* consequences are listed by templateImpacts() before anything is saved.
|
||||
*/
|
||||
public function chooseTemplate(string $area, string $key): void
|
||||
{
|
||||
$model = $this->model();
|
||||
$option = app(ChannelProcessConfiguration::class)->templateOptions($this->record, $model, $this->capabilityDraft)[$area][$key] ?? null;
|
||||
if ($option === null || ! $option['admissible']) {
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
$this->drafts[$this->intake]['templates'] = [...app(ChannelProcessConfiguration::class)->templatesOf($model, $this->draft()), $area => $key];
|
||||
$this->drafts[$this->intake]['templates'] = array_map(fn (string $reference): string => explode('@', $reference)[0], $this->drafts[$this->intake]['templates']);
|
||||
$modules = $model->modules($this->drafts[$this->intake]['variant'], $this->drafts[$this->intake]['templates']);
|
||||
$this->drafts[$this->intake]['steps'] = array_intersect_key($this->drafts[$this->intake]['steps'], array_flip($modules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves from a fixed archetype to the base process with the combination the archetype stands for. Switches and settings
|
||||
* stay as they are; what contradicts the templates shows as a conflict that has to be confirmed.
|
||||
*/
|
||||
public function applyPreset(string $archetype): void
|
||||
{
|
||||
$presets = $this->presets();
|
||||
$base = app(ProcessCatalogue::class)->model(ExternalBookingModel::key());
|
||||
if (! isset($presets[$archetype]) || ! in_array(IntakeKind::from($this->intake), $base::intakes(), true)) {
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
$this->drafts[$this->intake]['model'] = $base::key();
|
||||
$this->drafts[$this->intake]['variant'] = 'standard';
|
||||
$this->drafts[$this->intake]['templates'] = $presets[$archetype]['templates'];
|
||||
$this->drafts[$this->intake]['steps'] = array_intersect_key($this->drafts[$this->intake]['steps'], array_flip($base->modules('standard', $presets[$archetype]['templates'])));
|
||||
}
|
||||
|
||||
/**
|
||||
* What the draft's change of templates means (modules, responsibilities, stored switches and settings).
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function templateImpacts(): array
|
||||
{
|
||||
return app(ConfigurationImpact::class)->ofTemplates($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||
}
|
||||
|
||||
public function chooseModel(string $model): void
|
||||
@@ -149,9 +270,13 @@ public function chooseModel(string $model): void
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
// Leaving an archetype for a model with slots keeps its combination as the starting point of the templates.
|
||||
$previous = app(ProcessCatalogue::class)->model($this->drafts[$this->intake]['model']);
|
||||
$this->drafts[$this->intake]['model'] = $model;
|
||||
$this->drafts[$this->intake]['variant'] = 'standard';
|
||||
$this->drafts[$this->intake]['steps'] = [];
|
||||
$this->drafts[$this->intake]['templates'] = $this->model()->slots() === [] ? [] : $previous::presetTemplates();
|
||||
// Switches of steps the new course still has stay; only those that have no counterpart there drop out.
|
||||
$this->drafts[$this->intake]['steps'] = array_intersect_key($this->drafts[$this->intake]['steps'], array_flip($this->model()->modules('standard', $this->drafts[$this->intake]['templates'])));
|
||||
}
|
||||
|
||||
public function model(): ProcessModel
|
||||
|
||||
Reference in new issue
Block a user