reimplemented filtering.
This commit is contained in:
@@ -44,7 +44,9 @@
|
||||
'[?e :invoice/client ?c]
|
||||
'[?c :client/original-id ?original-id])
|
||||
(:status args) (add-arg '?status (keyword "invoice-status" (:status args))
|
||||
'[?e :invoice/status ?status])))
|
||||
'[?e :invoice/status ?status])
|
||||
(:vendor-id args) (add-arg '?vendor-id (:vendor-id args)
|
||||
'[?e :invoice/vendor ?vendor-id])))
|
||||
(map first)
|
||||
(<-datomic)))
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@
|
||||
:args {:imported {:type 'Boolean}
|
||||
:status {:type 'String}
|
||||
:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:start {:type 'Int}
|
||||
:sort_by {:type 'String}
|
||||
:asc {:type 'Boolean}}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user