Fix $/% toggle: handle nil amounts and make toggle horizontal
- Fix Math/abs nil error when adding new accounts by using (or value 0.0) - Fix Math/abs nil in account-grid-body* and save-handler for safety - Make $/% radio toggle display side-by-side using :orientation :horizontal - Apply fixes to edit-wizard-new-account render, account-grid-body*, and save-handler
This commit is contained in:
@@ -297,18 +297,19 @@
|
||||
(defn account-grid-body* [request]
|
||||
(let [snapshot (-> request :multi-form-state :snapshot)
|
||||
amount-mode (or (:amount-mode snapshot) "$")
|
||||
total (Math/abs (:transaction/amount snapshot))]
|
||||
total (Math/abs (or (:transaction/amount snapshot) 0.0))]
|
||||
(com/data-grid {:headers [(com/data-grid-header {} "Account")
|
||||
(com/data-grid-header {:class "w-32"} "Location")
|
||||
(com/data-grid-header {:class "w-16"}
|
||||
(com/radio-card {:options [{:value "$" :content "$"}
|
||||
{:value "%" :content "%"}]
|
||||
:value amount-mode
|
||||
:name "step-params[amount-mode]"
|
||||
:hx-post (bidi/path-for ssr-routes/only-routes ::route/toggle-amount-mode)
|
||||
:hx-target "#account-grid-body"
|
||||
:hx-swap "outerHTML"
|
||||
:hx-include "closest form"}))
|
||||
(com/radio-card {:options [{:value "$" :content "$"}
|
||||
{:value "%" :content "%"}]
|
||||
:value amount-mode
|
||||
:name "step-params[amount-mode]"
|
||||
:orientation :horizontal
|
||||
:hx-post (bidi/path-for ssr-routes/only-routes ::route/toggle-amount-mode)
|
||||
:hx-target "#account-grid-body"
|
||||
:hx-swap "outerHTML"
|
||||
:hx-include "closest form"}))
|
||||
(com/data-grid-header {:class "w-16"})]}
|
||||
(fc/cursor-map #(transaction-account-row* {:value %
|
||||
:client-id (-> request :entity :transaction/client :db/id)
|
||||
@@ -1109,7 +1110,7 @@
|
||||
client-id (->db-id (:transaction/client tx-data))
|
||||
existing-tx (d-transactions/get-by-id tx-id)
|
||||
amount-mode (or (:amount-mode tx-data) "$")
|
||||
total (Math/abs (:transaction/amount existing-tx))
|
||||
total (Math/abs (or (:transaction/amount existing-tx) 0.0))
|
||||
tx-data (if (= "%" amount-mode)
|
||||
(update tx-data :transaction/accounts
|
||||
#(map (fn [account dollar-amount]
|
||||
@@ -1314,12 +1315,12 @@
|
||||
(fn render [cursor request]
|
||||
(let [snapshot (-> request :multi-form-state :snapshot)
|
||||
amount-mode (or (:amount-mode snapshot) "$")
|
||||
total (Math/abs (:transaction/amount snapshot))]
|
||||
(transaction-account-row*
|
||||
{:value cursor
|
||||
:client-id (:client-id (:query-params request))
|
||||
:amount-mode amount-mode
|
||||
:total total})))
|
||||
total (Math/abs (or (:transaction/amount snapshot) 0.0))]
|
||||
(transaction-account-row*
|
||||
{:value cursor
|
||||
:client-id (:client-id (:query-params request))
|
||||
:amount-mode amount-mode
|
||||
:total total})))
|
||||
(fn build-new-row [base _]
|
||||
(assoc base :transaction-account/location "Shared")))
|
||||
(wrap-schema-enforce :query-schema [:map
|
||||
|
||||
Reference in New Issue
Block a user