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

@@ -0,0 +1 @@
-- 1532704782 DOWN fix-iguanas-locations

View File

@@ -0,0 +1,2 @@
-- 1532704782 UP fix-iguanas-locations
update companies set data = '{:locations ["DT" "EG" "SC" "SG" "CB" "BH"] :bank-accounts [{:number "000158443280" :id 1 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1120 BofA Exp and Main - 3280" :yodlee-account-id 16279663} {:number "" :id 2 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1122 BofA Squirrel - 5255" :yodlee-account-id 16279666} {:number "000158743279" :id 3 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1121 BofA Tax & SLO - 3279" :yodlee-account-id 16279664} {:number "" :id 4 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1123 BofA Paychecks - 5250" :yodlee-account-id 16279665} {:number "" :id 5 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1125 BofA EG Exp - 5598" :yodlee-account-id 16279667} {:number "" :id 6 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1126 BofA SC Exp - 5318" :yodlee-account-id 16279668} {:number "" :id 7 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1127 BofA SG Exp - 8407" :yodlee-account-id 16279669} {:number "" :id 8 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1124 BofA DT Exp - 8279" :yodlee-account-id 16279670} {:number "" :id 9 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1128 BofA CB Exp - 2495" :yodlee-account-id 16279671} {:number "" :id 10 :check-number 10000 :bank-name "Bank of America" :bank-code "11-35/1210" :routing "121000358" :name "A1129 BofA BH Exp - 1665" :yodlee-account-id 16279672}]}' where id = 39;

View File

@@ -18,11 +18,12 @@
]
(r/create-class
{:reagent-render (fn [{:keys [matches on-change field text-field value class not-found-description]}]
(let [valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
:when (str/includes? (.toLowerCase t) (.toLowerCase @text))]
(let [text @text
valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
:when (str/includes? (.toLowerCase t) (.toLowerCase text))]
match))
valid-matches (if (and not-found-description @text)
(concat valid-matches [[:not-found (not-found-description @text) (not-found-value @text)]])
valid-matches (if (and not-found-description text)
(concat valid-matches [[:not-found (not-found-description text) (not-found-value text)]])
valid-matches)]
[:div.typeahead
@@ -37,19 +38,19 @@
false))}
[:div.control
[:div.tags.has-addons
[:span.tag @text]
[:span.tag text]
[:a.tag.is-delete {:on-click (fn [] (select [nil "" nil]))}]]]]
[:input.input {:type "text"
:class class
:field field
:value @text
:value text
:auto-focus auto-focus
:on-blur (fn [e]
(cond @selected
nil
(#{"" nil} @text)
(#{"" nil} text)
nil
(seq valid-matches)
@@ -71,16 +72,16 @@
(select [nil (.. e -target -value)]))}
])
(cond
(and (seq @text)
(and (seq text)
(not @selected)
(seq valid-matches))
[:div.typeahead-menu
[:ul
(for [[id t :as match] valid-matches]
[:li.typeahead-suggestion {:class (if (= id @highlighted)
"typeahead-highlighted")
:on-mouse-down #(do (select match))} t])]]
(let [h @highlighted]
[:div.typeahead-menu
[:ul
(for [[id t :as match] valid-matches]
^{:key id} [:li.typeahead-suggestion {:class (if (= id h)
"typeahead-highlighted")
:on-mouse-down #(do (select match))} t])]])

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