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]
|
(defn account-grid-body* [request]
|
||||||
(let [snapshot (-> request :multi-form-state :snapshot)
|
(let [snapshot (-> request :multi-form-state :snapshot)
|
||||||
amount-mode (or (:amount-mode 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 {:headers [(com/data-grid-header {} "Account")
|
||||||
(com/data-grid-header {:class "w-32"} "Location")
|
(com/data-grid-header {:class "w-32"} "Location")
|
||||||
(com/data-grid-header {:class "w-16"}
|
(com/data-grid-header {:class "w-16"}
|
||||||
(com/radio-card {:options [{:value "$" :content "$"}
|
(com/radio-card {:options [{:value "$" :content "$"}
|
||||||
{:value "%" :content "%"}]
|
{:value "%" :content "%"}]
|
||||||
:value amount-mode
|
:value amount-mode
|
||||||
:name "step-params[amount-mode]"
|
:name "step-params[amount-mode]"
|
||||||
:hx-post (bidi/path-for ssr-routes/only-routes ::route/toggle-amount-mode)
|
:orientation :horizontal
|
||||||
:hx-target "#account-grid-body"
|
:hx-post (bidi/path-for ssr-routes/only-routes ::route/toggle-amount-mode)
|
||||||
:hx-swap "outerHTML"
|
:hx-target "#account-grid-body"
|
||||||
:hx-include "closest form"}))
|
:hx-swap "outerHTML"
|
||||||
|
:hx-include "closest form"}))
|
||||||
(com/data-grid-header {:class "w-16"})]}
|
(com/data-grid-header {:class "w-16"})]}
|
||||||
(fc/cursor-map #(transaction-account-row* {:value %
|
(fc/cursor-map #(transaction-account-row* {:value %
|
||||||
:client-id (-> request :entity :transaction/client :db/id)
|
:client-id (-> request :entity :transaction/client :db/id)
|
||||||
@@ -1109,7 +1110,7 @@
|
|||||||
client-id (->db-id (:transaction/client tx-data))
|
client-id (->db-id (:transaction/client tx-data))
|
||||||
existing-tx (d-transactions/get-by-id tx-id)
|
existing-tx (d-transactions/get-by-id tx-id)
|
||||||
amount-mode (or (:amount-mode tx-data) "$")
|
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)
|
tx-data (if (= "%" amount-mode)
|
||||||
(update tx-data :transaction/accounts
|
(update tx-data :transaction/accounts
|
||||||
#(map (fn [account dollar-amount]
|
#(map (fn [account dollar-amount]
|
||||||
@@ -1314,12 +1315,12 @@
|
|||||||
(fn render [cursor request]
|
(fn render [cursor request]
|
||||||
(let [snapshot (-> request :multi-form-state :snapshot)
|
(let [snapshot (-> request :multi-form-state :snapshot)
|
||||||
amount-mode (or (:amount-mode snapshot) "$")
|
amount-mode (or (:amount-mode snapshot) "$")
|
||||||
total (Math/abs (:transaction/amount snapshot))]
|
total (Math/abs (or (:transaction/amount snapshot) 0.0))]
|
||||||
(transaction-account-row*
|
(transaction-account-row*
|
||||||
{:value cursor
|
{:value cursor
|
||||||
:client-id (:client-id (:query-params request))
|
:client-id (:client-id (:query-params request))
|
||||||
:amount-mode amount-mode
|
:amount-mode amount-mode
|
||||||
:total total})))
|
:total total})))
|
||||||
(fn build-new-row [base _]
|
(fn build-new-row [base _]
|
||||||
(assoc base :transaction-account/location "Shared")))
|
(assoc base :transaction-account/location "Shared")))
|
||||||
(wrap-schema-enforce :query-schema [:map
|
(wrap-schema-enforce :query-schema [:map
|
||||||
|
|||||||
Reference in New Issue
Block a user