- 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
31 lines
1.6 KiB
Clojure
31 lines
1.6 KiB
Clojure
(ns auto-ap.ssr.common-handlers
|
|
(:require [auto-ap.ssr.form-cursor :as fc]
|
|
[auto-ap.ssr.utils :refer [html-response wrap-schema-enforce]]))
|
|
|
|
(defn add-new-entity-handler
|
|
([path render-fn] (add-new-entity-handler path
|
|
render-fn
|
|
(fn default-data [base _]
|
|
base)))
|
|
([path render-fn build-data]
|
|
(-> (fn new-entity [{{:keys [index]} :query-params :as request}]
|
|
(html-response
|
|
(fc/start-form-with-prefix (conj path (or index 0))
|
|
(build-data {:db/id (str (java.util.UUID/randomUUID))
|
|
:new? true} request)
|
|
[]
|
|
(render-fn fc/*current* request))))
|
|
(wrap-schema-enforce :query-schema [:map
|
|
[:index {:optional true
|
|
:default 0} [nat-int? {:default 0}]]]))))
|
|
|
|
(defn add-new-primitive-handler [path default-value render-fn]
|
|
(-> (fn new-location-match [{{:keys [index]} :query-params}]
|
|
(html-response
|
|
(fc/start-form-with-prefix (conj path (or index 0))
|
|
default-value
|
|
[]
|
|
(render-fn fc/*current*))))
|
|
(wrap-schema-enforce :query-schema [:map
|
|
[:index {:optional true
|
|
:default 0} [nat-int? {:default 0}]]]))) |