This commit is contained in:
Bryce Covert
2020-08-22 17:14:21 -07:00
parent dc57fd7d0c
commit 25477d07f7
16 changed files with 9593 additions and 158 deletions

View File

@@ -31,7 +31,11 @@
:component-did-mount (fn [this]
(js/Dropzone. (rdom/dom-node this)
(clj->js {:init (fn []
(.on (js-this) "addedfiles"
(fn []
(re-frame/dispatch [::status/completed ::import])))
(.on (js-this) "success" (fn [_ files]
(re-frame/dispatch [::invalidated])))
(.on (js-this) "error" (fn [_ error]
(re-frame/dispatch [::status/error ::import [(edn/read-string error)]]))))
@@ -83,8 +87,7 @@
(fn [{:keys [db]} [_ params]]
{:dispatch-n [[::params-change @(re-frame/subscribe [::data-page/params :import-invoices])]
[::data-page/reset-checked :import-invoices]]
:db (update db ::batch inc)}
))
:db (update db ::batch inc)}))
(re-frame/reg-event-fx
::mounted
@@ -161,23 +164,21 @@
:on-success on-success}}))
(defn approve-reject-button [checked]
[:div.is-pulled-right
[:button.button.is-success {:on-click (dispatch-event [::approve-invoices-clicked checked])
[:div.buttons
[:button.button.is-primary {:on-click (dispatch-event [::approve-invoices-clicked checked])
:class (status/class-for @(re-frame/subscribe [::status/single ::approve]))
:disabled (if (seq checked)
""
"disabled")}
:disabled (or (not (boolean (seq checked)))
(status/disabled-for @(re-frame/subscribe [::status/single ::approve])))}
"Approve "
(when (> (count checked ))
(str
(count checked)
" invoices"))
[:span " "]]
[:button.button.is-danger {:on-click (dispatch-event [::reject-invoices-clicked checked])
:class (status/class-for @(re-frame/subscribe [::status/single ::reject]))
:disabled (if (seq checked)
""
"disabled")}
[:button.button.is-warning {:on-click (dispatch-event [::reject-invoices-clicked checked])
:class (status/class-for @(re-frame/subscribe [::status/single ::reject]))
:disabled (or (not (boolean (seq checked)))
(status/disabled-for @(re-frame/subscribe [::status/single ::reject])))}
"Reject "
(when (> (count checked ))
(str
@@ -199,6 +200,7 @@
[::status/single ::import]]}]
^{:key (str batch)}
[dropzone]
[:div.mb-4]
[:div {:class "card found-invoices",}
[:div {:class "card-header"}
[:span {:class "card-header-title"} "Found Invoices"]]