Finished separating out manual import.
This commit is contained in:
@@ -37,6 +37,16 @@
|
|||||||
(assoc edit-transaction :class "live-added")
|
(assoc edit-transaction :class "live-added")
|
||||||
t))
|
t))
|
||||||
ts))))))
|
ts))))))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::manual-import-completed
|
||||||
|
(fn [{:keys [db]} [_ {:keys [imported errors]}]]
|
||||||
|
(println "MANUAL FINISHED")
|
||||||
|
{:dispatch [::params-change {}]
|
||||||
|
:db (-> db
|
||||||
|
(assoc-in [::notification :message] (str "Successfully imported " imported " transactions"))
|
||||||
|
(assoc-in [::notification :errors] errors))}))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::transaction-page
|
::transaction-page
|
||||||
(fn [db]
|
(fn [db]
|
||||||
@@ -208,9 +218,9 @@
|
|||||||
[:li (:description-original transaction) "-" (:details error)])]])))
|
[:li (:description-original transaction) "-" (:details error)])]])))
|
||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
[:button.button.is-danger {:on-click (dispatch-event [::manual/manual-yodlee-import])}
|
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
|
||||||
"Manage Rules"]
|
"Manage Rules"]
|
||||||
[:button.button.is-danger {:on-click (dispatch-event [::manual/manual-yodlee-import])}
|
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
|
||||||
"Manual Yodlee Import"]]]))
|
"Manual Yodlee Import"]]]))
|
||||||
[transaction-table {:id :transactions
|
[transaction-table {:id :transactions
|
||||||
:params (re-frame/subscribe [::params])
|
:params (re-frame/subscribe [::params])
|
||||||
@@ -218,7 +228,7 @@
|
|||||||
:status (re-frame/subscribe [::subs/status])
|
:status (re-frame/subscribe [::subs/status])
|
||||||
:on-params-change (fn [params]
|
:on-params-change (fn [params]
|
||||||
(re-frame/dispatch [::params-change params]))}]
|
(re-frame/dispatch [::params-change params]))}]
|
||||||
[manual/manual-yodlee-import-modal]]))
|
[manual/modal {:import-completed [::manual-import-completed ]}]]))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
||||||
|
|
||||||
(defn transactions-page []
|
(defn transactions-page []
|
||||||
|
|||||||
@@ -6,46 +6,48 @@
|
|||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::manual-yodlee-import
|
::opening
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
{:dispatch [::events/modal-status ::manual-yodlee-import {:visible? true}]
|
{:dispatch [::events/modal-status ::import {:visible? true}]
|
||||||
:db (assoc-in db [::manual-yodlee-import] {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
:db (assoc-in db [::import] {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||||
:data ""})}))
|
:data ""})}))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::manual-yodlee-import
|
::import
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db ::manual-yodlee-import)))
|
(-> db ::import)))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::manual-yodlee-import-completed
|
::import-completed
|
||||||
(fn [{:keys [db]} [_ {:keys [imported errors]}]]
|
(fn [{:keys [db]} [_ import-completed-event {:keys [imported errors] :as result}]]
|
||||||
(re-frame/dispatch [::params-change {}])
|
{:dispatch-n [[::events/modal-completed ::import]
|
||||||
{:dispatch [::events/modal-completed ::manual-yodlee-import]
|
(conj import-completed-event result)]}))
|
||||||
:db (-> db
|
|
||||||
(assoc-in [::notification :message] (str "Successfully imported " imported " transactions"))
|
|
||||||
(assoc-in [::notification :errors] errors))}))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::manual-yodlee-import-started
|
::import-error
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} [_ result]]
|
||||||
(let [manual-yodlee-import (::manual-yodlee-import db)]
|
{:dispatch [::events/modal-failed ::import "Import failed"]}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::import-started
|
||||||
|
(fn [{:keys [db]} [_ import-completed-event]]
|
||||||
|
(let [import (::import db)]
|
||||||
{:http {:token (:user db)
|
{:http {:token (:user db)
|
||||||
:method :post
|
:method :post
|
||||||
:body (pr-str manual-yodlee-import)
|
:body (pr-str import)
|
||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:uri (str "/api/transactions/batch-upload")
|
:uri (str "/api/transactions/batch-upload")
|
||||||
:on-success [::manual-yodlee-import-completed]
|
:on-success [::import-completed import-completed-event]
|
||||||
:on-error [::manual-yodlee-import-error]}})))
|
:on-error [::import-error]}})))
|
||||||
|
|
||||||
|
|
||||||
(defn manual-yodlee-import-modal []
|
(defn modal [{import-completed-event :import-completed}]
|
||||||
(let [data @(re-frame/subscribe [::manual-yodlee-import])
|
(let [data @(re-frame/subscribe [::import])
|
||||||
change-event [::events/change-form [::manual-yodlee-import]]]
|
change-event [::events/change-form [::import]]]
|
||||||
[action-modal {:id ::manual-yodlee-import
|
[action-modal {:id ::import
|
||||||
:title "Manual Yodlee Import"
|
:title "Manual Yodlee Import"
|
||||||
:action-text "Import"
|
:action-text "Import"
|
||||||
:save-event [::manual-yodlee-import-started]}
|
:save-event [::import-started import-completed-event]}
|
||||||
[:div.field
|
[:div.field
|
||||||
[:label.label
|
[:label.label
|
||||||
"Yodlee manual import table"]
|
"Yodlee manual import table"]
|
||||||
|
|||||||
Reference in New Issue
Block a user