Close to supporting bulk upload

This commit is contained in:
2022-09-30 16:58:17 -07:00
parent ae1500be9a
commit 556d6311ff
2 changed files with 42 additions and 13 deletions

View File

@@ -255,11 +255,12 @@
Consumer Consumer
["status" "can-submit" "fullwidth?"] ["status" "can-submit" "fullwidth?"]
(fn [status can-submit fullwidth?] (fn [status can-submit fullwidth?]
[:button.button.is-medium.is-primary {:disabled (or (status/disabled-for status) [:button.button.is-primary {:disabled (or (status/disabled-for status)
(not can-submit)) (not can-submit))
:class (cond-> (or class []) :class (cond-> (or class [])
(status/class-for status) (into (status/class-for status)) (status/class-for status) (into (status/class-for status))
fullwidth? (conj "is-fullwidth")) } fullwidth? (conj "is-fullwidth")
(not= "is-small" class) (conj "is-medium")) }
child])))) child]))))
(defn hidden-submit-button [] (defn hidden-submit-button []

View File

@@ -9,11 +9,15 @@
[auto-ap.views.utils :refer [dispatch-event with-user]] [auto-ap.views.utils :refer [dispatch-event with-user]]
[clojure.set :as set] [clojure.set :as set]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[vimsical.re-frame.fx.track :as track])) [vimsical.re-frame.fx.track :as track]
[auto-ap.forms.builder :as form-builder]
[vimsical.re-frame.cofx.inject :as inject]
[auto-ap.forms :as forms]
[clojure.string :as str]))
(def default-read [:name :start-date :end-date :status]) (def default-read [:name :start-date :end-date :status])
(def job-types [:yodlee2 :yodlee2-accounts :intuit :plaid]) (def job-types [:yodlee2 :yodlee2-accounts :intuit :plaid :bulk-journal-import])
(re-frame/reg-event-fx (re-frame/reg-event-fx
::params-change ::params-change
@@ -48,16 +52,24 @@
(re-frame/reg-event-fx (re-frame/reg-event-fx
::request ::request
[with-user ] [with-user
(fn [{:keys [user]} [_ which]] (re-frame/inject-cofx ::inject/sub [::forms/form ::bulk-journal-form])
{:graphql {:token user ]
(fn [{:keys [user] ::forms/keys [form]} [_ which]]
{:graphql {:token user
:owns-state {:single which} :owns-state {:single which}
:query-obj :query-obj
{:venia/operation {:operation/type :mutation {:venia/operation {:operation/type :mutation
:operation/name "RequestJob"} :operation/name "RequestJob"}
:venia/variables [{:variable/name "args"
:variable/type :String
:variable/default (when (= which :bulk-journal-import)
(str/replace (pr-str (:data form))
"\"" "\\\""))}]
:venia/queries [{:query/data :venia/queries [{:query/data
[:request-job [:request-job
{:which (name which)} {:which (name which)
:args :$args}
[:message]]}]} [:message]]}]}
:on-success [::success]}})) :on-success [::success]}}))
@@ -84,7 +96,7 @@
(defn job-button [{:keys [which]} content] (defn job-button [{:keys [which]} content]
(let [status @(re-frame/subscribe [::status/single which])] (let [status @(re-frame/subscribe [::status/single which])]
(println status) (println status)
[:button.button.is-primary-two {:type "button" [:button.button.is-primary.is-small {:type "button"
:on-click (dispatch-event [::request which]) :on-click (dispatch-event [::request which])
:disabled (status/disabled-for status) :disabled (status/disabled-for status)
:class (status/class-for status)} :class (status/class-for status)}
@@ -107,6 +119,20 @@
:else :else
nil)]))]) nil)]))])
(defn bulk-journal-import-button []
[form-builder/builder {:submit-event [::request :bulk-journal-import]
:id ::bulk-journal-form}
[:p.field.has-addons
[:p.control
[:a.button.is-static.is-small
"s3://data.prod.app.integreatconsult.com/bulk-import/"]]
[:p.control
[form-builder/raw-field-v2 {:field :ledger-url}
[:input.input.is-small {:placeholder "ledger-data.csv"}]]]
[:p.control
[form-builder/submit-button {:class "is-small"} "Ledger Import"]
]]])
;; VIEWS ;; VIEWS
(def jobs-content (def jobs-content
(with-meta (with-meta
@@ -120,10 +146,12 @@
[:div [:div
[:div.is-pulled-right [:div.is-pulled-right
[:div.buttons [:div.buttons
[job-button {:which :yodlee2} "Start Yodlee Import"] [job-button {:which :yodlee2} "Start Yodlee Import"]
[job-button {:which :yodlee2-accounts} "Start Yodlee Account Import"] [job-button {:which :yodlee2-accounts} "Start Yodlee Account Import"]
[job-button {:which :intuit} "Start Intuit"] [job-button {:which :intuit} "Start Intuit"]
[job-button {:which :plaid} "Start Plaid"]]] [job-button {:which :plaid} "Start Plaid"]
[bulk-journal-import-button]]]
[table/table {:id :jobs [table/table {:id :jobs
:data-page ::page}]])])) :data-page ::page}]])]))
{:component-did-mount (dispatch-event [::mounted ]) {:component-did-mount (dispatch-event [::mounted ])