form improvements.

This commit is contained in:
Bryce Covert
2019-05-17 16:22:29 -07:00
parent c56e5372e4
commit 598c58a6bd

View File

@@ -104,7 +104,10 @@
:dom-gte nil :dom-gte nil
:vendor nil :vendor nil
:transaction-approval-status :unapproved :transaction-approval-status :unapproved
:accounts []))))) :accounts [{:id (str "new-" (random-uuid))
:amount-mode "%"
:amount-percentage 100
:location nil}])))))
(re-frame/reg-event-db (re-frame/reg-event-db
::editing ::editing
@@ -132,7 +135,17 @@
::changed ::changed
(forms/change-handler ::form (forms/change-handler ::form
(fn [data field value] (fn [data field value]
[]))) (cond (and (= [:vendor] field)
value
(doto (expense-accounts-field/can-replace-with-default? (:accounts data))
println))
[[:accounts] (expense-accounts-field/default-account (:accounts data)
@(re-frame/subscribe [::subs/vendor-default-account value])
(:total data)
[])]
:else
[]))))
(re-frame/reg-event-fx (re-frame/reg-event-fx
::saving ::saving
@@ -192,6 +205,7 @@
[form (assoc params :title "New Transaction Rule") [form (assoc params :title "New Transaction Rule")
[field "Note" [field "Note"
[:input.input {:type "text" [:input.input {:type "text"
:auto-focus true
:field [:note] :field [:note]
:spec ::entity/note}]] :spec ::entity/note}]]
@@ -199,14 +213,12 @@
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients]) [typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
:match->text :name :match->text :name
:type "typeahead-entity" :type "typeahead-entity"
:auto-focus (if @(re-frame/subscribe [::subs/client]) false true)
:field [:client] :field [:client]
:spec ::entity/client}]] :spec ::entity/client}]]
[field "Bank account" [field "Bank account"
[typeahead-entity {:matches @(re-frame/subscribe [::subs/real-bank-accounts-for-client (:client data)]) [typeahead-entity {:matches @(re-frame/subscribe [::subs/real-bank-accounts-for-client (:client data)])
:match->text :name :match->text :name
:auto-focus (if @(re-frame/subscribe [::subs/client]) true false)
:type "typeahead-entity" :type "typeahead-entity"
:field [:bank-account] :field [:bank-account]
:spec ::entity/bank-account}]] :spec ::entity/bank-account}]]
@@ -270,7 +282,6 @@
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors]) [typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
:match->text :name :match->text :name
:type "typeahead-entity" :type "typeahead-entity"
:auto-focus (if @(re-frame/subscribe [::subs/vendors]) false true)
:field [:vendor] :field [:vendor]
:spec ::entity/vendor}]] :spec ::entity/vendor}]]