applying Ashlee's feedback
This commit is contained in:
@@ -6,9 +6,8 @@
|
|||||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||||
[auto-ap.logging :as alog]
|
[auto-ap.logging :as alog]
|
||||||
[auto-ap.routes.admin.clients :as route]
|
[auto-ap.routes.admin.clients :as route]
|
||||||
[auto-ap.routes.queries :as q]
|
|
||||||
[auto-ap.routes.indicators :as indicators]
|
[auto-ap.routes.indicators :as indicators]
|
||||||
[auto-ap.ssr.indicators :as i]
|
[auto-ap.routes.queries :as q]
|
||||||
[auto-ap.routes.utils
|
[auto-ap.routes.utils
|
||||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||||
[auto-ap.solr :as solr]
|
[auto-ap.solr :as solr]
|
||||||
@@ -19,15 +18,16 @@
|
|||||||
[auto-ap.ssr.components :as com]
|
[auto-ap.ssr.components :as com]
|
||||||
[auto-ap.ssr.components.multi-modal :as mm]
|
[auto-ap.ssr.components.multi-modal :as mm]
|
||||||
[auto-ap.ssr.form-cursor :as fc]
|
[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.hiccup-helper :as hh]
|
[auto-ap.ssr.hiccup-helper :as hh]
|
||||||
[auto-ap.ssr.hx :as hx]
|
[auto-ap.ssr.hx :as hx]
|
||||||
|
[auto-ap.ssr.indicators :as i]
|
||||||
[auto-ap.ssr.svg :as svg]
|
[auto-ap.ssr.svg :as svg]
|
||||||
[auto-ap.ssr.utils
|
[auto-ap.ssr.utils
|
||||||
:refer [apply-middleware-to-all-handlers entity-id
|
:refer [apply-middleware-to-all-handlers entity-id
|
||||||
form-validation-error html-response many-entity
|
form-validation-error html-response main-transformer
|
||||||
modal-response ref->enum-schema strip temp-id wrap-entity
|
many-entity modal-response ref->enum-schema strip temp-id
|
||||||
wrap-schema-enforce]]
|
wrap-entity wrap-schema-enforce]]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[cheshire.core :as cheshire]
|
[cheshire.core :as cheshire]
|
||||||
@@ -50,6 +50,20 @@
|
|||||||
;; TODO a few bug fixes from slack
|
;; TODO a few bug fixes from slack
|
||||||
;; TOOD check pinecone
|
;; TOOD check pinecone
|
||||||
|
|
||||||
|
(def query-schema (mc/schema
|
||||||
|
[:maybe [:map
|
||||||
|
[:sort {:optional true} [:maybe [:any]]]
|
||||||
|
[:per-page {:optional true :default 25} [:maybe :int]]
|
||||||
|
[:start {:optional true :default 0} [:maybe :int]]
|
||||||
|
[:code {:optional true} [:maybe {:decode/string strip} :string]]
|
||||||
|
[:name {:optional true} [:maybe {:decode/string strip} :string]]
|
||||||
|
[:group {:optional true} [:maybe {:decode/string strip} :string]]
|
||||||
|
[:select {:optional true :default "all"} [:maybe
|
||||||
|
|
||||||
|
|
||||||
|
[:enum
|
||||||
|
"" "all" "only-mine"]]] ]]))
|
||||||
|
|
||||||
(defn filters [request]
|
(defn filters [request]
|
||||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||||
@@ -72,7 +86,22 @@
|
|||||||
:class "hot-filter"
|
:class "hot-filter"
|
||||||
:value (:code (:parsed-query-params request))
|
:value (:code (:parsed-query-params request))
|
||||||
:placeholder "BRLC"
|
:placeholder "BRLC"
|
||||||
:size :small}))]])
|
:size :small}))
|
||||||
|
(com/field {:label "Group"}
|
||||||
|
(com/text-input {:name "group"
|
||||||
|
:id "group"
|
||||||
|
:class "hot-filter"
|
||||||
|
:value (:group (:parsed-query-params request))
|
||||||
|
:placeholder "NTG"
|
||||||
|
:size :small}))
|
||||||
|
(com/field {:label "Select"}
|
||||||
|
(com/radio-card {:size :small
|
||||||
|
:name "select"
|
||||||
|
:value (:select (:query-params request))
|
||||||
|
:options [{:value ""
|
||||||
|
:content "All"}
|
||||||
|
{:value "only-mine"
|
||||||
|
:content "Only mine"} ]}))]])
|
||||||
|
|
||||||
(def default-read '[:db/id
|
(def default-read '[:db/id
|
||||||
:client/name
|
:client/name
|
||||||
@@ -121,8 +150,8 @@
|
|||||||
|
|
||||||
(defn fetch-ids [db request]
|
(defn fetch-ids [db request]
|
||||||
(let [query-params (:parsed-query-params request)
|
(let [query-params (:parsed-query-params request)
|
||||||
valid-clients (extract-client-ids (:clients request)
|
valid-clients (extract-client-ids #_(:clients request)
|
||||||
(:client request)
|
(map first (dc/q '[:find ?c :where [?c :client/code]] (dc/db conn)))
|
||||||
(:client-id query-params)
|
(:client-id query-params)
|
||||||
(when (:client-code query-params)
|
(when (:client-code query-params)
|
||||||
[:client/code (:client-code query-params)]))
|
[:client/code (:client-code query-params)]))
|
||||||
@@ -134,6 +163,16 @@
|
|||||||
|
|
||||||
"code" ['[?e :client/code ?sort-code]]}
|
"code" ['[?e :client/code ?sort-code]]}
|
||||||
query-params)
|
query-params)
|
||||||
|
(= "only-mine" (:select query-params))
|
||||||
|
(merge-query {:query {:in ['?uid]
|
||||||
|
:where ['[?uid :user/clients ?e]]}
|
||||||
|
:args [(:db/id (:identity request))]})
|
||||||
|
|
||||||
|
(:group query-params)
|
||||||
|
(merge-query {:query {:in ['?g]
|
||||||
|
:where ['[?e :client/groups ?g]]}
|
||||||
|
:args [(clojure.string/upper-case (:group query-params))]})
|
||||||
|
|
||||||
|
|
||||||
(not (str/blank? (some-> query-params :code)))
|
(not (str/blank? (some-> query-params :code)))
|
||||||
(merge-query {:query {:in ['?code]
|
(merge-query {:query {:in ['?code]
|
||||||
@@ -175,7 +214,8 @@
|
|||||||
:nav com/admin-aside-nav
|
:nav com/admin-aside-nav
|
||||||
:page-specific-nav filters
|
:page-specific-nav filters
|
||||||
:fetch-page fetch-page
|
:fetch-page fetch-page
|
||||||
:parse-query-params (helper/default-parse-query-params grid-page)
|
:parse-query-params (fn [p]
|
||||||
|
(mc/decode query-schema p main-transformer))
|
||||||
:action-buttons (fn [_]
|
:action-buttons (fn [_]
|
||||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/new-dialog))
|
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/new-dialog))
|
||||||
:color :primary}
|
:color :primary}
|
||||||
@@ -900,8 +940,8 @@
|
|||||||
:value (fc/field-value)
|
:value (fc/field-value)
|
||||||
:options
|
:options
|
||||||
(sort-by second (dc/q '[:find ?ia ?inn
|
(sort-by second (dc/q '[:find ?ia ?inn
|
||||||
:in $
|
:in $
|
||||||
:where [?ia :intuit-bank-account/name ?inn] ]
|
:where [?ia :intuit-bank-account/name ?inn]]
|
||||||
(dc/db conn)))})))
|
(dc/db conn)))})))
|
||||||
(fc/with-field :bank-account/use-date-instead-of-post-date?
|
(fc/with-field :bank-account/use-date-instead-of-post-date?
|
||||||
(com/checkbox {:name (fc/field-name)
|
(com/checkbox {:name (fc/field-name)
|
||||||
@@ -975,8 +1015,8 @@
|
|||||||
;; todo do date coercion in the input
|
;; todo do date coercion in the input
|
||||||
(atime/unparse-local atime/normal-date))})])
|
(atime/unparse-local atime/normal-date))})])
|
||||||
[:div#days-indicator
|
[:div#days-indicator
|
||||||
(i/days-ago* (some-> (fc/field-value))) ]])
|
(i/days-ago* (some-> (fc/field-value)))]])
|
||||||
|
|
||||||
|
|
||||||
(fc/with-field :bank-account/include-in-reports
|
(fc/with-field :bank-account/include-in-reports
|
||||||
(com/checkbox {:name (fc/field-name)
|
(com/checkbox {:name (fc/field-name)
|
||||||
@@ -1085,7 +1125,7 @@
|
|||||||
;; todo do date coercion in the input
|
;; todo do date coercion in the input
|
||||||
(atime/unparse-local atime/normal-date))})])
|
(atime/unparse-local atime/normal-date))})])
|
||||||
[:div#days-indicator
|
[:div#days-indicator
|
||||||
(i/days-ago* (some-> (fc/field-value))) ]])
|
(i/days-ago* (some-> (fc/field-value)))]])
|
||||||
|
|
||||||
(fc/with-field :bank-account/include-in-reports
|
(fc/with-field :bank-account/include-in-reports
|
||||||
(com/checkbox {:name (fc/field-name)
|
(com/checkbox {:name (fc/field-name)
|
||||||
@@ -1093,7 +1133,7 @@
|
|||||||
:checked (fc/field-value)}
|
:checked (fc/field-value)}
|
||||||
"Include in reports"))
|
"Include in reports"))
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
(fc/with-field :bank-account/visible
|
(fc/with-field :bank-account/visible
|
||||||
(com/checkbox {:name (fc/field-name)
|
(com/checkbox {:name (fc/field-name)
|
||||||
:value (boolean (fc/field-value))
|
:value (boolean (fc/field-value))
|
||||||
@@ -1863,5 +1903,7 @@
|
|||||||
(mm/wrap-wizard client-wizard))}
|
(mm/wrap-wizard client-wizard))}
|
||||||
(fn [h]
|
(fn [h]
|
||||||
(-> h
|
(-> h
|
||||||
|
(wrap-apply-sort grid-page)
|
||||||
|
(wrap-schema-enforce :query-schema query-schema)
|
||||||
(wrap-admin)
|
(wrap-admin)
|
||||||
(wrap-client-redirect-unauthenticated)))))
|
(wrap-client-redirect-unauthenticated)))))
|
||||||
|
|||||||
Reference in New Issue
Block a user