Add vendor pre-population for bulk code and individual edit forms
- Add vendor-changed HTMX handlers for both bulk code and individual edit - Pre-populate default account at 100% when vendor is selected and no accounts exist - Fix render-accounts-section to render from step-params correctly - Change bulk code vendor-changed from hx-get to hx-post to include form data - Add routes for vendor-changed endpoints - Update e2e tests to cover vendor pre-population - Run lein cljfmt fix across codebase
This commit is contained in:
@@ -33,18 +33,17 @@
|
||||
(com/content-card {:class " w-[748px]"
|
||||
:hx-target "this"
|
||||
:hx-swap "outerHTML"}
|
||||
[:div.col-span-1.p-4 {:class "p-4 sm:p-6 space-y-4 overflow-visible "
|
||||
}
|
||||
[:div.col-span-1.p-4 {:class "p-4 sm:p-6 space-y-4 overflow-visible "}
|
||||
[:h3 {:class "mb-4 text-xl font-semibold dark:text-white"}
|
||||
"Signature"]
|
||||
[:div#signature-notification.notification.block {:style {:display "none"}}]
|
||||
[:div {:x-data (hx/json {"signature" nil
|
||||
"editing" false
|
||||
"existing" (boolean signature-file)})
|
||||
:hx-put (bidi/path-for ssr-routes/only-routes
|
||||
:company-update-signature)
|
||||
:hx-trigger "accepted"
|
||||
:hx-vals "js:{signatureData: event.detail.signatureData}"}
|
||||
"editing" false
|
||||
"existing" (boolean signature-file)})
|
||||
:hx-put (bidi/path-for ssr-routes/only-routes
|
||||
:company-update-signature)
|
||||
:hx-trigger "accepted"
|
||||
:hx-vals "js:{signatureData: event.detail.signatureData}"}
|
||||
[:div.htmx-indicator
|
||||
[:div.bg-gray-100.flex.items-center.text-green-500.justify-center.rounded.rounded-lg.border.border-gray-400 {:style {:width "696px" :height "261px"}}
|
||||
(svg/spinner {:class "w-4 h-4 text-primary-300"})
|
||||
@@ -58,7 +57,6 @@
|
||||
:x-show "existing && !editing"}])
|
||||
[:canvas.rounded.rounded-lg.border.border-gray-300
|
||||
|
||||
|
||||
{:style {:width 696
|
||||
:height 261}
|
||||
:x-init "signature= new SignaturePad($el); signature.off()"
|
||||
@@ -67,7 +65,6 @@
|
||||
:height 261
|
||||
:x-show "existing ? editing: true"}]]
|
||||
|
||||
|
||||
[:div.flex.gap-2.justify-end
|
||||
(com/button {:color :primary
|
||||
:x-show "!editing"
|
||||
@@ -83,7 +80,7 @@
|
||||
:x-show "editing"}
|
||||
"Accept")]]
|
||||
|
||||
[:div
|
||||
[:div
|
||||
[:div.flex.justify-center " - or -"]
|
||||
[:form {:hx-post (bidi/path-for ssr-routes/only-routes
|
||||
:company-upload-signature)
|
||||
@@ -92,18 +89,17 @@
|
||||
#_#_:hx-target "#signature-notification"
|
||||
:hx-swap "outerHTML"
|
||||
:id "upload"
|
||||
:hx-trigger "z"
|
||||
}
|
||||
[:div.htmx-indicator
|
||||
[:div.bg-gray-100.flex.items-center.text-green-500.justify-center.rounded.rounded-lg.border.border-gray-400 {:style {:width "696px" :height "261px"}}
|
||||
(svg/spinner {:class "w-4 h-4 text-primary-300"})
|
||||
[:div.ml-3 "Loading..."]]]
|
||||
[:div.htmx-indicator-hidden
|
||||
[:div.border-2.border-dashed.rounded-lg.p-4.w-full.text-center.cursor-pointer.h-64.flex.items-center.justify-center.text-lg.relative
|
||||
{:x-data (hx/json {"files" nil
|
||||
"hovering" false})
|
||||
:x-dispatch:z "files"
|
||||
":class" "{'bg-blue-100': !hovering,
|
||||
:hx-trigger "z"}
|
||||
[:div.htmx-indicator
|
||||
[:div.bg-gray-100.flex.items-center.text-green-500.justify-center.rounded.rounded-lg.border.border-gray-400 {:style {:width "696px" :height "261px"}}
|
||||
(svg/spinner {:class "w-4 h-4 text-primary-300"})
|
||||
[:div.ml-3 "Loading..."]]]
|
||||
[:div.htmx-indicator-hidden
|
||||
[:div.border-2.border-dashed.rounded-lg.p-4.w-full.text-center.cursor-pointer.h-64.flex.items-center.justify-center.text-lg.relative
|
||||
{:x-data (hx/json {"files" nil
|
||||
"hovering" false})
|
||||
:x-dispatch:z "files"
|
||||
":class" "{'bg-blue-100': !hovering,
|
||||
'border-blue-300': !hovering,
|
||||
'text-blue-700': !hovering,
|
||||
'bg-green-100': hovering,
|
||||
@@ -111,23 +107,20 @@
|
||||
'text-green-700': hovering
|
||||
}"}
|
||||
|
||||
[:input {:type "file"
|
||||
:name "file"
|
||||
:class "absolute inset-0 m-0 p-0 w-full h-full outline-none opacity-0",
|
||||
:x-on:change "files = $event.target.files;",
|
||||
:x-on:dragover "hovering = true",
|
||||
:x-on:dragleave "hovering = false",
|
||||
:x-on:drop "hovering = false"}]
|
||||
[:div.flex.flex-col.space-2
|
||||
[:div
|
||||
[:ul {:x-show "files != null"}
|
||||
[:template {:x-for "f in files"}
|
||||
[:li (com/pill {:color :primary :x-text "f.name"})]]]]
|
||||
|
||||
|
||||
[:input {:type "file"
|
||||
:name "file"
|
||||
:class "absolute inset-0 m-0 p-0 w-full h-full outline-none opacity-0",
|
||||
:x-on:change "files = $event.target.files;",
|
||||
:x-on:dragover "hovering = true",
|
||||
:x-on:dragleave "hovering = false",
|
||||
:x-on:drop "hovering = false"}]
|
||||
[:div.flex.flex-col.space-2
|
||||
[:div
|
||||
[:ul {:x-show "files != null"}
|
||||
[:template {:x-for "f in files"}
|
||||
[:li (com/pill {:color :primary :x-text "f.name"})]]]]
|
||||
|
||||
|
||||
[:div.htmx-indicator-hidden "Drop a signature file (696x261 pixels jpeg) here."]]]] ]]])))
|
||||
[:div.htmx-indicator-hidden "Drop a signature file (696x261 pixels jpeg) here."]]]]]]])))
|
||||
|
||||
(defn upload-signature-data [{{:strs [signatureData]} :form-params client :client :as request}]
|
||||
(let [prefix "data:image/png;base64,"]
|
||||
@@ -149,66 +142,66 @@
|
||||
|
||||
(defn upload-signature-file [{{:strs [signatureData]} :form-params client :client user :identity :as request}]
|
||||
(assert-can-see-client user client)
|
||||
(let [{:strs [file]} (:multipart-params request) ]
|
||||
(try
|
||||
(let [signature-id (str (UUID/randomUUID)) ]
|
||||
(s3/put-object :bucket-name "integreat-signature-images" #_(:data-bucket env)
|
||||
:key (str signature-id ".jpg")
|
||||
:input-stream (io/input-stream (:tempfile file))
|
||||
:metadata {:content-type "image/jpeg"
|
||||
:content-length (:length (:tempfile file))}
|
||||
:canned-acl "public-read")
|
||||
@(dc/transact conn [{:db/id (:db/id client)
|
||||
:client/signature-file (str "https://integreat-signature-images.s3.amazonaws.com/" signature-id ".jpg")}])
|
||||
(html-response
|
||||
(signature request)))
|
||||
(catch Exception e
|
||||
(println e)
|
||||
#_(-> result
|
||||
(assoc :error? true)
|
||||
(update :results conj {:filename filename
|
||||
:response (.getMessage e)
|
||||
:sample (:sample (ex-data e))
|
||||
:template (:template (ex-data e))}))))
|
||||
(let [{:strs [file]} (:multipart-params request)]
|
||||
(try
|
||||
(let [signature-id (str (UUID/randomUUID))]
|
||||
(s3/put-object :bucket-name "integreat-signature-images" #_(:data-bucket env)
|
||||
:key (str signature-id ".jpg")
|
||||
:input-stream (io/input-stream (:tempfile file))
|
||||
:metadata {:content-type "image/jpeg"
|
||||
:content-length (:length (:tempfile file))}
|
||||
:canned-acl "public-read")
|
||||
@(dc/transact conn [{:db/id (:db/id client)
|
||||
:client/signature-file (str "https://integreat-signature-images.s3.amazonaws.com/" signature-id ".jpg")}])
|
||||
(html-response
|
||||
(signature request)))
|
||||
(catch Exception e
|
||||
(println e)
|
||||
#_(-> result
|
||||
(assoc :error? true)
|
||||
(update :results conj {:filename filename
|
||||
:response (.getMessage e)
|
||||
:sample (:sample (ex-data e))
|
||||
:template (:template (ex-data e))}))))
|
||||
#_(html-response [:div#page-notification.p-4.rounded-lg
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700"
|
||||
"bg-primary-50 text-primary-700")}
|
||||
[:table
|
||||
[:thead
|
||||
[:tr [:td "File"] [:td "Result"]
|
||||
[:td "Template"]
|
||||
(if (:error? results)
|
||||
[:td "Sample match"])]
|
||||
#_[:tr "Result"]
|
||||
#_[:tr "Template"]]
|
||||
(for [r (:results results)]
|
||||
[:tr
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:filename r)]
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:response r)]
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
"Template: " (:template r)]
|
||||
(if (:error? results)
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700"
|
||||
"bg-primary-50 text-primary-700")}
|
||||
[:table
|
||||
[:thead
|
||||
[:tr [:td "File"] [:td "Result"]
|
||||
[:td "Template"]
|
||||
(if (:error? results)
|
||||
[:td "Sample match"])]
|
||||
#_[:tr "Result"]
|
||||
#_[:tr "Template"]]
|
||||
(for [r (:results results)]
|
||||
[:tr
|
||||
[:td.p-2.border
|
||||
{:class "bg-red-50 text-red-700 border-red-300"}
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:filename r)]
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:response r)]
|
||||
[:td.p-2.border
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
"Template: " (:template r)]
|
||||
(if (:error? results)
|
||||
[:td.p-2.border
|
||||
{:class "bg-red-50 text-red-700 border-red-300"}
|
||||
|
||||
[:ul
|
||||
(for [[k v] (dissoc (:sample r) :template :source-url :full-text :text)]
|
||||
[:li (name k) ": " (str v)])]
|
||||
#_(:template r)])])]]
|
||||
:headers
|
||||
{"hx-trigger" "invalidated"})))
|
||||
[:ul
|
||||
(for [[k v] (dissoc (:sample r) :template :source-url :full-text :text)]
|
||||
[:li (name k) ": " (str v)])]
|
||||
#_(:template r)])])]]
|
||||
:headers
|
||||
{"hx-trigger" "invalidated"})))
|
||||
|
||||
(defn main-content* [{:keys [client identity] :as request}]
|
||||
(if-not client
|
||||
@@ -276,7 +269,6 @@
|
||||
|
||||
(def search (wrap-json-response search))
|
||||
|
||||
|
||||
(defn bank-account-search [{:keys [route-params query-params clients]}]
|
||||
(let [valid-client-ids (set (map :db/id clients))
|
||||
selected-client-id (Long/parseLong (get route-params :db/id))
|
||||
|
||||
Reference in New Issue
Block a user