progress on migrating all grids.

This commit is contained in:
2023-09-28 22:22:25 -07:00
parent d1798f6b5c
commit 99accc067c
15 changed files with 743 additions and 742 deletions

View File

@@ -21,7 +21,8 @@
[bidi.bidi :as bidi]
[clj-time.coerce :as c]
[datomic.api :as dc]
[auto-ap.client-routes :as client-routes]))
[auto-ap.client-routes :as client-routes]
[malli.core :as m]))
;; make params parsing composable
@@ -132,75 +133,65 @@
[(->> (hydrate-results ids-to-retrieve db args))
matching-count]))
(def grid-page {:id "expected-deposit-table"
:nav (com/main-aside-nav)
:page-specific-nav filters
:id-fn :db/id
:fetch-page fetch-page
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
(def grid-page
(helper/build
{:id "expected-deposit-table"
:nav (com/main-aside-nav)
:page-specific-nav filters
:fetch-page fetch-page
:parse-query-params (comp
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page))
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)}
"Expected deposits"]]
:title "Expected deposits"
:entity-name "Expected deposit"
:route :pos-expected-deposit-table
:action-buttons (fn [request]
)
:row-buttons (fn [_ e]
[
(when (:expected-deposit/reference-link e)
(com/a-icon-button {:href (:expected-deposit/reference-link e)}
svg/external-link))
(when-let [transaction-id (-> e (:transaction/_expected-deposit) first :db/id)]
(com/a-button {:href (str (bidi/path-for client-routes/routes
:transactions)
"?exact-match-id="
transaction-id)} "Transaction"))])
:headers [{:key "client"
:name "Client"
:sort-key "client"
:hide? (fn [args]
(= (count (:clients args)) 1))
:render #(-> % :expected-deposit/client :client/code)}
{:key "date"
:name "Date"
:sort-key "date"
:render #(atime/unparse-local (:expected-deposit/date %) atime/standard-time)}
{:key "sales-date"
:name "Sales Date"
:sort-key "sales-date"
:render #(atime/unparse-local (:expected-deposit/sales-date %) atime/standard-time)}
{:key "total"
:name "Total"
:sort-key "total"
:render #(some->> % :expected-deposit/total (format "$%.2f"))}
{:key "fee"
:name "Fee"
:sort-key "fee"
:render #(some->> % :expected-deposit/fee (format "$%.2f"))}]})
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)}
"Expected deposits"]]
:title "Expected deposits"
:entity-name "Expected deposit"
:route :pos-expected-deposit-table
:row-buttons (fn [_ e]
[
(when (:expected-deposit/reference-link e)
(com/a-icon-button {:href (:expected-deposit/reference-link e)}
svg/external-link))
(when-let [transaction-id (-> e (:transaction/_expected-deposit) first :db/id)]
(com/a-button {:href (str (bidi/path-for client-routes/routes
:transactions)
"?exact-match-id="
transaction-id)} "Transaction"))])
:headers [{:key "client"
:name "Client"
:sort-key "client"
:hide? (fn [args]
(= (count (:clients args)) 1))
:render #(-> % :expected-deposit/client :client/code)}
{:key "date"
:name "Date"
:sort-key "date"
:render #(atime/unparse-local (:expected-deposit/date %) atime/standard-time)}
{:key "sales-date"
:name "Sales Date"
:sort-key "sales-date"
:render #(atime/unparse-local (:expected-deposit/sales-date %) atime/standard-time)}
{:key "total"
:name "Total"
:sort-key "total"
:render #(some->> % :expected-deposit/total (format "$%.2f"))}
{:key "fee"
:name "Fee"
:sort-key "fee"
:render #(some->> % :expected-deposit/fee (format "$%.2f"))}]}))
(def row* (partial helper/row* grid-page))
(def table* (partial helper/table* grid-page))
(def table (-> (partial helper/table grid-page)
(query-params/wrap-parse-query-params
(comp
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page)))))
(def page (-> (partial helper/page grid-page)
(query-params/wrap-parse-query-params
(comp
(query-params/parse-key :total-gte query-params/parse-double)
(query-params/parse-key :total-lte query-params/parse-double)
(helper/default-parse-query-params grid-page)))))
(def key->handler
{:pos-expected-deposits (wrap-client-redirect-unauthenticated (wrap-secure page))
:pos-expected-deposit-table (wrap-client-redirect-unauthenticated (wrap-secure table))})
{:pos-expected-deposits (helper/page-route grid-page)
:pos-expected-deposit-table (helper/table-route grid-page)})