fix(ssr): only require account coding for manual transaction edits
Account coding lived in the always-applied base map of edit-form-schema, so every action (including the link/apply-rule/unlink actions) required a valid transaction-account/account. The edit modal always submits the Manual tab's (usually blank) account row, so link submits failed validation before reaching their save-handler and silently no-op'd. Move account validation into the :manual branch of the action :multi so link actions validate without it. Also surface whole-form validation errors in the wizard footer error bar: default-step-footer only handled top-level/sequential error shapes, so nested field-error maps (e.g. a hidden tab's account error) produced an empty bar and a silent failure. Add flatten-form-errors to flatten the humanized error tree. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -138,6 +138,33 @@
|
||||
[:div.space-y-1 {}
|
||||
children])
|
||||
|
||||
(defn flatten-form-errors
|
||||
"Walks a malli-humanized error structure and returns a flat sequence of
|
||||
human-readable strings, prefixing each leaf message with the nearest
|
||||
field name for context. Lets the footer's error bar surface every
|
||||
validation error for the whole form, even ones whose field lives on a
|
||||
hidden step/tab and so would otherwise be invisible."
|
||||
([errors] (flatten-form-errors nil errors))
|
||||
([field errors]
|
||||
(let [label (cond (keyword? field) (name field)
|
||||
(string? field) field
|
||||
:else nil)
|
||||
decorate (fn [msg] (if label (str label ": " msg) msg))]
|
||||
(cond
|
||||
(map? errors)
|
||||
(mapcat (fn [[k v]] (flatten-form-errors k v)) errors)
|
||||
|
||||
(and (sequential? errors) (every? string? errors))
|
||||
(map decorate errors)
|
||||
|
||||
(sequential? errors)
|
||||
(mapcat #(flatten-form-errors field %) errors)
|
||||
|
||||
(string? errors)
|
||||
[(decorate errors)]
|
||||
|
||||
:else nil))))
|
||||
|
||||
(defn default-step-footer [linear-wizard step & {:keys [validation-route
|
||||
discard-button
|
||||
next-button
|
||||
@@ -146,7 +173,8 @@
|
||||
[:div.flex.items-baseline.gap-x-4
|
||||
(let [step-errors (:step-params fc/*form-errors*)]
|
||||
(com/form-errors {:errors (or (:errors step-errors)
|
||||
(when (sequential? step-errors) step-errors))}))
|
||||
(when (sequential? step-errors) step-errors)
|
||||
(seq (distinct (flatten-form-errors step-errors))))}))
|
||||
(when (not= (first (steps linear-wizard))
|
||||
(step-key step))
|
||||
(when validation-route
|
||||
|
||||
Reference in New Issue
Block a user