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 (r/create-class
{:reagent-render (fn [{:keys [matches on-change field text-field value class not-found-description]}] {: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)) (let [text @text
:when (str/includes? (.toLowerCase t) (.toLowerCase @text))] valid-matches (take 5 (for [[[id t :as match] i] (map vector matches (range))
:when (str/includes? (.toLowerCase t) (.toLowerCase text))]
match)) match))
valid-matches (if (and not-found-description @text) valid-matches (if (and not-found-description text)
(concat valid-matches [[:not-found (not-found-description @text) (not-found-value @text)]]) (concat valid-matches [[:not-found (not-found-description text) (not-found-value text)]])
valid-matches)] valid-matches)]
[:div.typeahead [:div.typeahead
@@ -37,19 +38,19 @@
false))} false))}
[:div.control [:div.control
[:div.tags.has-addons [:div.tags.has-addons
[:span.tag @text] [:span.tag text]
[:a.tag.is-delete {:on-click (fn [] (select [nil "" nil]))}]]]] [:a.tag.is-delete {:on-click (fn [] (select [nil "" nil]))}]]]]
[:input.input {:type "text" [:input.input {:type "text"
:class class :class class
:field field :field field
:value @text :value text
:auto-focus auto-focus :auto-focus auto-focus
:on-blur (fn [e] :on-blur (fn [e]
(cond @selected (cond @selected
nil nil
(#{"" nil} @text) (#{"" nil} text)
nil nil
(seq valid-matches) (seq valid-matches)
@@ -71,16 +72,16 @@
(select [nil (.. e -target -value)]))} (select [nil (.. e -target -value)]))}
]) ])
(cond (cond
(and (seq @text) (and (seq text)
(not @selected) (not @selected)
(seq valid-matches)) (seq valid-matches))
(let [h @highlighted]
[:div.typeahead-menu [:div.typeahead-menu
[:ul [:ul
(for [[id t :as match] valid-matches] (for [[id t :as match] valid-matches]
^{:key id} [:li.typeahead-suggestion {:class (if (= id h)
[:li.typeahead-suggestion {:class (if (= id @highlighted)
"typeahead-highlighted") "typeahead-highlighted")
:on-mouse-down #(do (select match))} t])]] :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]) (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) multi-location? (> (count locations) 1)
change-event [::events/change-form [::change-expense-accounts]] change-event [::events/change-form [::change-expense-accounts]]
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
expense-accounts-total (->> expense-accounts expense-accounts-total (->> expense-accounts
(map :amount) (map :amount)
(map js/parseFloat) (map js/parseFloat)
@@ -454,10 +455,11 @@
[:th {:style {:width "5em"}}]]] [:th {:style {:width "5em"}}]]]
[:tbody [:tbody
(for [[expense-account index] (map vector expense-accounts (range))] (for [[expense-account index] (map vector expense-accounts (range))]
^{:key index}
[:tr [:tr
[:td.expandable [:div.control [:td.expandable [:div.control
[bind-field [bind-field
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/chooseable-expense-accounts])) [typeahead {:matches (map (fn [x] [(:id x) (:name x)]) chooseable-expense-accounts)
:type "typeahead" :type "typeahead"
:field [:invoice :expense-accounts index :expense-account-id] :field [:invoice :expense-accounts index :expense-account-id]
:event change-event :event change-event
@@ -476,7 +478,7 @@
:spec (set locations) :spec (set locations)
:event change-event :event change-event
:subscription data} :subscription data}
(map (fn [l] [:option {:value l} l]) locations)]]])]) (map (fn [l] ^{:key l} [:option {:value l} l]) locations)]]])])
[:td [:td
[:div.control [:div.control