Kanalkonfigurator: bestätigter Modellwechsel (A4→A3) speicherbar
Veraltete Altwerte (payments/guest_messages = portal), die das gewählte Modell überstimmt, blockierten das Speichern trotz bestätigter Übernahme: problems() prüfte den Entwurf vor der Entfernung, und nicht erlaubte variable Verantwortlichkeiten zählten nicht als Konflikt. Jetzt: conflicts() listet auch nicht mehr erlaubte Verantwortlichkeiten, problems()/profileWith() ignorieren die zu entfernenden Altwerte. Regressionstests A3/A4, Altwerte, Bestätigung, laufende Vorgänge. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8ad71c54d2
commit
a3ab1b6657
2 files changed
+101
-2
No files matched your search
@@ -158,9 +158,43 @@ public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey
|
||||
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. Das Modell „'.$modelKey.'“ legt fest: „'.$setting->describe($fixedValue).'“.'];
|
||||
}
|
||||
|
||||
// Stored responsibilities the model does not allow (variable ones, not fixed through fixes()) are just as stale.
|
||||
$responsibilities = $this->catalogue->model($modelKey)::responsibilities();
|
||||
foreach (Responsibilities::SETTINGS as $field => $setting) {
|
||||
$value = $setting->normalize($stored[$setting->value] ?? null);
|
||||
$responsibility = $value === null ? null : Responsibility::tryFrom((string) $value);
|
||||
if ($responsibility === null || $responsibilities->admits($setting, $responsibility) || in_array($setting, array_column($conflicts, 'setting'), true)) {
|
||||
continue;
|
||||
}
|
||||
$allowed = collect($responsibilities->allowed($field))->map(fn (Responsibility $allowedValue): string => $setting->describe($allowedValue->value))->implode(' oder ');
|
||||
$conflicts[] = ['setting' => $setting, 'stored' => $setting->describe($value), 'fixed' => $allowed,
|
||||
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. Das Modell „'.$modelKey.'“ erlaubt: „'.$allowed.'“.'];
|
||||
}
|
||||
|
||||
return $conflicts;
|
||||
}
|
||||
|
||||
/**
|
||||
* The draft without the stored settings the chosen model overrides (see conflicts()): the landlord has to confirm their
|
||||
* removal when saving, so they are neither validated against the model nor saved again.
|
||||
*
|
||||
* @param array<string, mixed> $draft
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function withoutOverriddenSettings(Channel $channel, IntakeKind $intake, array $draft): array
|
||||
{
|
||||
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||
foreach ($this->conflicts($channel, $intake, (string) ($draft['model'] ?? '')) as $conflict) {
|
||||
$key = $conflict['setting']->value;
|
||||
$value = $draft['settings'][$key] ?? null;
|
||||
if (array_key_exists($key, (array) ($draft['settings'] ?? [])) && (string) $conflict['setting']->normalize($value) === (string) $conflict['setting']->normalize($stored[$key] ?? null)) {
|
||||
unset($draft['settings'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $draft;
|
||||
}
|
||||
|
||||
/**
|
||||
* The model a new case of this channel and intake would follow now: the chosen one, or the one derived from the
|
||||
* settings as before (marked as derived).
|
||||
@@ -276,6 +310,7 @@ public function preview(Channel $channel, IntakeKind $intake, array $draft): arr
|
||||
*/
|
||||
public function problems(Channel $channel, IntakeKind $intake, array $draft, bool $sandbox = false): array
|
||||
{
|
||||
$draft = $this->withoutOverriddenSettings($channel, $intake, $draft);
|
||||
$problems = [];
|
||||
if (! in_array($intake, $this->intakes($channel), true)) {
|
||||
$problems[] = 'Dieser Kanal liefert keine '.($intake === IntakeKind::Booking ? 'festen Buchungen' : 'Anfragen').'.';
|
||||
@@ -335,6 +370,7 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
||||
*/
|
||||
public function profileWith(Channel $channel, IntakeKind $intake, array $draft): ProcessProfile
|
||||
{
|
||||
$draft = $this->withoutOverriddenSettings($channel, $intake, $draft);
|
||||
$preview = clone $channel;
|
||||
$overrides = (array) ($channel->process_overrides ?? []);
|
||||
$overrides[$intake->value] = [...array_filter((array) ($draft['settings'] ?? []), fn (mixed $value): bool => $value !== null && $value !== ''), 'model' => $draft['model'] ?? null, 'variant' => $draft['variant'] ?? 'standard', 'steps' => (array) ($draft['steps'] ?? [])];
|
||||
|
||||
Reference in new issue
Block a user