payments use new grid. Still need to update void button
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
[auto-ap.views.pages.payments.side-bar :as side-bar]
|
[auto-ap.views.pages.payments.side-bar :as side-bar]
|
||||||
[auto-ap.views.pages.payments.table :as table]
|
[auto-ap.views.pages.payments.table :as table]
|
||||||
[auto-ap.views.pages.check :as check]
|
[auto-ap.views.pages.check :as check]
|
||||||
[auto-ap.subs :as subs]))
|
[auto-ap.subs :as subs]
|
||||||
|
[auto-ap.status :as status]
|
||||||
|
[vimsical.re-frame.fx.track :as track]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -28,48 +30,35 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db ::payment-page)))
|
(-> db ::payment-page)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
|
||||||
::last-params
|
|
||||||
(fn [db]
|
|
||||||
(-> db ::last-params)))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::params
|
::params
|
||||||
:<- [::last-params]
|
|
||||||
:<- [::subs/client]
|
:<- [::subs/client]
|
||||||
:<- [::side-bar/filter-params]
|
:<- [::side-bar/filter-params]
|
||||||
:<- [::table/table-params]
|
:<- [::table/table-params]
|
||||||
(fn [[last-params client filter-params table-params]]
|
(fn [[ client filter-params table-params]]
|
||||||
(let [params (cond-> {}
|
(cond-> {}
|
||||||
client (assoc :client-id (:id client))
|
client (assoc :client-id (:id client))
|
||||||
(seq filter-params) (merge filter-params)
|
(seq filter-params) (merge filter-params)
|
||||||
(seq table-params) (merge table-params))]
|
(seq table-params) (merge table-params))))
|
||||||
(when (not= last-params params)
|
|
||||||
(re-frame/dispatch [::params-change]))
|
|
||||||
params)))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::params-change
|
::params-change
|
||||||
[with-user (re-frame/inject-cofx ::inject/sub [::params])]
|
[with-user]
|
||||||
(fn [{:keys [user db ::params]}[_ ]]
|
(fn [{:keys [user db ]}[_ params]]
|
||||||
(when (not= (::last-params db) params)
|
{:graphql {:token user
|
||||||
{:db (-> db
|
:owns-state {:single ::page}
|
||||||
(assoc-in [:status :loading] true)
|
:query-obj {:venia/queries [[:payment_page
|
||||||
(assoc-in [::last-params] params))
|
params
|
||||||
:graphql {:token user
|
[[:payments [:id :status :amount :type :check_number :s3_url
|
||||||
:query-obj {:venia/queries [[:payment_page
|
[:bank-account [:name]]
|
||||||
params
|
:date [:vendor [:name :id]] [:client [:name :id]]
|
||||||
[[:payments [:id :status :amount :type :check_number :s3_url
|
[:invoices [:invoice-id [:invoice [:invoice-number]]]]]]
|
||||||
[:bank-account [:name]]
|
:total
|
||||||
:date [:vendor [:name :id]] [:client [:name :id]]
|
:start
|
||||||
[:invoices [:invoice-id [:invoice [:invoice-number]]]]]]
|
:end]]]}
|
||||||
:total
|
:on-success [::received]}
|
||||||
:start
|
:set-uri-params (dissoc params :client-id)}))
|
||||||
:end]]]}
|
|
||||||
:on-success [::received]
|
|
||||||
:on-error [::events/page-failed]}
|
|
||||||
:set-uri-params (dissoc params
|
|
||||||
:client-id)})))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::void-check
|
::void-check
|
||||||
@@ -105,21 +94,30 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::unmounted
|
::unmounted
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
{:db (dissoc db ::last-params ::table/table-params ::side-bar/filters ::side-bar/settled-filters ::payment-page)}))
|
{:db (dissoc db ::last-params ::table/table-params ::side-bar/filters ::side-bar/settled-filters ::payment-page)
|
||||||
|
::track/dispose {:id ::params} }))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::mounted
|
||||||
|
(fn [{:keys [db]} _]
|
||||||
|
{::track/register {:id ::params
|
||||||
|
:subscription [::params]
|
||||||
|
:event-fn (fn [params] [::params-change params])}}))
|
||||||
|
|
||||||
(defn content []
|
(defn content []
|
||||||
(let [params @(re-frame/subscribe [::params])]
|
(let [params @(re-frame/subscribe [::params])]
|
||||||
[:div
|
[:div
|
||||||
[:h1.title "Payments"]
|
[:h1.title "Payments"]
|
||||||
[table/table {:id :payments
|
[table/table {:id :payments
|
||||||
:payment-page (re-frame/subscribe [::payment-page])
|
:payment-page @(re-frame/subscribe [::payment-page])
|
||||||
:status (re-frame/subscribe [::subs/status])
|
:status @(re-frame/subscribe [::status/single ::page])
|
||||||
:void-event [::void-check]}]]))
|
:void-event [::void-check]}]]))
|
||||||
|
|
||||||
(defn payments-page []
|
(defn payments-page []
|
||||||
(reagent/create-class
|
(reagent/create-class
|
||||||
{:display-name "payments-page"
|
{:display-name "payments-page"
|
||||||
:component-will-unmount #(re-frame/dispatch [::unmounted])
|
:component-will-unmount #(re-frame/dispatch [::unmounted])
|
||||||
|
:component-did-mount #(re-frame/dispatch [::mounted])
|
||||||
:reagent-render
|
:reagent-render
|
||||||
(fn []
|
(fn []
|
||||||
[side-bar-layout {:side-bar [side-bar/side-bar]
|
[side-bar-layout {:side-bar [side-bar/side-bar]
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
[auto-ap.views.components.dropdown :refer [drop-down drop-down-contents]]
|
[auto-ap.views.components.dropdown :refer [drop-down drop-down-contents]]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]
|
||||||
|
[auto-ap.views.components.grid :as grid]
|
||||||
|
[auto-ap.views.components.buttons :as buttons]))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::specific-table-params
|
::specific-table-params
|
||||||
@@ -36,27 +38,27 @@
|
|||||||
void-event :void-event
|
void-event :void-event
|
||||||
}]
|
}]
|
||||||
(let [{:keys [client s3-url bank-account payments type check-number date amount id vendor status invoices] :as check} check]
|
(let [{:keys [client s3-url bank-account payments type check-number date amount id vendor status invoices] :as check} check]
|
||||||
[:tr {:class (:class check)}
|
[grid/row {:class (:class check)}
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[:td (:name client)])
|
[grid/cell {} (:name client)])
|
||||||
[:td (:name vendor)]
|
[grid/cell {} (:name vendor)]
|
||||||
[:td (:name bank-account)]
|
[grid/cell {} (:name bank-account)]
|
||||||
[:td (cond
|
[grid/cell {} (cond
|
||||||
(= :cash type) "Cash"
|
(= :cash type) "Cash"
|
||||||
(= :debit type) "Debit"
|
(= :debit type) "Debit"
|
||||||
:else (if s3-url
|
:else (if s3-url
|
||||||
[:a {:href s3-url :target "_new"} [:a.button [:span.icon [:i.fa.fa-share-square-o]]
|
[:a {:href s3-url :target "_new"} [:a.button [:span.icon [:i.fa.fa-share-square-o]]
|
||||||
[:span (str " " check-number )]]]
|
[:span (str " " check-number )]]]
|
||||||
check-number))]
|
check-number))]
|
||||||
[:td (date->str date) ]
|
[grid/cell {} (date->str date) ]
|
||||||
[:td.has-text-right (nf amount )]
|
[grid/cell {:class "has-text-right"} (nf amount )]
|
||||||
[:td status]
|
[grid/cell {} status]
|
||||||
[:td.expandable
|
[grid/cell {:style {:overflow "visible"}}
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
(when (seq invoices)
|
(when (seq invoices)
|
||||||
[drop-down {:id [::invoices id]
|
[drop-down {:id [::invoices id]
|
||||||
:header [:button.button.badge {:data-badge (str (clojure.core/count invoices))
|
:header [:button.button.badge {:data-badge (str (clojure.core/count invoices))
|
||||||
:aria-haspopup true
|
:aria-haspopup true?
|
||||||
:tab-index "0"
|
:tab-index "0"
|
||||||
:on-click (dispatch-event [::events/toggle-menu [::invoices id]])
|
:on-click (dispatch-event [::events/toggle-menu [::invoices id]])
|
||||||
} "Invoices"]}
|
} "Invoices"]}
|
||||||
@@ -75,82 +77,32 @@
|
|||||||
(when (or (= :pending status)
|
(when (or (= :pending status)
|
||||||
(and (#{":cash" :cash ":debit" :debit} type)
|
(and (#{":cash" :cash ":debit" :debit} type)
|
||||||
(not= :voided status)))
|
(not= :voided status)))
|
||||||
[:button.button.is-warning.is-outlined {:on-click (dispatch-event (conj void-event check))} [:span [:span.icon [:i.fa.fa-minus-circle]]]])]]]))
|
[buttons/sl-icon {:event (conj void-event check) :icon :icon-bin-2}])]]]))
|
||||||
|
|
||||||
(defn table [{:keys [id payment-page status void-event]}]
|
(defn table [{:keys [id payment-page status void-event]}]
|
||||||
(let [{:keys [sort]} @(re-frame/subscribe [::table-params])
|
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||||
{:keys [payments start end count total]} @payment-page
|
percentage-size (if selected-client "50%" "33%")]
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
[grid/grid {:on-params-change (fn [e]
|
||||||
percentage-size (if selected-client "50%" "33%")
|
(re-frame/dispatch [::params-changed e]))
|
||||||
opc (fn [e]
|
:params @(re-frame/subscribe [::table-params])
|
||||||
(re-frame/dispatch [::params-changed e]))]
|
:status status
|
||||||
[:div
|
:column-count (if selected-client 7 8)}
|
||||||
[:div.level
|
[grid/controls payment-page]
|
||||||
[:div.level-left
|
[grid/table {:fullwidth true}
|
||||||
[:div.level-item
|
[grid/header {}
|
||||||
[paginator {:start start :end end :count count :total total
|
[grid/row {}
|
||||||
:on-change opc}]]
|
|
||||||
[:div.level-item
|
|
||||||
[sort-by-list {:sort sort
|
|
||||||
:on-change opc}]]]]
|
|
||||||
|
|
||||||
[:table.table.is-fullwidth
|
|
||||||
[:thead
|
|
||||||
[:tr
|
|
||||||
(when-not selected-client
|
(when-not selected-client
|
||||||
[sorted-column {:on-sort opc
|
[grid/sortable-header-cell {:sort-key "client" :sort-name "Client"} "Client"])
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
[grid/sortable-header-cell {:sort-key "vendor" :sort-name "Vendor"} "Vendor"]
|
||||||
:sort-key "client"
|
[grid/sortable-header-cell {:sort-key "bank-account" :sort-name "Bank Account"} "Bank Account"]
|
||||||
:sort-name "Client"
|
[grid/sortable-header-cell {:sort-key "check-number" :sort-name "Check Number"} "Check Number"]
|
||||||
:sort sort}
|
[grid/sortable-header-cell {:sort-key "date" :sort-name "Date" :style {:width "8em"}} "Date"]
|
||||||
"Client"])
|
[grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "8em"}} "Amount"]
|
||||||
|
[grid/sortable-header-cell {:sort-key "status" :sort-name "Status" :style {:width "7em"}} "Status"]
|
||||||
[sorted-column {:on-sort opc
|
[grid/header-cell {:style {:width "12em"}}]]]
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
[grid/body
|
||||||
:sort-key "vendor"
|
(for [check (:payments payment-page)]
|
||||||
:sort-name "Vendor"
|
^{:key (:id check)}
|
||||||
:sort sort}
|
[row {:check check
|
||||||
"Vendor"]
|
:selected-client selected-client
|
||||||
[sorted-column {:on-sort opc
|
:void-event void-event}])]]]))
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
|
||||||
:sort-key "bank-account"
|
|
||||||
:sort-name "Bank Account"
|
|
||||||
:sort sort}
|
|
||||||
"Bank Account"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
|
||||||
:sort-key "check-number"
|
|
||||||
:sort-name "Check #"
|
|
||||||
:sort sort}
|
|
||||||
"Check #"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "8em" :cursor "pointer"}
|
|
||||||
:sort-key "date"
|
|
||||||
:sort-name "Date"
|
|
||||||
:sort sort}
|
|
||||||
"Date"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "8em" :cursor "pointer"}
|
|
||||||
:class "has-text-right"
|
|
||||||
:sort-key "amount"
|
|
||||||
:sort-name "Amount"
|
|
||||||
:sort sort}
|
|
||||||
"Amount"]
|
|
||||||
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "8em" :cursor "pointer"}
|
|
||||||
:sort-key "status"
|
|
||||||
:sort-name "Status"
|
|
||||||
:sort sort}
|
|
||||||
"Status"]
|
|
||||||
[:th {:style {:width "15em"}} "" ]]]
|
|
||||||
[:tbody
|
|
||||||
(if (:loading @status)
|
|
||||||
[:tr
|
|
||||||
[:td {:col-span 5}
|
|
||||||
[:i.fa.fa-spin.fa-spinner]]]
|
|
||||||
(for [check (:payments @payment-page)]
|
|
||||||
^{:key (:id check)}
|
|
||||||
[row {:check check
|
|
||||||
:selected-client selected-client
|
|
||||||
:void-event void-event}]))]]]))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user