the form is pretty good now.
This commit is contained in:
@@ -53,21 +53,19 @@
|
||||
(assoc :potential-payment-matches potential-payment-matches)
|
||||
(update :accounts expense-accounts-field/from-graphql (:amount which) locations))))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
(re-frame/reg-event-db
|
||||
::changed
|
||||
[(forms/in-form ::form)]
|
||||
(fn [{{:keys [data]} :db} [_ field value]]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client data))])]
|
||||
(if (and (= [:vendor] field)
|
||||
value
|
||||
(expense-accounts-field/can-replace-with-default? (:accounts data)))
|
||||
{:dispatch [::forms/change ::form
|
||||
field value
|
||||
[:accounts] (expense-accounts-field/default-account (:accounts data)
|
||||
@(re-frame/subscribe [::subs/vendor-default-account value])
|
||||
(:amount data)
|
||||
locations)]}
|
||||
{:dispatch [::forms/change ::form field value]}))))
|
||||
(forms/change-handler ::form
|
||||
(fn [data field value]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client data))])]
|
||||
(if (and (= [:vendor] field)
|
||||
value
|
||||
(expense-accounts-field/can-replace-with-default? (:accounts data)))
|
||||
[[:accounts] (expense-accounts-field/default-account (:accounts data)
|
||||
@(re-frame/subscribe [::subs/vendor-default-account value])
|
||||
(:amount data)
|
||||
locations)]
|
||||
[])))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::saving
|
||||
|
||||
Reference in New Issue
Block a user