From f6d0870f320f1351351aea60c0c67492127132da Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Thu, 11 Apr 2019 08:41:08 -0700 Subject: [PATCH] last refactoring before adding new accounts. --- .../auto_ap/views/pages/transactions.cljs | 24 +++---------- .../views/pages/transactions/common.cljs | 13 +++++++ .../views/pages/transactions/form.cljs | 36 +++++++------------ 3 files changed, 31 insertions(+), 42 deletions(-) create mode 100644 src/cljs/auto_ap/views/pages/transactions/common.cljs diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index ab859841..b3ef94d7 100644 --- a/src/cljs/auto_ap/views/pages/transactions.cljs +++ b/src/cljs/auto_ap/views/pages/transactions.cljs @@ -9,23 +9,14 @@ [auto-ap.views.components.sorter :refer [sorted-column]] [auto-ap.views.pages.transactions.form :as edit] [auto-ap.views.pages.transactions.table :as table] + [auto-ap.views.pages.transactions.common :refer [transaction-read]] [auto-ap.utils :refer [replace-by]] [auto-ap.views.pages.transactions.manual :as manual] [auto-ap.views.utils :refer [bind-field date->str dispatch-event nf]] [goog.string :as gstring] [re-frame.core :as re-frame])) -(def transaction-read - [:id - :amount - [:vendor [:name :id]] - :date - :post_date - :status - :description_original - [:payment [:check_number :s3_url]] - [:client [:name :id]] - [:bank-account [:name :yodlee-account-id]]]) + (re-frame/reg-event-db ::edit-completed @@ -75,12 +66,6 @@ (assoc ::transaction-page (first (:transaction-page data))) (assoc-in [:status :loading] false)))) -(re-frame/reg-event-fx - ::invalidated - (fn [cofx [_ params]] - {:dispatch [::params-change @(re-frame/subscribe [::params])]})) - - (re-frame/reg-event-db ::change-selected-bank-account (fn [db [_ key value]] @@ -122,8 +107,9 @@ [:li (:description-original transaction) "-" (:details error)])]]))) [:div.is-pulled-right [:div.buttons - [:button.button.is-danger {:on-click (dispatch-event [::manual/opening])} - "Manage Rules"] + (comment + [:button.button.is-danger {:on-click (dispatch-event [::manual/opening])} + "Manage Rules"]) [:button.button.is-danger {:on-click (dispatch-event [::manual/opening])} "Manual Yodlee Import"]]])) [table/table {:id :transactions diff --git a/src/cljs/auto_ap/views/pages/transactions/common.cljs b/src/cljs/auto_ap/views/pages/transactions/common.cljs new file mode 100644 index 00000000..fe2869b4 --- /dev/null +++ b/src/cljs/auto_ap/views/pages/transactions/common.cljs @@ -0,0 +1,13 @@ +(ns auto-ap.views.pages.transactions.common) + +(def transaction-read + [:id + :amount + [:vendor [:name :id]] + :date + :post_date + :status + :description_original + [:payment [:check_number :s3_url]] + [:client [:name :id]] + [:bank-account [:name :yodlee-account-id]]]) diff --git a/src/cljs/auto_ap/views/pages/transactions/form.cljs b/src/cljs/auto_ap/views/pages/transactions/form.cljs index 196d8fec..028eb164 100644 --- a/src/cljs/auto_ap/views/pages/transactions/form.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/form.cljs @@ -2,6 +2,7 @@ (:require [auto-ap.forms :as forms] [auto-ap.subs :as subs] [auto-ap.views.components.typeahead :refer [typeahead]] + [auto-ap.views.pages.transactions.common :refer [transaction-read]] [auto-ap.views.utils :refer [bind-field]] [re-frame.core :as re-frame])) @@ -32,26 +33,14 @@ (fn [{:keys [db]} [_ edit-completed]] (when @(re-frame/subscribe [::can-submit]) (let [{{:keys [id vendor-id]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])] - {:db (forms/loading db ::edit-transaction ) :graphql {:token (-> db :user) :query-obj {:venia/operation {:operation/type :mutation :operation/name "EditTransaction"} - :venia/queries [{:query/data [:edit-transaction {:transaction {:id id :vendor-id vendor-id}} - - [:id - :amount - [:vendor [:name :id]] - :date - :post_date - :status - :description_original - [:payment [:check_number :s3_url]] - [:client [:name :id]] - [:bank-account [:name :yodlee-account-id]]]]}]} + transaction-read]}]} :on-success [::edited edit-completed] :on-error [::forms/save-error ::edit-transaction]}})))) @@ -70,8 +59,9 @@ (re-frame/dispatch-sync [::saving edit-completed]))} [:h1.title.is-2 "Edit Transaction"] - [:div.notification - [:p "This transaction matches Invoice 'ABC' for 'DBI Beverages'. " [:a "Create payment and match"] "."]] + (comment + [:div.notification + [:p "This transaction matches Invoice 'ABC' for 'DBI Beverages'. " [:a "Create payment and match"] "."]]) [:div.field @@ -96,14 +86,14 @@ :event change-event :subscription data}]]]] - [:div.field - - [:p.control - [:label.checkbox - [:input.checkbox {:type "checkbox" - :field [:always-map] - :subscription data}] - " Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]] + (comment + [:div.field + [:p.control + [:label.checkbox + [:input.checkbox {:type "checkbox" + :field [:always-map] + :subscription data}] + " Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]]) [:div.field [:p.help "Credit Account"]