fix: normalize account ref map to db/id in simple mode rendering
When a transaction is pre-coded, the snapshot stores :transaction-account/account
as a Datomic ref map {:db/id N} rather than a bare integer. simple-mode-fields*
and the simpleAccountId Alpine initializer both need the integer id, not the map,
to correctly populate the account typeahead value and the x-hx-val binding.
This commit is contained in:
@@ -191,7 +191,8 @@
|
|||||||
(:transaction/client snapshot))
|
(:transaction/client snapshot))
|
||||||
existing-row (first (or (seq (:transaction/accounts step-params))
|
existing-row (first (or (seq (:transaction/accounts step-params))
|
||||||
(seq (:transaction/accounts snapshot))))
|
(seq (:transaction/accounts snapshot))))
|
||||||
account-val (:transaction-account/account existing-row)
|
account-val (let [av (:transaction-account/account existing-row)]
|
||||||
|
(if (map? av) (:db/id av) av))
|
||||||
location-val (or (:transaction-account/location existing-row) "Shared")
|
location-val (or (:transaction-account/location existing-row) "Shared")
|
||||||
account-id (when (nat-int? account-val)
|
account-id (when (nat-int? account-val)
|
||||||
(dc/pull (dc/db conn) '[:account/location] account-val))
|
(dc/pull (dc/db conn) '[:account/location] account-val))
|
||||||
@@ -527,8 +528,8 @@
|
|||||||
:content-fn (fn [c] (pull-attr (dc/db conn) :vendor/name c))})]))]
|
:content-fn (fn [c] (pull-attr (dc/db conn) :vendor/name c))})]))]
|
||||||
(if (= mode :simple)
|
(if (= mode :simple)
|
||||||
[:div {:x-data (hx/json {:simpleAccountId
|
[:div {:x-data (hx/json {:simpleAccountId
|
||||||
(-> (first all-accounts)
|
(let [av (-> (first all-accounts) :transaction-account/account)]
|
||||||
:transaction-account/account)})}
|
(if (map? av) (:db/id av) av))})}
|
||||||
(simple-mode-fields* request)]
|
(simple-mode-fields* request)]
|
||||||
[:div
|
[:div
|
||||||
(when (<= row-count 1)
|
(when (<= row-count 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user