makes stuff work

This commit is contained in:
2023-05-11 09:43:37 -07:00
parent 6220ae1f6d
commit 0e814a8a4a
12 changed files with 403 additions and 197 deletions

View File

@@ -5,7 +5,9 @@
[auto-ap.ssr.utils :refer [html-response]]
[auto-ap.time :as atime]
[clojure.string :as str]
[com.brunobonacci.mulog :as mu]))
[com.brunobonacci.mulog :as mu]
[auto-ap.ssr.components :as com]
[auto-ap.ssr.svg :as svg]))
(defn try-cleanse-date [d]
(try
@@ -60,58 +62,65 @@
(let [results (search-results q id)]
[:div
(if (seq results)
(for [doc results]
[:div.block
[:div.card
[:div.card-header.has-background-info-light
(cond (= "transaction" (:type doc))
[:div.card-header-icon.icon-task-list-text-1]
[:div.flex.gap-8.flex-col
(for [doc results]
(com/card {}
[:div.flex.flex-col.gap-4
[:div.flex.items-center.p-2.gap-4.bg-gray-50.dark:bg-gray-800
[:div.h-8.w-8.p-2
(cond (= "transaction" (:type doc))
svg/bank
(= "invoice" (:type doc))
[:div.card-header-icon.icon-accounting-invoice-mail]
(= "invoice" (:type doc))
svg/accounting-invoice-mail
(= "payment" (:type doc))
[:div.card-header-icon.icon-check-payment-sign]
(= "payment" (:type doc))
svg/payments
(= "journal-entry" (:type doc))
[:div.card-header-icon.icon-receipt]
(= "journal-entry" (:type doc))
svg/receipt
:else
nil)
[:div.card-header-title (clojure.string/capitalize (:type doc))
" "
" "
[:span.tags.ml-3
[:span.tag.is-warning "client: " (:client_code doc)]
[:span.tag.is-info "amount: $" (first (:amount doc))]
:else
nil)]
(clojure.string/capitalize (:type doc))
(com/pill {:color :primary}
"client: " (:client_code doc))
(com/pill {:color :secondary}
"amount: $" (first (:amount doc)))
(when-let [vendor-name (first (:vendor_name doc))]
[:span.tag.is-primary "vendor: " vendor-name])]]
[:a.card-header-icon.fa.fa-external-link {:href (str "/" (cond (= "invoice"
(:type doc))
"invoices"
(com/pill {:color :yellow}
"vendor: " vendor-name))
[:div
(com/link {:href (str "/" (cond (= "invoice"
(:type doc))
"invoices"
(= "transaction"
(:type doc))
"transactions"
(= "transaction"
(:type doc))
"transactions"
(= "journal-entry"
(:type doc))
"ledger"
(= "journal-entry"
(:type doc))
"ledger"
:else
"payments") "/?exact-match-id=" (:id doc))
:target "_blank"}]
]
[:div.card-content
[:span
:else
"payments") "/?exact-match-id=" (:id doc))
:target "_blank"}
[:div.h-8.w-8.p-2
svg/external-link])]
]
[:strong (atime/unparse (atime/parse (:date doc) atime/solr-date) atime/normal-date)]
": "
(str (or (first (:description doc))
(first (:number doc))))]]]]
)
[:div.px-4.pb-2
[:span
[:strong (atime/unparse (atime/parse (:date doc) atime/solr-date) atime/normal-date)]
": "
(str (or (first (:description doc))
(first (:number doc))))]]])
)]
[:div.block "No results found."])]))
(defn dialog-contents [request]
@@ -121,22 +130,26 @@
(if-let [q (get (:form-params request) "q")]
(html-response (search-results* q (:identity request)))
(html-response
[:div#search {:style {:height "400px" :overflow "auto"}}
[:div.block
[:input#search-input.input {:type "search"
:placeholder "5/5/2034 Magheritas"
:name "q"
:hx-post "/search"
:hx-trigger "keyup changed delay:300ms, search"
:hx-target "#search-results"
:hx-indicator "#search"
:value (:q (:params request))
:autofocus true}]]
[:i "Try dates, numbers, vendors. To filter to specific entity type, use 'invoice', 'transaction', 'journal-entry', 'payment'."]
[:style
".htmx-request #search-results {display: none} .htmx-request .htmx-indicator { display: block !important; }"]
[:div#search-results
]
[:div.loader.is-loading.big.htmx-indicator {:style {:display "none"}}]])))
(com/dialog
[:div.p-2 "Search"]
[:div#search.overflow-auto.space-y-6.p-2.h-96
(com/text-input {:id "search-input"
:type "search"
:placeholder "5/5/2034 Magheritas"
:name "q"
:hx-post "/search"
:hx-trigger "keyup changed delay:300ms, search"
:hx-target "#search-results"
:hx-indicator "#search"
:value (:q (:params request))
:autofocus true})
[:i.text-sm.text-gray-600.dark:text-gray-50 "Try dates, numbers, vendors. To filter to specific type, use 'invoice', 'transaction', 'journal-entry', 'payment'."]
#_[:style
".htmx-request #search-results {display: none} .htmx-request .htmx-indicator { display: block !important; }"]
[:div#search-results
]
[:div.loader.is-loading.big.htmx-indicator ]]
nil)
:headers {"hx-trigger" "openDialog"})))