cleans up grids
This commit is contained in:
@@ -1,47 +1,39 @@
|
||||
(ns auto-ap.ssr.admin.accounts
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields
|
||||
apply-pagination
|
||||
apply-sort-3
|
||||
audit-transact
|
||||
conn
|
||||
merge-query
|
||||
pull-attr
|
||||
pull-many
|
||||
query2]]
|
||||
[auto-ap.query-params :as query-params]
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3 audit-transact
|
||||
conn merge-query pull-attr pull-many query2]]
|
||||
[auto-ap.query-params :as query-params :refer [wrap-copy-qp-pqp]]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [wrap-apply-sort]]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.nested-form-params :refer [wrap-nested-form-params]]
|
||||
[auto-ap.ssr.payments :refer [wrap-status-from-source]]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers
|
||||
entity-id
|
||||
field-validation-error
|
||||
form-validation-error
|
||||
html-response
|
||||
main-transformer
|
||||
many-entity
|
||||
modal-response
|
||||
ref->enum-schema
|
||||
ref->select-options
|
||||
strip
|
||||
temp-id
|
||||
wrap-entity
|
||||
wrap-form-4xx-2
|
||||
:refer [apply-middleware-to-all-handlers clj-date-schema
|
||||
default-grid-fields-schema entity-id field-validation-error
|
||||
form-validation-error html-response main-transformer many-entity
|
||||
modal-response ref->enum-schema ref->select-options strip temp-id
|
||||
wrap-entity wrap-form-4xx-2 wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
[bidi.bidi :as bidi]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[malli.core :as mc]))
|
||||
|
||||
(def query-schema (mc/schema
|
||||
[:maybe
|
||||
(into [:map {:date-range [:date-range :start-date :end-date]}
|
||||
[:type {:optional true} [:maybe (ref->enum-schema "account-type")]]
|
||||
[:name {:optional true} [:maybe [:string {:decode/string strip}]]]
|
||||
[:code {:optional true} [:maybe nat-int?]]]
|
||||
default-grid-fields-schema)]))
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
@@ -54,7 +46,7 @@
|
||||
(com/text-input {:name "name"
|
||||
:id "name"
|
||||
:class "hot-filter"
|
||||
:value (:name (:parsed-query-params request))
|
||||
:value (:name (:query-params request))
|
||||
:placeholder "Cash"
|
||||
:size :small}))
|
||||
|
||||
@@ -62,12 +54,13 @@
|
||||
(com/text-input {:name "code"
|
||||
:id "code"
|
||||
:class "hot-filter"
|
||||
:value (:code (:parsed-query-params request))
|
||||
:value (:code (:query-params request))
|
||||
:placeholder "11101"
|
||||
:size :small}))
|
||||
(com/field {:label "Type"}
|
||||
(com/radio-card {:size :small
|
||||
:name "type"
|
||||
:value (:type (:query-params request))
|
||||
:options [{:value ""
|
||||
:content "All"}
|
||||
{:value "dividend"
|
||||
@@ -99,7 +92,7 @@
|
||||
:db/id]}])
|
||||
|
||||
(defn fetch-ids [db request]
|
||||
(let [query-params (:parsed-query-params request)
|
||||
(let [query-params (:query-params request)
|
||||
query (cond-> {:query {:find []
|
||||
:in '[$]
|
||||
:where '[]}
|
||||
@@ -127,10 +120,8 @@
|
||||
|
||||
(some->> query-params :type)
|
||||
(merge-query {:query {:find []
|
||||
:in ['?rir]
|
||||
:where ['[?e :account/type ?r]
|
||||
'[?r :db/ident ?ri]
|
||||
'[(name ?ri) ?rir] ]}
|
||||
:in ['?r]
|
||||
:where ['[?e :account/type ?r] ]}
|
||||
:args [(some->> query-params :type)]})
|
||||
|
||||
true
|
||||
@@ -161,9 +152,6 @@
|
||||
:nav com/admin-aside-nav
|
||||
:page-specific-nav filters
|
||||
:fetch-page fetch-page
|
||||
:parse-query-params (comp
|
||||
(query-params/parse-key :code query-params/parse-long)
|
||||
(helper/default-parse-query-params grid-page))
|
||||
:action-buttons (fn [_]
|
||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
||||
:admin-account-new-dialog))
|
||||
@@ -183,6 +171,7 @@
|
||||
"Accounts"]]
|
||||
:title "Accounts"
|
||||
:entity-name "Account"
|
||||
:query-schema query-schema
|
||||
:route :admin-account-table
|
||||
:headers [{:key "code"
|
||||
:name "Code"
|
||||
@@ -431,25 +420,31 @@
|
||||
|
||||
|
||||
(def key->handler
|
||||
(apply-middleware-to-all-handlers
|
||||
(->>
|
||||
{:admin-accounts (helper/page-route grid-page)
|
||||
:admin-account-table (helper/table-route grid-page)
|
||||
:admin-account-client-override-new (-> new-client-override
|
||||
(wrap-schema-enforce :query-schema [:map
|
||||
[:index {:optional true
|
||||
:default 0} [nat-int? {:default 0}]]])
|
||||
wrap-admin wrap-client-redirect-unauthenticated)
|
||||
:admin-account-save (-> account-save
|
||||
(wrap-entity [:form-params :db/id] default-read)
|
||||
(wrap-schema-enforce :form-schema form-schema)
|
||||
(wrap-nested-form-params)
|
||||
(wrap-form-4xx-2 (wrap-entity account-dialog [:form-params :db/id] default-read)))
|
||||
:admin-account-edit-dialog (-> account-dialog
|
||||
(wrap-entity [:route-params :db/id] default-read)
|
||||
(wrap-schema-enforce :route-schema [:map [:db/id entity-id]]))
|
||||
:admin-account-new-dialog account-dialog})
|
||||
(fn [h]
|
||||
(-> h
|
||||
(wrap-admin)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
(apply-middleware-to-all-handlers
|
||||
(->>
|
||||
{:admin-accounts (helper/page-route grid-page)
|
||||
:admin-account-table (helper/table-route grid-page)
|
||||
:admin-account-client-override-new (-> new-client-override
|
||||
(wrap-schema-enforce :query-schema [:map
|
||||
[:index {:optional true
|
||||
:default 0} [nat-int? {:default 0}]]])
|
||||
wrap-admin wrap-client-redirect-unauthenticated)
|
||||
:admin-account-save (-> account-save
|
||||
(wrap-entity [:form-params :db/id] default-read)
|
||||
(wrap-schema-enforce :form-schema form-schema)
|
||||
(wrap-nested-form-params)
|
||||
(wrap-form-4xx-2 (wrap-entity account-dialog [:form-params :db/id] default-read)))
|
||||
:admin-account-edit-dialog (-> account-dialog
|
||||
(wrap-entity [:route-params :db/id] default-read)
|
||||
(wrap-schema-enforce :route-schema [:map [:db/id entity-id]]))
|
||||
:admin-account-new-dialog account-dialog})
|
||||
(fn [h]
|
||||
(-> h
|
||||
(wrap-copy-qp-pqp)
|
||||
(wrap-apply-sort grid-page)
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-status-from-source)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-admin)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
(filter is-background-job?)
|
||||
(map ecs-task->job))]
|
||||
[jobs (count jobs)]))
|
||||
(def query-schema (mc/schema [:map ]))
|
||||
|
||||
(def grid-page
|
||||
(helper/build {:id "job-table"
|
||||
@@ -104,6 +105,7 @@
|
||||
"Background Jobs"]]
|
||||
:title "Jobs"
|
||||
:entity-name "Job"
|
||||
:query-schema query-schema
|
||||
:route :admin-job-table
|
||||
:headers [
|
||||
{:key "start"
|
||||
|
||||
@@ -216,8 +216,6 @@
|
||||
:nav com/admin-aside-nav
|
||||
:page-specific-nav filters
|
||||
:fetch-page fetch-page
|
||||
:parse-query-params (fn [p]
|
||||
(mc/decode query-schema p main-transformer))
|
||||
:action-buttons (fn [_]
|
||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/new-dialog))
|
||||
:color :primary}
|
||||
@@ -237,6 +235,7 @@
|
||||
"Clients"]]
|
||||
:title "Clients"
|
||||
:entity-name "Client"
|
||||
:query-schema query-schema
|
||||
:route ::route/table
|
||||
:headers [{:key "name"
|
||||
:name "Name"
|
||||
@@ -1848,8 +1847,8 @@
|
||||
|
||||
(def key->handler
|
||||
(apply-middleware-to-all-handlers
|
||||
{::route/page (helper/page-route grid-page :parse-query-params? false)
|
||||
::route/table (helper/table-route grid-page :parse-query-params? false)
|
||||
{::route/page (helper/page-route grid-page)
|
||||
::route/table (helper/table-route grid-page)
|
||||
::route/new-location (add-new-primitive-handler [:step-params :client/locations]
|
||||
""
|
||||
location-row)
|
||||
|
||||
@@ -1,31 +1,38 @@
|
||||
(ns auto-ap.ssr.admin.import-batch
|
||||
(:require
|
||||
[auto-ap.client-routes :as client-routes]
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields
|
||||
apply-pagination
|
||||
apply-sort-3
|
||||
conn
|
||||
merge-query
|
||||
pull-many
|
||||
query2]]
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query
|
||||
pull-many query2]]
|
||||
[auto-ap.query-params :refer [wrap-copy-qp-pqp]]
|
||||
[auto-ap.routes.admin.import-batch :as 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.date-range :refer [date-range-field]]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [wrap-apply-sort]]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers ref->select-options]]
|
||||
:refer [apply-middleware-to-all-handlers clj-date-schema
|
||||
default-grid-fields-schema ref->select-options wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]
|
||||
[datomic.api :as dc]
|
||||
[clj-time.coerce :as c]
|
||||
[auto-ap.logging :as alog]
|
||||
[datomic.api :as dc]
|
||||
[hiccup.util :as hu]
|
||||
[auto-ap.client-routes :as client-routes]
|
||||
[auto-ap.ssr.svg :as svg]))
|
||||
[malli.core :as mc]))
|
||||
|
||||
(def query-schema (mc/schema
|
||||
[:maybe
|
||||
(into [:map {:date-range [:date-range :start-date :end-date]}
|
||||
[:start-date {:optional true}
|
||||
[:maybe clj-date-schema]]
|
||||
[:end-date {:optional true}
|
||||
[:maybe clj-date-schema]]
|
||||
[:client {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :client/name]}]]]]
|
||||
default-grid-fields-schema)]))
|
||||
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
@@ -35,13 +42,13 @@
|
||||
"hx-indicator" "#entity-table"}
|
||||
|
||||
[:fieldset.space-y-6
|
||||
(date-range-field {:value {:start (:start-date (:parsed-query-params request))
|
||||
:end (:end-date (:parsed-query-params request))}
|
||||
(date-range-field {:value {:start (:start-date (:query-params request))
|
||||
:end (:end-date (:query-params request))}
|
||||
:id "date-range"})
|
||||
(com/field {:label "Source"}
|
||||
(com/select {:name "source"
|
||||
:class "hot-filter w-full"
|
||||
:value (:source (:parsed-query-params request))
|
||||
:value (:source (:query-params request))
|
||||
:placeholder ""
|
||||
:options (ref->select-options "import-source" :allow-nil? true)}))
|
||||
|
||||
@@ -49,7 +56,7 @@
|
||||
(com/text-input {:name "code"
|
||||
:id "code"
|
||||
:class "hot-filter"
|
||||
:value (:code (:parsed-query-params request))
|
||||
:value (:code (:query-params request))
|
||||
:placeholder "11101"
|
||||
:size :small}))]])
|
||||
|
||||
@@ -63,7 +70,7 @@
|
||||
[:import-batch/status :xform iol-ion.query/ident] [:db/ident]}])
|
||||
|
||||
(defn fetch-ids [db request]
|
||||
(let [query-params (:parsed-query-params request)
|
||||
(let [query-params (:query-params request)
|
||||
query (cond-> {:query {:find []
|
||||
:in '[$ ]
|
||||
:where '[]}
|
||||
@@ -134,11 +141,9 @@
|
||||
svg/external-link)])
|
||||
:oob-render
|
||||
(fn [request]
|
||||
[(assoc-in (date-range-field {:value {:start (:start-date (:parsed-query-params request))
|
||||
:end (:end-date (:parsed-query-params request))}
|
||||
[(assoc-in (date-range-field {:value {:start (:start-date (:query-params request))
|
||||
:end (:end-date (:query-params request))}
|
||||
:id "date-range"}) [1 :hx-swap-oob] true)])
|
||||
:parse-query-params (comp
|
||||
(helper/default-parse-query-params grid-page))
|
||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:admin)}
|
||||
"Admin"]
|
||||
@@ -148,6 +153,7 @@
|
||||
"Import Batches"]]
|
||||
:title "Import Batches"
|
||||
:entity-name "Batch"
|
||||
:query-schema query-schema
|
||||
:route ::route/table
|
||||
:headers [{:key "date"
|
||||
:name "Date"
|
||||
@@ -184,5 +190,11 @@
|
||||
::route/table (helper/table-route grid-page)})
|
||||
(fn [h]
|
||||
(-> h
|
||||
|
||||
(wrap-copy-qp-pqp)
|
||||
(wrap-apply-sort grid-page)
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-admin)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
@@ -1,32 +1,45 @@
|
||||
(ns auto-ap.ssr.admin.sales-summaries
|
||||
(:require [auto-ap.datomic
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [apply-pagination apply-sort-3 conn merge-query pull-many
|
||||
query2]]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[auto-ap.routes.admin.sales-summaries :as route]
|
||||
[auto-ap.routes.utils
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[auto-ap.query-params :refer [wrap-copy-qp-pqp]]
|
||||
[auto-ap.routes.admin.sales-summaries :as route]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers entity-id html-response
|
||||
money strip temp-id wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as c]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[hiccup.util :as hu]
|
||||
[iol-ion.query :refer [dollars=]]
|
||||
[malli.core :as mc]
|
||||
[malli.util :as mut]))
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [wrap-apply-sort]]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers clj-date-schema
|
||||
default-grid-fields-schema entity-id html-response money
|
||||
strip temp-id wrap-merge-prior-hx wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as c]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[hiccup.util :as hu]
|
||||
[iol-ion.query :refer [dollars=]]
|
||||
[malli.core :as mc]
|
||||
[malli.util :as mut]))
|
||||
|
||||
(def query-schema (mc/schema
|
||||
[:maybe
|
||||
(into [:map {:date-range [:date-range :start-date :end-date]}
|
||||
|
||||
[:start-date {:optional true}
|
||||
[:maybe clj-date-schema]]
|
||||
[:end-date {:optional true}
|
||||
[:maybe clj-date-schema]] ]
|
||||
default-grid-fields-schema)]))
|
||||
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
@@ -36,13 +49,13 @@
|
||||
"hx-indicator" "#entity-table"}
|
||||
|
||||
#_[:fieldset.space-y-6
|
||||
(date-range-field {:value {:start (:start-date (:parsed-query-params request))
|
||||
:end (:end-date (:parsed-query-params request))}
|
||||
(date-range-field {:value {:start (:start-date (:query-params request))
|
||||
:end (:end-date (:query-params request))}
|
||||
:id "date-range"})
|
||||
(com/field {:label "Source"}
|
||||
(com/select {:name "source"
|
||||
:class "hot-filter w-full"
|
||||
:value (:source (:parsed-query-params request))
|
||||
:value (:source (:query-params request))
|
||||
:placeholder ""
|
||||
:options (ref->select-options "import-source" :allow-nil? true)}))
|
||||
|
||||
@@ -50,7 +63,7 @@
|
||||
(com/text-input {:name "code"
|
||||
:id "code"
|
||||
:class "hot-filter"
|
||||
:value (:code (:parsed-query-params request))
|
||||
:value (:code (:query-params request))
|
||||
:placeholder "11101"
|
||||
:size :small}))]])
|
||||
|
||||
@@ -69,7 +82,7 @@
|
||||
} ]) ;; TODO
|
||||
|
||||
(defn fetch-ids [db request]
|
||||
(let [query-params (:parsed-query-params request)
|
||||
(let [query-params (:query-params request)
|
||||
valid-clients (extract-client-ids (:clients request)
|
||||
(:client request)
|
||||
(:client-id query-params)
|
||||
@@ -159,6 +172,7 @@
|
||||
:nav com/admin-aside-nav
|
||||
:fetch-page fetch-page
|
||||
:page-specific-nav filters
|
||||
:query-schema query-schema
|
||||
:row-buttons (fn [_ entity]
|
||||
[(com/icon-button {:hx-get (bidi/path-for ssr-routes/only-routes
|
||||
::route/edit-wizard
|
||||
@@ -166,11 +180,9 @@
|
||||
svg/pencil)])
|
||||
:oob-render
|
||||
(fn [request]
|
||||
[#_(assoc-in (date-range-field {:value {:start (:start-date (:parsed-query-params request))
|
||||
:end (:end-date (:parsed-query-params request))}
|
||||
[#_(assoc-in (date-range-field {:value {:start (:start-date (:query-params request))
|
||||
:end (:end-date (:query-params request))}
|
||||
:id "date-range"}) [1 :hx-swap-oob] true)]) ;; TODO
|
||||
:parse-query-params (comp
|
||||
(helper/default-parse-query-params grid-page))
|
||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:admin)}
|
||||
"Admin"]
|
||||
@@ -516,26 +528,33 @@
|
||||
{::route/page (helper/page-route grid-page)
|
||||
::route/table (helper/table-route grid-page)
|
||||
::route/edit-wizard (-> mm/open-wizard-handler
|
||||
(mm/wrap-wizard edit-wizard)
|
||||
(mm/wrap-init-multi-form-state initial-edit-wizard-state)
|
||||
(wrap-schema-enforce :route-schema [:map [:db/id entity-id]]))
|
||||
(mm/wrap-wizard edit-wizard)
|
||||
(mm/wrap-init-multi-form-state initial-edit-wizard-state)
|
||||
(wrap-schema-enforce :route-schema [:map [:db/id entity-id]]))
|
||||
::route/edit-wizard-navigate (-> mm/next-handler
|
||||
(mm/wrap-wizard edit-wizard)
|
||||
(mm/wrap-decode-multi-form-state))
|
||||
(mm/wrap-wizard edit-wizard)
|
||||
(mm/wrap-decode-multi-form-state))
|
||||
::route/new-summary-item (-> (add-new-entity-handler [:step-params :sales-summary/items]
|
||||
(fn render [cursor request]
|
||||
(sales-summary-item-row*
|
||||
{:value cursor
|
||||
:client-id (:client-id (:query-params request)) }))
|
||||
(fn build-new-row [base _]
|
||||
(assoc base :sales-summary-item/manual? true)))
|
||||
(wrap-schema-enforce :query-schema [:map
|
||||
[:client-id {:optional true}
|
||||
[:maybe entity-id]]]))
|
||||
(fn render [cursor request]
|
||||
(sales-summary-item-row*
|
||||
{:value cursor
|
||||
:client-id (:client-id (:query-params request))}))
|
||||
(fn build-new-row [base _]
|
||||
(assoc base :sales-summary-item/manual? true)))
|
||||
(wrap-schema-enforce :query-schema [:map
|
||||
[:client-id {:optional true}
|
||||
[:maybe entity-id]]]))
|
||||
::route/edit-wizard-submit (-> mm/submit-handler
|
||||
(mm/wrap-wizard edit-wizard)
|
||||
(mm/wrap-decode-multi-form-state))})
|
||||
(mm/wrap-wizard edit-wizard)
|
||||
(mm/wrap-decode-multi-form-state))})
|
||||
(fn [h]
|
||||
(-> h
|
||||
(wrap-copy-qp-pqp)
|
||||
(wrap-apply-sort grid-page)
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-admin)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +1,49 @@
|
||||
(ns auto-ap.ssr.admin.transaction-rules
|
||||
(:require [auto-ap.datomic
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3
|
||||
audit-transact conn merge-query pull-attr pull-many
|
||||
query2 remove-nils]]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.query-params :as query-params]
|
||||
[auto-ap.routes.admin.transaction-rules :as route]
|
||||
[auto-ap.routes.utils
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[auto-ap.query-params :as query-params :refer [wrap-copy-qp-pqp]]
|
||||
[auto-ap.routes.admin.transaction-rules :as route]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler]]
|
||||
[auto-ap.ssr.company :refer [bank-account-typeahead*]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers entity-id
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler]]
|
||||
[auto-ap.ssr.company :refer [bank-account-typeahead*]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [wrap-apply-sort]]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers
|
||||
default-grid-fields-schema entity-id
|
||||
field-validation-error form-validation-error
|
||||
html-response many-entity modal-response money percentage
|
||||
ref->enum-schema ref->radio-options regex temp-id
|
||||
wrap-entity wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[malli.core :as mc]
|
||||
[malli.util :as mut]))
|
||||
wrap-entity wrap-merge-prior-hx wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[malli.core :as mc]
|
||||
[malli.util :as mut]))
|
||||
|
||||
(def query-schema (mc/schema
|
||||
[:maybe
|
||||
(into [:map {}
|
||||
[:vendor {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :vendor/name]}]]] ]
|
||||
default-grid-fields-schema)]))
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
@@ -52,14 +58,14 @@
|
||||
:url (bidi/path-for ssr-routes/only-routes
|
||||
:vendor-search)
|
||||
:id (str "vendor-search")
|
||||
:value (:vendor (:parsed-query-params request))
|
||||
:value (:vendor (:query-params request))
|
||||
:value-fn :db/id
|
||||
:content-fn :vendor/name}))
|
||||
(com/field {:label "Note"}
|
||||
(com/text-input {:name "note"
|
||||
:id "note"
|
||||
:class "hot-filter"
|
||||
:value (:note (:parsed-query-params request))
|
||||
:value (:note (:query-params request))
|
||||
:placeholder "HOME DEPOT lte 250.0"
|
||||
:size :small}))
|
||||
|
||||
@@ -67,14 +73,14 @@
|
||||
(com/text-input {:name "description"
|
||||
:id "description"
|
||||
:class "hot-filter"
|
||||
:value (:description (:parsed-query-params request))
|
||||
:value (:description (:query-params request))
|
||||
:placeholder "LOWES"
|
||||
:size :small}))
|
||||
(com/field {:label "Client group"}
|
||||
(com/text-input {:name "client-group"
|
||||
:id "client-group"
|
||||
:class "hot-filter"
|
||||
:value (:client-group (:parsed-query-params request))
|
||||
:value (:client-group (:query-params request))
|
||||
:placeholder "NTG"
|
||||
:size :small}))]])
|
||||
|
||||
@@ -100,7 +106,7 @@
|
||||
:db/id]}])
|
||||
|
||||
(defn fetch-ids [db request]
|
||||
(let [query-params (:parsed-query-params request)
|
||||
(let [query-params (:query-params request)
|
||||
valid-clients (extract-client-ids (:clients request)
|
||||
(:client request)
|
||||
(:client-id query-params)
|
||||
@@ -179,9 +185,6 @@
|
||||
:nav com/admin-aside-nav
|
||||
:page-specific-nav filters
|
||||
:fetch-page fetch-page
|
||||
:parse-query-params (comp
|
||||
(query-params/parse-key :vendor #(dc/pull (dc/db conn) '[:vendor/name :db/id] (Long/parseLong %)))
|
||||
(helper/default-parse-query-params grid-page))
|
||||
:action-buttons (fn [request]
|
||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/new-dialog))
|
||||
:color :primary}
|
||||
@@ -206,6 +209,7 @@
|
||||
"Transaction Rules"]]
|
||||
:title "Rules"
|
||||
:entity-name "Rule"
|
||||
:query-schema query-schema
|
||||
:route ::route/table
|
||||
:headers [{:key "client"
|
||||
:name "Client"
|
||||
@@ -999,5 +1003,10 @@
|
||||
{}))))})
|
||||
(fn [h]
|
||||
(-> h
|
||||
(wrap-copy-qp-pqp)
|
||||
(wrap-apply-sort grid-page)
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-admin)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
@@ -1,38 +1,48 @@
|
||||
(ns auto-ap.ssr.admin.vendors
|
||||
(:require [auto-ap.cursor :as cursor]
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3 audit-transact
|
||||
audit-transact-batch audit-transact-batch conn merge-query
|
||||
pull-attr pull-many query2]]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.query-params :as query-params]
|
||||
[auto-ap.routes.admin.vendors :as route]
|
||||
[auto-ap.routes.utils
|
||||
(:require
|
||||
[auto-ap.cursor :as cursor]
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3
|
||||
audit-transact audit-transact-batch audit-transact-batch
|
||||
conn merge-query pull-attr pull-many query2]]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.query-params :refer [wrap-copy-qp-pqp]]
|
||||
[auto-ap.routes.admin.vendors :as route]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler
|
||||
add-new-primitive-handler]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.components.timeline :as timeline]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers entity-id form-validation-error
|
||||
html-response many-entity modal-response ref->enum-schema
|
||||
ref->select-options strip temp-id wrap-entity wrap-form-4xx-2
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.common-handlers :refer [add-new-entity-handler
|
||||
add-new-primitive-handler]]
|
||||
[auto-ap.ssr.components :as com]
|
||||
[auto-ap.ssr.components.multi-modal :as mm]
|
||||
[auto-ap.ssr.components.timeline :as timeline]
|
||||
[auto-ap.ssr.form-cursor :as fc]
|
||||
[auto-ap.ssr.grid-page-helper :as helper :refer [wrap-apply-sort]]
|
||||
[auto-ap.ssr.hx :as hx]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers
|
||||
default-grid-fields-schema entity-id
|
||||
form-validation-error html-response many-entity
|
||||
modal-response ref->enum-schema ref->select-options strip
|
||||
temp-id wrap-entity wrap-form-4xx-2 wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
[bidi.bidi :as bidi]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[malli.core :as mc]
|
||||
[malli.transform :as mt]
|
||||
[malli.util :as mut]))
|
||||
[bidi.bidi :as bidi]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[malli.core :as mc]
|
||||
[malli.transform :as mt]
|
||||
[malli.util :as mut]))
|
||||
|
||||
(def query-schema (mc/schema
|
||||
[:maybe
|
||||
(into [:map {}
|
||||
[:name {:optional true :default nil} [:maybe [:string {:string/decode strip}]]]
|
||||
#_[:role {:optional true} [:maybe (ref->enum-schema "user-role")]]
|
||||
#_[:client {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :client/name]}]]] ]
|
||||
default-grid-fields-schema)]))
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
@@ -45,13 +55,13 @@
|
||||
(com/text-input {:name "name"
|
||||
:id "name"
|
||||
:class "hot-filter"
|
||||
:value (:name (:parsed-query-params request))
|
||||
:value (:name (:query-params request))
|
||||
:placeholder "Cash"
|
||||
:size :small}))
|
||||
(com/field {:label "Type"}
|
||||
(com/radio-card {:size :small
|
||||
:name "type"
|
||||
:value (:type (:parsed-query-params request))
|
||||
:value (:type (:query-params request))
|
||||
:options [{:value ""
|
||||
:content "All"}
|
||||
{:value "only-hidden"
|
||||
@@ -84,7 +94,7 @@
|
||||
[:vendor/legal-entity-tin-type :xform iol-ion.query/ident] [:db/ident]}])
|
||||
|
||||
(defn fetch-ids [db request]
|
||||
(let [query-params (:parsed-query-params request)
|
||||
(let [query-params (:query-params request)
|
||||
query (cond-> {:query {:find []
|
||||
:in '[$]
|
||||
:where '[]}
|
||||
@@ -139,9 +149,6 @@
|
||||
:nav com/admin-aside-nav
|
||||
:page-specific-nav filters
|
||||
:fetch-page fetch-page
|
||||
:parse-query-params (comp
|
||||
(query-params/parse-key :code query-params/parse-long)
|
||||
(helper/default-parse-query-params grid-page))
|
||||
:action-buttons (fn [_]
|
||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
||||
::route/merge))
|
||||
@@ -165,6 +172,7 @@
|
||||
"Vendors"]]
|
||||
:title "Vendors"
|
||||
:entity-name "Vendor"
|
||||
:query-schema query-schema
|
||||
:route ::route/table
|
||||
:headers [{:key "name"
|
||||
:name "Name"
|
||||
@@ -913,6 +921,11 @@
|
||||
(fn [cursor _] (account-override-row cursor)))})
|
||||
(fn [h]
|
||||
(-> h
|
||||
(wrap-copy-qp-pqp)
|
||||
(wrap-apply-sort grid-page)
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-admin)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user