fixing problems with slowness and fixing error with wrong locations.

This commit is contained in:
Bryce Covert
2018-07-27 08:29:01 -07:00
parent fda152b8e8
commit 523a96f51b
4 changed files with 29 additions and 23 deletions

View File

@@ -429,6 +429,7 @@
(let [{{:keys [expense-accounts total ] :or {expense-accounts [] total 0} {:keys [locations]} :company} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
multi-location? (> (count locations) 1)
change-event [::events/change-form [::change-expense-accounts]]
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
expense-accounts-total (->> expense-accounts
(map :amount)
(map js/parseFloat)
@@ -454,15 +455,16 @@
[:th {:style {:width "5em"}}]]]
[:tbody
(for [[expense-account index] (map vector expense-accounts (range))]
^{:key index}
[:tr
[:td.expandable [:div.control
[bind-field
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/chooseable-expense-accounts]))
:type "typeahead"
:field [:invoice :expense-accounts index :expense-account-id]
:event change-event
:spec ::invoice/vendor-id
:subscription data}]]]]
[bind-field
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) chooseable-expense-accounts)
:type "typeahead"
:field [:invoice :expense-accounts index :expense-account-id]
:event change-event
:spec ::invoice/vendor-id
:subscription data}]]]]
(when multi-location?
[:td
@@ -476,7 +478,7 @@
:spec (set locations)
:event change-event
:subscription data}
(map (fn [l] [:option {:value l} l]) locations)]]])])
(map (fn [l] ^{:key l} [:option {:value l} l]) locations)]]])])
[:td
[:div.control