invoices page works, needs dialog.
This commit is contained in:
@@ -10,13 +10,14 @@
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.permissions :refer [can?]]
|
||||
[auto-ap.routes.payments :as route]
|
||||
[auto-ap.routes.invoice :as invoice-route]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.bank-account-icon :as bank-account-icon]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [sort->query
|
||||
wrap-apply-sort]]
|
||||
[auto-ap.ssr.components.link-dropdown :refer [link-dropdown]]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [wrap-apply-sort]]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.pos.common :refer [date-range-field*]]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
@@ -48,6 +49,7 @@
|
||||
svg/x)]])]
|
||||
[:div {:id "exact-match-id-tag"}]))
|
||||
|
||||
;; TODO use query-params instead of parsed-query-params
|
||||
(defn filters [request]
|
||||
[:form#payment-filters {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
@@ -56,13 +58,13 @@
|
||||
"hx-indicator" "#entity-table"}
|
||||
|
||||
(com/hidden {:name "status"
|
||||
:value (some-> (:status (:parsed-query-params request)) name)})
|
||||
:value (some-> (:status (:query-params request)) name)})
|
||||
[:fieldset.space-y-6
|
||||
(com/field {:label "Vendor"}
|
||||
(com/typeahead {:name "vendor"
|
||||
:id "vendor"
|
||||
:url (bidi/path-for ssr-routes/only-routes :vendor-search)
|
||||
:value (:vendor (:parsed-query-params request))
|
||||
:value (:vendor (:query-params request))
|
||||
:value-fn :db/id
|
||||
:content-fn :vendor/name}))
|
||||
(date-range-field* request)
|
||||
@@ -70,14 +72,14 @@
|
||||
(com/text-input {:name "check-number"
|
||||
:id "check-number"
|
||||
:class "hot-filter"
|
||||
:value (:check-number (:parsed-query-params request))
|
||||
:value (:check-number (:query-params request))
|
||||
:placeholder "10001"
|
||||
:size :small}))
|
||||
(com/field {:label "Invoice #"}
|
||||
(com/text-input {:name "invoice-number"
|
||||
:id "invoice-number"
|
||||
:class "hot-filter"
|
||||
:value (:invoice-number (:parsed-query-params request))
|
||||
:value (:invoice-number (:query-params request))
|
||||
:placeholder "10001"
|
||||
:size :small}))
|
||||
|
||||
@@ -87,7 +89,7 @@
|
||||
:id "amount-gte"
|
||||
:hx-preserve "true"
|
||||
:class "hot-filter w-20"
|
||||
:value (:amount-gte (:parsed-query-params request))
|
||||
:value (:amount-gte (:query-params request))
|
||||
:placeholder "0.01"
|
||||
:size :small})
|
||||
[:div.align-baseline
|
||||
@@ -96,13 +98,13 @@
|
||||
:hx-preserve "true"
|
||||
:id "amount-lte"
|
||||
:class "hot-filter w-20"
|
||||
:value (:amount-lte (:parsed-query-params request))
|
||||
:value (:amount-lte (:query-params request))
|
||||
:placeholder "9999.34"
|
||||
:size :small})])
|
||||
(com/field {:label "Payment Type"}
|
||||
(com/radio {:size :small
|
||||
:name "payment-type"
|
||||
:value (:payment-type (:parsed-query-params request))
|
||||
:value (:payment-type (:query-params request))
|
||||
:options [{:value ""
|
||||
:content "All"}
|
||||
{:value "cash"
|
||||
@@ -248,31 +250,8 @@
|
||||
[(->> (hydrate-results ids-to-retrieve db request))
|
||||
matching-count]))
|
||||
|
||||
(defn- render-links [links]
|
||||
(if (<= (count links) 2)
|
||||
[:div.flex.flex-col.space-y-1
|
||||
(for [l links]
|
||||
[:a {:href (:link l)}
|
||||
(com/pill {:color (or (:color l) :primary) :class "truncate w-24 block shrink grow-0"}
|
||||
(:content l))])]
|
||||
[:div {:x-data (hx/json {:popper nil
|
||||
:show false})
|
||||
"@click.outside" "show=false"
|
||||
|
||||
:x-init "popper = Popper.createPopper($refs.link, $refs.tooltip, {placement: 'bottom', strategy: 'fixed'})"}
|
||||
(com/a-icon-button {:x-ref "link" "@click.prevent" "show=!show; $nextTick(() => popper.update());" :class "relative"}
|
||||
svg/three-dots
|
||||
(com/badge {} (count links)))
|
||||
[:div.divide-y.divide-gray-200.bg-white.rounded-lg.shadow (hx/alpine-appear {:x-ref "tooltip" :x-show "show" :data-key "show"})
|
||||
[:div {:class "p-3 overflow-y-auto text-sm text-gray-700 dark:text-gray-200"}
|
||||
[:div.flex.flex-col.space-y-1
|
||||
(for [l links]
|
||||
[:a {:href (:link l)}
|
||||
(com/pill {:color (or (:color l) :primary) :class "truncate w-24 block shrink grow-0"}
|
||||
(:content l))])]]]]))
|
||||
|
||||
(def query-schema (mc/schema
|
||||
[:maybe [:map {:date-range [:date-range :start-date :end-date] }
|
||||
[:maybe [:map {:date-range [:date-range :start-date :end-date]}
|
||||
[:sort {:optional true} [:maybe [:any]]]
|
||||
[:per-page {:optional true :default 25} [:maybe :int]]
|
||||
[:start {:optional true :default 0} [:maybe :int]]
|
||||
@@ -385,15 +364,15 @@
|
||||
:name "Links"
|
||||
:class "w-8"
|
||||
:render (fn [p]
|
||||
(render-links (concat (->> p :payment/invoices (map (fn [invoice]
|
||||
{:link (hu/url (bidi/path-for client-routes/routes
|
||||
:invoices)
|
||||
(link-dropdown (concat (->> p :payment/invoices (map (fn [invoice]
|
||||
{:link (hu/url (bidi/path-for ssr-routes/only-routes
|
||||
::invoice-route/page)
|
||||
{:exact-match-id (:db/id invoice)})
|
||||
:content (str "Inv. " (:invoice/invoice-number invoice))})))
|
||||
(some-> p :transaction/_payment ((fn [t]
|
||||
[{:link (hu/url (bidi/path-for client-routes/routes
|
||||
:transactions)
|
||||
{:exact-match-id 1})
|
||||
{:exact-match-id (:db/id (first t))})
|
||||
:color :secondary
|
||||
:content "Transaction"}]))))))}]}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user