starting to be able to choose invoices
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.views.utils :refer [dispatch-event]]
|
||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]))
|
||||
@@ -44,6 +45,18 @@
|
||||
(disj x data)
|
||||
(conj x data)))))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::print-checks
|
||||
(fn [{:keys [db]} [_ data]]
|
||||
{:db (assoc-in db [::invoice-page :checked] nil)
|
||||
:http {:method :post
|
||||
:token (:user db)
|
||||
:body (pr-str {:invoice-ids (get-in db [::invoice-page :checked])})
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/checks/")
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invalidated
|
||||
(fn [cofx [_ params]]
|
||||
@@ -52,18 +65,20 @@
|
||||
(def unpaid-invoices-page
|
||||
(with-meta
|
||||
(fn []
|
||||
[:div
|
||||
[:h1.title "Unpaid invoices"]
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-primary "Print check(s)"]]
|
||||
|
||||
[invoice-table {:id :unpaid
|
||||
:params (re-frame/subscribe [::params])
|
||||
:invoice-page (re-frame/subscribe [::invoice-page])
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-params-change (fn [params]
|
||||
(re-frame/dispatch [::params-change params]))
|
||||
:check-boxes true
|
||||
:on-check-changed (fn [which]
|
||||
(re-frame/dispatch [::toggle-check which]))}]])
|
||||
(let [checked (:checked @(re-frame/subscribe [::invoice-page]))]
|
||||
[:div
|
||||
[:h1.title "Unpaid invoices"]
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::print-checks ])} "Print check(s)"]]
|
||||
|
||||
[invoice-table {:id :unpaid
|
||||
:params (re-frame/subscribe [::params])
|
||||
:invoice-page (re-frame/subscribe [::invoice-page])
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-params-change (fn [params]
|
||||
(re-frame/dispatch [::params-change params]))
|
||||
:check-boxes true
|
||||
:checked checked
|
||||
:on-check-changed (fn [which]
|
||||
(re-frame/dispatch [::toggle-check which]))}]]))
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
||||
|
||||
Reference in New Issue
Block a user