makes more changes.

This commit is contained in:
2024-10-18 21:34:29 -07:00
parent 2311acb9a2
commit 4c05452774
2 changed files with 33 additions and 24 deletions

View File

@@ -99,8 +99,6 @@
[:ul.dropdown-contents {:class "bg-gray-100 dark:bg-gray-600 ring-1"
"@keydown.escape" "tippy.hide(); value = {value: '', label: '' }; "
:x-destroy "if ($refs.input) {$refs.input.focus();}"}
[:input {:type "text"
:autofocus true
:class (-> (:class params)
@@ -266,6 +264,12 @@
(assoc
:type "hidden"
"x-bind:value" "v"))]]
[:template {:x-if "value.size == 0"}
[:input (-> params
(dissoc :class :value-fn :content-fn :placeholder :x-model)
(assoc :type "hidden"
:value ""
))]]
[:div.flex.w-full.justify-items-stretch
(multi-typeahead-selected-pill- params)
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}

View File

@@ -284,7 +284,7 @@
(defn maybe-trim-clients [request client ]
(if (= :all client)
(cond-> {:client (take 5 (:clients request))}
(cond-> {:client (take 20 (:clients request))}
(> (count (:clients request)) 20)
(assoc :warning "You requested a report with more than 20 clients. This report will only contain the first 20."))
{:client client}))
@@ -303,8 +303,8 @@
:table report
:warning (not-empty (str/join "\n " (filter not-empty [warning (:warning report)])))} ))))])
(defn form* [request]
(let [params (merge (:query-params request) (:form-params request) {})]
(defn form* [request & children]
(let [params (:query-params request)]
(fc/start-form
params
(:form-errors request)
@@ -348,10 +348,11 @@
(com/button {:color :primary :class "w-32"}
"Run")
(com/button {:formaction (bidi.bidi/path-for ssr-routes/only-routes ::route/export-balance-sheet) } "Export PDF")]]] ]
(balance-sheet* request)])))
children])))
(defn form [request]
(html-response (form* request)
(html-response (form* request
(balance-sheet* request))
:headers {"hx-retarget" "#balance-sheet-form"
"hx-push-url" (str "?" (:query-string request))}))
@@ -404,10 +405,13 @@
(defn print-balance-sheet [request]
(let [uuid (str (UUID/randomUUID))
{:keys [client warning]} (maybe-trim-clients request (:client (:query-params request)))
request (assoc-in request [:query-params :client] client)
pdf-data (make-balance-sheet-pdf request (:report (get-report request)))
name (balance-sheet-args->name request)
key (str "reports/balance-sheet/" uuid "/" name ".pdf")
url (str "https://" (:data-bucket env) "/" key)]
(println "CLIENT IS" client)
(s3/put-object :bucket-name (:data-bucket env/env)
:key key
:input-stream (io/make-input-stream pdf-data {})
@@ -415,7 +419,7 @@
:content-type "application/pdf"})
@(dc/transact conn
[{:report/name name
:report/client (map :db/id (:client (:query-params request)))
:report/client (map :db/id client)
:report/key key
:report/url url
:report/creator (:user (:identity request))
@@ -431,16 +435,17 @@
{}
"Ready!"
(com/modal-body {}
(let [bs (print-balance-sheet request)]
[:div.flex.flex-col.mt-4.space-y-4.items-center
[:a {:href (:report/url (print-balance-sheet request))}
[:a {:href (:report/url bs)}
[:div.w-24.h-24.bg-green-50.rounded-full.p-4.text-green-300 {:class " hover:scale-110 transition duration-100"}
svg/download]]
[:span.text-gray-800
"Click "
(com/link {:href (:report/url (print-balance-sheet request))} "here")
(com/link {:href (:report/url bs)} "here")
" to download"]
])
]))
nil))
:headers (-> {}
(assoc "hx-retarget" ".modal-stack")