improvements to rule gen to make it so you can't set account incorrectly.
This commit is contained in:
@@ -95,9 +95,14 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::expense-account-changed
|
::expense-account-changed
|
||||||
(fn [_ [_ event expense-accounts max-value field value]]
|
(fn [_ [_ event expense-accounts max-value field value]]
|
||||||
|
(println field value)
|
||||||
(let [updated-accounts (cond-> expense-accounts
|
(let [updated-accounts (cond-> expense-accounts
|
||||||
true (assoc-in field value)
|
true (assoc-in field value)
|
||||||
(= (list :account :id) (drop 1 field)) (assoc-in [(first field) :account] @(re-frame/subscribe [::subs/account nil value]))
|
(= (list :account) (drop 1 field)) (assoc-in [(first field) :location] nil)
|
||||||
|
|
||||||
|
(= (list :account :id) (drop 1 field)) (-> (assoc-in [(first field) :account] @(re-frame/subscribe [::subs/account nil value]))
|
||||||
|
(assoc-in [(first field) :location] nil))
|
||||||
|
|
||||||
(= (list :amount-percentage) (drop 1 field)) (assoc-in [(first field) :amount]
|
(= (list :amount-percentage) (drop 1 field)) (assoc-in [(first field) :amount]
|
||||||
(js/parseFloat
|
(js/parseFloat
|
||||||
(goog.string/format "%.2f"
|
(goog.string/format "%.2f"
|
||||||
@@ -108,6 +113,7 @@
|
|||||||
updated-accounts (if-let [location (get-in updated-accounts [(first field) :account :location])]
|
updated-accounts (if-let [location (get-in updated-accounts [(first field) :account :location])]
|
||||||
(assoc-in updated-accounts [(first field) :location] location)
|
(assoc-in updated-accounts [(first field) :location] location)
|
||||||
updated-accounts)]
|
updated-accounts)]
|
||||||
|
(println updated-accounts)
|
||||||
{:dispatch (into event [updated-accounts])})))
|
{:dispatch (into event [updated-accounts])})))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user