added vendor filter payment
This commit is contained in:
@@ -38,6 +38,8 @@
|
|||||||
|
|
||||||
(:client-id args) (add-arg '?client-id (:client-id args)
|
(:client-id args) (add-arg '?client-id (:client-id args)
|
||||||
'[?e :payment/client ?client-id])
|
'[?e :payment/client ?client-id])
|
||||||
|
(:vendor-id args) (add-arg '?vendor-id (:vendor-id args)
|
||||||
|
'[?e :payment/vendor ?vendor-id])
|
||||||
(:original-id args) (add-arg '?original-id (cond-> (:original-id args) (string? (:original-id args)) Long/parseLong )
|
(:original-id args) (add-arg '?original-id (cond-> (:original-id args) (string? (:original-id args)) Long/parseLong )
|
||||||
'[?e :payment/client ?c]
|
'[?e :payment/client ?c]
|
||||||
'[?c :client/original-id ?original-id])
|
'[?c :client/original-id ?original-id])
|
||||||
|
|||||||
@@ -233,6 +233,7 @@
|
|||||||
|
|
||||||
:payment_page {:type '(list :payment_page)
|
:payment_page {:type '(list :payment_page)
|
||||||
:args {:client_id {:type :id}
|
:args {:client_id {:type :id}
|
||||||
|
:vendor_id {:type :id}
|
||||||
:start {:type 'Int}
|
:start {:type 'Int}
|
||||||
:sort_by {:type 'String}
|
:sort_by {:type 'String}
|
||||||
:asc {:type 'Boolean}}
|
:asc {:type 'Boolean}}
|
||||||
|
|||||||
@@ -2,13 +2,16 @@
|
|||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[auto-ap.entities.clients :as client]
|
[auto-ap.entities.clients :as client]
|
||||||
[auto-ap.entities.vendors :as vendor]
|
[auto-ap.entities.vendors :as vendor]
|
||||||
|
[auto-ap.entities.invoice :as invoice]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
[auto-ap.views.components.sorter :refer [sorted-column]]
|
[auto-ap.views.components.sorter :refer [sorted-column]]
|
||||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||||
|
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||||
[auto-ap.views.components.paginator :refer [paginator]]
|
[auto-ap.views.components.paginator :refer [paginator]]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[auto-ap.views.utils :refer [dispatch-event date->str ]]
|
[auto-ap.views.utils :refer [dispatch-event date->str bind-field]]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.views.pages.check :as check]
|
[auto-ap.views.pages.check :as check]
|
||||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
||||||
@@ -79,6 +82,18 @@
|
|||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params]]
|
||||||
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
|
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-db
|
||||||
|
::change-selected-vendor
|
||||||
|
(fn [db [_ key value]]
|
||||||
|
(let [[key] key
|
||||||
|
updated (assoc-in db [::payment-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))))
|
||||||
|
|
||||||
(defn check-table [{:keys [id payment-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
|
(defn check-table [{:keys [id payment-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
|
||||||
(let [state (reagent/atom (or @params {}))
|
(let [state (reagent/atom (or @params {}))
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
selected-client @(re-frame/subscribe [::subs/client])
|
||||||
@@ -188,6 +203,23 @@
|
|||||||
(re-frame/dispatch [::params-change params]))}]]))
|
(re-frame/dispatch [::params-change params]))}]]))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
||||||
|
|
||||||
|
(defn vendor-filter []
|
||||||
|
(let [{:keys [vendor-filter]} @(re-frame/subscribe [::payment-page])]
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
[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}]]]]))
|
||||||
|
|
||||||
(defn checks-page []
|
(defn checks-page []
|
||||||
[side-bar-layout {:side-bar [:div]
|
[side-bar-layout {:side-bar
|
||||||
|
[:div
|
||||||
|
[:p.menu-label "Vendor"]
|
||||||
|
[:div [vendor-filter]]]
|
||||||
:main [checks-content]}])
|
:main [checks-content]}])
|
||||||
|
|||||||
Reference in New Issue
Block a user