From 1aa5219659b5e1122957a90bac30c7b01d4b1ede Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Thu, 11 Apr 2019 07:36:03 -0700 Subject: [PATCH] separating out manual. --- .../auto_ap/views/pages/transactions.cljs | 55 ++---------------- .../views/pages/transactions/manual.cljs | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+), 51 deletions(-) create mode 100644 src/cljs/auto_ap/views/pages/transactions/manual.cljs diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index 28f70616..f0ad3520 100644 --- a/src/cljs/auto_ap/views/pages/transactions.cljs +++ b/src/cljs/auto_ap/views/pages/transactions.cljs @@ -8,6 +8,7 @@ [auto-ap.views.components.paginator :refer [paginator]] [auto-ap.views.components.sorter :refer [sorted-column]] [auto-ap.views.pages.transactions.form :as edit] + [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])) @@ -175,55 +176,7 @@ [:a.tag {:href (:s3-url check) :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " (:check-number check) " (" (gstring/format "$%.2f" amount ) ")")])] ]))]]])))) -(re-frame/reg-event-fx - ::manual-yodlee-import - (fn [{:keys [db]} _] - {:dispatch [::events/modal-status ::manual-yodlee-import {:visible? true}] - :db (assoc-in db [::manual-yodlee-import] {:client-id (:id @(re-frame/subscribe [::subs/client])) - :data ""})})) -(re-frame/reg-sub - ::manual-yodlee-import - (fn [db] - (-> db ::manual-yodlee-import))) - -(re-frame/reg-event-fx - ::manual-yodlee-import-completed - (fn [{:keys [db]} [_ {:keys [imported errors]}]] - (re-frame/dispatch [::params-change {}]) - {:dispatch [::events/modal-completed ::manual-yodlee-import] - :db (-> db - (assoc-in [::notification :message] (str "Successfully imported " imported " transactions")) - (assoc-in [::notification :errors] errors))})) - -(re-frame/reg-event-fx - ::manual-yodlee-import-started - (fn [{:keys [db]} _] - (let [manual-yodlee-import (::manual-yodlee-import db)] - {:http {:token (:user db) - :method :post - :body (pr-str manual-yodlee-import) - :headers {"Content-Type" "application/edn"} - :uri (str "/api/transactions/batch-upload") - :on-success [::manual-yodlee-import-completed] - :on-error [::manual-yodlee-import-error]}}))) - - -(defn manual-yodlee-import-modal [] - (let [data @(re-frame/subscribe [::manual-yodlee-import]) - change-event [::events/change-form [::manual-yodlee-import]]] - [action-modal {:id ::manual-yodlee-import - :title "Manual Yodlee Import" - :action-text "Import" - :save-event [::manual-yodlee-import-started]} - [:div.field - [:label.label - "Yodlee manual import table"] - [:div.control - [bind-field - [:textarea.textarea {:field [:data] - :event change-event - :subscription data}]]]]])) (re-frame/reg-sub ::notification @@ -255,9 +208,9 @@ [:li (:description-original transaction) "-" (:details error)])]]))) [:div.is-pulled-right [:div.buttons - [:button.button.is-danger {:on-click (dispatch-event [::manual-yodlee-import])} + [:button.button.is-danger {:on-click (dispatch-event [::manual/manual-yodlee-import])} "Manage Rules"] - [:button.button.is-danger {:on-click (dispatch-event [::manual-yodlee-import])} + [:button.button.is-danger {:on-click (dispatch-event [::manual/manual-yodlee-import])} "Manual Yodlee Import"]]])) [transaction-table {:id :transactions :params (re-frame/subscribe [::params]) @@ -265,7 +218,7 @@ :status (re-frame/subscribe [::subs/status]) :on-params-change (fn [params] (re-frame/dispatch [::params-change params]))}] - [manual-yodlee-import-modal]])) + [manual/manual-yodlee-import-modal]])) {:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) })) (defn transactions-page [] diff --git a/src/cljs/auto_ap/views/pages/transactions/manual.cljs b/src/cljs/auto_ap/views/pages/transactions/manual.cljs new file mode 100644 index 00000000..809f221f --- /dev/null +++ b/src/cljs/auto_ap/views/pages/transactions/manual.cljs @@ -0,0 +1,57 @@ +(ns auto-ap.views.pages.transactions.manual + (:require [auto-ap.events :as events] + [auto-ap.subs :as subs] + [auto-ap.views.components.modal :refer [action-modal]] + [auto-ap.views.utils :refer [bind-field]] + [re-frame.core :as re-frame])) + +(re-frame/reg-event-fx + ::manual-yodlee-import + (fn [{:keys [db]} _] + {:dispatch [::events/modal-status ::manual-yodlee-import {:visible? true}] + :db (assoc-in db [::manual-yodlee-import] {:client-id (:id @(re-frame/subscribe [::subs/client])) + :data ""})})) + +(re-frame/reg-sub + ::manual-yodlee-import + (fn [db] + (-> db ::manual-yodlee-import))) + +(re-frame/reg-event-fx + ::manual-yodlee-import-completed + (fn [{:keys [db]} [_ {:keys [imported errors]}]] + (re-frame/dispatch [::params-change {}]) + {:dispatch [::events/modal-completed ::manual-yodlee-import] + :db (-> db + (assoc-in [::notification :message] (str "Successfully imported " imported " transactions")) + (assoc-in [::notification :errors] errors))})) + +(re-frame/reg-event-fx + ::manual-yodlee-import-started + (fn [{:keys [db]} _] + (let [manual-yodlee-import (::manual-yodlee-import db)] + {:http {:token (:user db) + :method :post + :body (pr-str manual-yodlee-import) + :headers {"Content-Type" "application/edn"} + :uri (str "/api/transactions/batch-upload") + :on-success [::manual-yodlee-import-completed] + :on-error [::manual-yodlee-import-error]}}))) + + +(defn manual-yodlee-import-modal [] + (let [data @(re-frame/subscribe [::manual-yodlee-import]) + change-event [::events/change-form [::manual-yodlee-import]]] + [action-modal {:id ::manual-yodlee-import + :title "Manual Yodlee Import" + :action-text "Import" + :save-event [::manual-yodlee-import-started]} + [:div.field + [:label.label + "Yodlee manual import table"] + [:div.control + [bind-field + [:textarea.textarea {:field [:data] + :event change-event + :subscription data}]]]]])) +