reimplemented filtering.

This commit is contained in:
Bryce Covert
2019-01-22 09:22:31 -08:00
parent 9385624309
commit e6adf11fa1
3 changed files with 29 additions and 2 deletions

View File

@@ -663,17 +663,41 @@
:step "0.01"}]]]]]
]))
(re-frame/reg-event-db
::change-selected-vendor
(fn [db [_ key value]]
(let [[key] key
updated (assoc-in db [::invoice-page :vendor-filter key] value)]
(if (and (= key :vendor-id)
(not= value (get-in db [::params :vendor-id])))
(do
(re-frame/dispatch [::params-change (assoc (::params updated) :vendor-id value)])
(assoc-in updated [::params :vendor-id] value))
updated))))
(def unpaid-invoices-page
(with-meta
(fn []
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown?]} @(re-frame/subscribe [::invoice-page])
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
current-client @(re-frame/subscribe [::subs/client])
{check-results-shown? :shown? pdf-url :pdf-url} @(re-frame/subscribe [::check-results])]
[:div
[:h1.title "Unpaid invoices"]
[:div.field.has-addons.is-extended
[:p.control [:a.button.is-static "Filter Vendor"]]
[:div.control {:style {:width "500px"}}
[bind-field
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors]))
:type "typeahead"
:auto-focus true
:field [:vendor-id]
:text-field [:vendor-name]
:event [::change-selected-vendor]
:spec (s/nilable ::invoice/vendor-id)
:subscription vendor-filter}]]]]
[:div.is-pulled-right
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
(when current-client