investigate progress.

This commit is contained in:
2024-10-14 23:21:48 -07:00
parent 502a05bdcd
commit ca5d90b17f
11 changed files with 119 additions and 80 deletions

View File

@@ -264,4 +264,7 @@
.ct-series-e .ct-bar { .ct-series-e .ct-bar {
stroke: #9c27b0; stroke: #9c27b0;
fill: #9c27b0; fill: #9c27b0;
}
[x-cloak] {
display:none
} }

View File

@@ -57,9 +57,12 @@ Alpine.directive('hx-header', (el, { value, expression }, { evaluateLater, effec
this.$refs.source.addEventListener('mouseover', reveal) this.$refs.source.addEventListener('mouseover', reveal)
this.$refs.source.addEventListener('mouseout', hide) this.$refs.source.addEventListener('mouseout', hide)
}, },
destroy() {
this.popper.destroy()
},
tooltip: { tooltip: {
[':class']() { return { 'opacity-0': !this.show, 'opacity-100': this.show, 'pointer-events-none': !this.show, 'transition': true } }, [':class']() { return {'opacity-0': !this.show, 'opacity-100': this.show, 'pointer-events-none': !this.show, 'transition': true } },
["x-ref"]: 'tooltip', ["x-ref"]: 'tooltip',
['x-transition']: true ['x-transition']: true
} }

File diff suppressed because one or more lines are too long

View File

@@ -206,6 +206,14 @@
result))) result)))
(with-bindings { #'bucket-name "data.prod.app.integreatconsult.com"}
(let [result (-> "sysco/error/SYSCO050_00175962_20241010122639019.csv"
read-sysco-csv
(extract-invoice-details (get-sysco-vendor))
)]
result))
) )
(defn import-sysco [] (defn import-sysco []

View File

@@ -41,21 +41,26 @@
[:input (merge {:id "checkbox-all", :type "checkbox", :class inputs/default-checkbox-classes :name (:name params) :value (:value params)} params)] [:input (merge {:id "checkbox-all", :type "checkbox", :class inputs/default-checkbox-classes :name (:name params) :value (:value params)} params)]
[:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]]) [:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]])
(defn data-grid- [{:keys [headers thead-params id] :as params} & rest] (defn data-grid-
[:table (merge {:class "w-full text-sm text-left text-gray-500 dark:text-gray-400"} [{:keys [headers thead-params id] :as params} & rest]
(dissoc params :headers :thead-params)) [:div.shrink.overflow-y-scroll
[:thead (update thead-params :class #(-> "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400" [:table (merge {:class "w-full text-sm text-left text-gray-500 dark:text-gray-400 shrink"}
(hh/add-class (or % "")))) (dissoc params :headers :thead-params))
[:thead (update thead-params :class #(-> "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400 group-[.raw]:sticky group-[.raw]:top-0"
(hh/add-class (or % ""))))
(into
[:tr]
headers)]
(into (into
[:tr] [:tbody {}]
headers)] rest)]])
(into
[:tbody]
rest)])
;; needed for tailwind ;; needed for tailwind
;; lg:table-cell md:table-cell ;; lg:table-cell md:table-cell
(defn raw-table-card [params & children]
[:div params children])
(defn data-grid-card- [{:keys [id (defn data-grid-card- [{:keys [id
route route
title title
@@ -68,64 +73,64 @@
per-page per-page
flash-id flash-id
headers headers
raw?
rows] :as params} & children] rows] :as params} & children]
[:div (cond-> { :id id} (let [card (if raw? raw-table-card content-card-)]
route (assoc (card
(cond-> { :id id :class (cond-> "group" raw? (hh/add-class "raw h-full flex flex-col overflow-hidden"))}
route (assoc
:hx-get (bidi/path-for ssr-routes/only-routes :hx-get (bidi/path-for ssr-routes/only-routes
route route
:request-method :get) :request-method :get)
:hx-trigger "clientSelected from:body, invalidated from:body" :hx-trigger "clientSelected from:body, invalidated from:body"
:hx-swap "outerHTML swap:300ms")) :hx-swap "outerHTML swap:300ms"))
[:div {:class " group-[.raw]:hidden flex flex-col px-4 py-3 space-y-3 lg:flex-row lg:items-center lg:justify-between lg:space-y-0 lg:space-x-4 text-gray-800 dark:text-gray-100"}
(content-card- [:h1.text-2xl.mb-3.font-bold title]
{} [:div {:class "flex items-center flex-1 space-x-4"}
[:div {:class "flex flex-col px-4 py-3 space-y-3 lg:flex-row lg:items-center lg:justify-between lg:space-y-0 lg:space-x-4 text-gray-800 dark:text-gray-100"} [:h5
[:div (when subtitle
[:h1.text-2xl.mb-3.font-bold title] [:span subtitle])]]
[:div {:class "flex items-center flex-1 space-x-4"} (into [:div {:class "flex flex-col flex-shrink-0 space-y-3 md:flex-row md:items-center lg:justify-end md:space-y-0 md:space-x-3"}]
[:h5 action-buttons)]
(when subtitle [:div {:class "overflow-x-auto contents"}
[:span subtitle])]]] (data-grid- {:headers headers
(into [:div {:class "flex flex-col flex-shrink-0 space-y-3 md:flex-row md:items-center lg:justify-end md:space-y-0 md:space-x-3"}] :thead-params thead-params}
action-buttons)] rows)]
[:div {:class "overflow-x-auto"}
(data-grid- {:headers headers
:thead-params thead-params}
rows)]
(when (or paginate? (when (or paginate?
(nil? paginate?)) (nil? paginate?))
(paginator- {:start start [:div {:class "contents group-[.raw]:block"}
:end (Math/min (+ start per-page) total) (paginator- {:start start
:per-page per-page :end (Math/min (+ start per-page) total)
:total total :per-page per-page
:a-params (fn [page] :total total
;; TODO it might be good to have a more global form defined in the specific page :a-params (fn [page]
;; with elements that are part of item ;; TODO it might be good to have a more global form defined in the specific page
;; that way this is not deeply coupled ;; with elements that are part of item
;; for example, including filters and pagination is awkward ;; that way this is not deeply coupled
;; TODO the other way to think about this is that we want the request to include ;; for example, including filters and pagination is awkward
;; all of the correct parameters, not parameters to merge with the current ones. ;; TODO the other way to think about this is that we want the request to include
;; think sorting, filters, pagination ;; all of the correct parameters, not parameters to merge with the current ones.
{:hx-get (hu/url (bidi/path-for ssr-routes/only-routes ;; think sorting, filters, pagination
route {:hx-get (hu/url (bidi/path-for ssr-routes/only-routes
:request-method :get) route
{:start (* page per-page)}) :request-method :get)
:hx-target (str "#" id) {:start (* page per-page)})
:hx-swap "outerHTML show:#app:top" :hx-target (str "#" id)
:hx-indicator (str "#" id)}) :hx-swap "outerHTML show:#app:top"
:per-page-params {:hx-get (hu/url (bidi/path-for ssr-routes/only-routes :hx-indicator (str "#" id)})
route :per-page-params {:hx-get (hu/url (bidi/path-for ssr-routes/only-routes
:request-method :get)) route
:hx-trigger "change" :request-method :get))
:hx-include "this" :hx-trigger "change"
:hx-target (str "#" id) ; :hx-include "this"
:hx-swap "outerHTML show:#app:top" :hx-target (str "#" id) ;
:hx-indicator (str "#" id)}})) :hx-swap "outerHTML show:#app:top"
children :hx-indicator (str "#" id)}})])
[:div {:class "htmx-indicator absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2 overflow-hidden w-full h-full"} children
[:div {:class "flex items-center justify-center w-full h-full border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-800 dark:border-gray-700 bg-opacity-50" } [:div {:class "htmx-indicator absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2 overflow-hidden w-full h-full"}
[:div {:class "px-3 py-1 text-xs font-medium leading-none text-center text-blue-800 bg-blue-200 rounded-full animate-pulse dark:bg-blue-900 dark:text-blue-200"} "loading..."]]])]) [:div {:class "flex items-center justify-center w-full h-full border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-800 dark:border-gray-700 bg-opacity-50" }
[:div {:class "px-3 py-1 text-xs font-medium leading-none text-center text-blue-800 bg-blue-200 rounded-full animate-pulse dark:bg-blue-900 dark:text-blue-200"} "loading..."]]])))
(defn new-row- [{:keys [index colspan tr-params row-offset] :as params} & content] (defn new-row- [{:keys [index colspan tr-params row-offset] :as params} & content]
(row- (row-

View File

@@ -23,10 +23,10 @@
[:div (update params [:div (update params
:class (fn [c] (-> c :class (fn [c] (-> c
(or "") (or "")
(hh/add-class "w-full p-4 h-full modal-card")))) (hh/add-class "w-full p-4 modal-card flex max-h-[inherit]"))))
[:div {:class "bg-white rounded-lg shadow dark:bg-gray-700 dark:text-white modal-content w-full flex flex-col h-full"} [:div {:class "bg-white rounded-lg shadow dark:bg-gray-700 dark:text-white modal-content w-full flex flex-col max-h-full overflow-hidden"}
[:div {:class "flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600 shrink-0"} header] [:div {:class "flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600 shrink-0"} header]
[:div {:class "px-6 py-2 space-y-6 overflow-y-scroll w-full shrink"} [:div {:class "px-6 py-2 space-y-6 overflow-y-scroll w-full contents"}
#_[:div.bg-green-300.w-full.h-64 #_[:div.bg-green-300.w-full.h-64
"hello"] "hello"]
content] content]

View File

@@ -109,6 +109,7 @@
request (assoc request :page-results page-results)] request (assoc request :page-results page-results)]
(com/data-grid-card {:id (:id grid-spec) (com/data-grid-card {:id (:id grid-spec)
:raw? (:raw? grid-spec)
:title (if (string? (:title grid-spec)) :title (if (string? (:title grid-spec))
(:title grid-spec) (:title grid-spec)
((:title grid-spec) request)) ((:title grid-spec) request))

View File

@@ -407,6 +407,7 @@
{:report/name name {:report/name name
:report/url url })) :report/url url }))
;; TODO PRINT WARNING
(defn export [request] (defn export [request]
(modal-response (modal-response
(com/modal {} (com/modal {}

View File

@@ -148,7 +148,6 @@
(when (:client-code request) (when (:client-code request)
[:client/code (:client-code request)])) [:client/code (:client-code request)]))
args query-params args query-params
#_#__ (clojure.pprint/pprint query-params)
query query
(if (:exact-match-id args) (if (:exact-match-id args)
{:query {:find '[?e] {:query {:find '[?e]
@@ -384,7 +383,7 @@
[:amount-gte {:optional true} [:maybe :double]] [:amount-gte {:optional true} [:maybe :double]]
[:amount-lte {:optional true} [:maybe :double]] [:amount-lte {:optional true} [:maybe :double]]
[:client-id {:optional true} [:maybe entity-id]] [:client-id {:optional true} [:maybe entity-id]]
[:numeric-code {:optional true :decode/string clojure.edn/read-string} [:numeric-code {:optional true :decode/string clojure.edn/read-string }
[:maybe [:vector [:map [:from nat-int?] [:maybe [:vector [:map [:from nat-int?]
[:to nat-int?]]] ]] [:to nat-int?]]] ]]
[:numeric-code-gte {:optional true} [:maybe nat-int?]] [:numeric-code-gte {:optional true} [:maybe nat-int?]]

View File

@@ -5,33 +5,51 @@
[auto-ap.routes.utils :refer [wrap-client-redirect-unauthenticated]] [auto-ap.routes.utils :refer [wrap-client-redirect-unauthenticated]]
[auto-ap.ssr.components :as com] [auto-ap.ssr.components :as com]
[auto-ap.ssr.grid-page-helper :refer [table*]] [auto-ap.ssr.grid-page-helper :refer [table*]]
[auto-ap.ssr.hx :as hx]
[auto-ap.ssr.ledger.common :refer [grid-page query-schema]] [auto-ap.ssr.ledger.common :refer [grid-page query-schema]]
[auto-ap.ssr.utils :refer [apply-middleware-to-all-handlers [auto-ap.ssr.utils :refer [apply-middleware-to-all-handlers
modal-response wrap-merge-prior-hx html-response modal-response
wrap-schema-enforce]])) wrap-merge-prior-hx wrap-schema-enforce]]))
(def altered-grid-page
(assoc grid-page
:id "yoho"
:raw? true
:check-boxes? false
:route ::route/investigate-results))
(defn investigate-results [request]
(html-response
(table*
altered-grid-page
identity
(assoc-in request [:query-params :sort] [{:sort-key "date" :asc? false}]))))
(defn investigate [request] (defn investigate [request]
(modal-response (modal-response
(com/modal {:class "h-[600px]"} (com/modal {:class "max-h-[600px]"}
(com/modal-card {} (com/modal-card {:hx-vals (hx/json (update (:query-params request)
:numeric-code pr-str))
}
[:div "Ledger entries"] [:div "Ledger entries"]
[:div (table*
(table* altered-grid-page
grid-page identity
identity (assoc-in request [:query-params :sort] [{:sort-key "date" :asc? false}]))
request)]
nil) nil)
))) )))
(def key->handler (def key->handler
(apply-middleware-to-all-handlers (apply-middleware-to-all-handlers
(-> (->
{::route/investigate investigate } {::route/investigate investigate
::route/investigate-results investigate-results}
) )
(fn [h] (fn [h]
(-> h (-> h
(wrap-copy-qp-pqp)
(wrap-merge-prior-hx) (wrap-merge-prior-hx)
(wrap-schema-enforce :query-schema query-schema) (wrap-schema-enforce :query-schema query-schema)
(wrap-schema-enforce :hx-schema query-schema) (wrap-schema-enforce :hx-schema query-schema)
(wrap-must {:activity :read :subject :ledger}) (wrap-must {:activity :read :subject :ledger})
(wrap-client-redirect-unauthenticated))))) (wrap-client-redirect-unauthenticated)))))

View File

@@ -5,7 +5,8 @@
"/external-import-new" {"" ::external-import-page "/external-import-new" {"" ::external-import-page
"/parse" ::external-import-parse "/parse" ::external-import-parse
"/import" ::external-import-import} "/import" ::external-import-import}
"/investigate" ::investigate "/investigate" {"" ::investigate
"/results" ::investigate-results}
"/table" ::table "/table" ::table
"/bank-account-filter" ::bank-account-filter "/bank-account-filter" ::bank-account-filter
"/reports/balance-sheet" {"" ::balance-sheet "/reports/balance-sheet" {"" ::balance-sheet