Makes print checks basically work.

This commit is contained in:
Bryce
2024-03-16 19:50:04 -07:00
parent 5b9c4b7aef
commit a972df1d43
12 changed files with 2134 additions and 1503 deletions

View File

@@ -30,8 +30,7 @@
:hx-target-400 "#form-errors .error-content"
:hx-trigger "submit"
:hx-target "this"
"x-trap" "true"
:class "h-full w-full"})
"x-trap" "true" })
(defprotocol ModalWizardStep
(step-key [this])
@@ -114,12 +113,13 @@
:to (encode-step-key (step-key (get-step linear-wizard n)))})}
(step-name (get-step linear-wizard n))])))))
(defn back-button [linear-wizard step validation-route]
[:a.cursor-pointer.whitespace-nowrap {:hx-put (hu/url (bidi/path-for ssr-routes/only-routes validation-route)
[:a.cursor-pointer.whitespace-nowrap.font-medium.text-blue-600 {:hx-put (hu/url (bidi/path-for ssr-routes/only-routes validation-route)
{:from (encode-step-key (step-key step))
:to (encode-step-key (->> (partition-all 2 1 (steps linear-wizard))
(filter (fn [[from to]]
(= to (step-key step))))
ffirst))})}
ffirst))})
:class "dark:text-blue-500"}
"Back"])
(defn default-next-button [linear-wizard step validation-route]
@@ -146,7 +146,7 @@
[:div.w-5.h-5 svg/arrow-right]))))
(defn default-step-body [params & children]
[:div.space-y-1 {:class "w-[600px] h-[700px]"}
[:div.space-y-1 {}
children])
(defn default-step-footer [linear-wizard step & {:keys [validation-route
@@ -174,11 +174,31 @@
(let [is-last? (= (step-key step) (last (steps linear-wizard)))]
(com/modal-card-advanced
{"@keydown.enter.prevent.stop" "$refs.next.click()"
:class (str (when is-last? "last-modal-step")
" transition duration-300 ease-in-out
:class (str
"w-[750px] h-[600px]
group-[.forward]/transition:htmx-swapping:opacity-0
group-[.forward]/transition:htmx-swapping:-translate-x-1/4
group-[.forward]/transition:htmx-swapping:scale-75
group-[.forward]/transition:htmx-swapping:ease-in
group-[.forward]/transition:htmx-added:opacity-0
group-[.forward]/transition:htmx-added:scale-75
group-[.forward]/transition:htmx-added:translate-x-1/4
group-[.forward]/transition:htmx-added:ease-out
group-[.backward]/transition:htmx-swapping:opacity-0
group-[.backward]/transition:htmx-swapping:translate-x-1/4
group-[.backward]/transition:htmx-swapping:scale-75
group-[.backward]/transition:htmx-swapping:ease-in
group-[.backward]/transition:htmx-added:opacity-0
group-[.backward]/transition:htmx-added:scale-75
group-[.backward]/transition:htmx-added:-translate-x-1/4
group-[.backward]/transition:htmx-added:ease-out
opacity-100 translate-x-0 scale-100"
(when is-last? "last-modal-step")
" transition duration-150
")
":class" (hiccup/raw "{
\"htmx-swapping:-translate-x-2/3 htmx-swapping:opacity-0 htmx-swapping:scale-0 htmx-added:translate-x-2/3 htmx-added:opacity-0 htmx-added:scale-0 scale-100 translate-x-0 opacity-100\": $data.transitionType=='forward',
#_#_":class" (hiccup/raw "{
\"htmx-added:opacity-0 opacity-100\": $data.transitionType=='forward',
\"htmx-swapping:translate-x-2/3 htmx-swapping:opacity-0 htmx-swapping:scale-0 htmx-added:-translate-x-2/3 htmx-added:opacity-0 htmx-added:scale-0 scale-100 translate-x-0 opacity-100\": $data.transitionType=='backward'
}
")
@@ -186,7 +206,7 @@
(com/modal-header {}
head)
#_(com/modal-header-attachment {})
[:div.flex.shrink
[:div.flex.shrink.overflow-auto.grow
[:div.grow-0.pr-6.pt-2.bg-gray-100.self-stretch #_{:style "margin-left:-20px"} (render-timeline linear-wizard step validation-route)]
(com/modal-body {}
body)]
@@ -197,15 +217,9 @@
(defn wrap-ensure-step [handler]
(->
(fn [{:keys [wizard multi-form-state] :as request}]
(println "ENSURE STEP")
(clojure.pprint/pprint (:step-params (:multi-form-state request)))
(assert-schema (step-schema (get-current-step wizard)) (:step-params multi-form-state))
(handler request))
(wrap-form-4xx-2 (fn [{:keys [wizard] :as request}] ;; THIS MAY BE BETTER TO JUST MAKE THE LINEAR WIZARD POPULATE FROM THE REQUEST
(println "FINAL")
(clojure.pprint/pprint (:step-params (:multi-form-state request)))
(html-response
(render-wizard wizard request)
:headers {"x-transition-type" "none"
@@ -242,7 +256,7 @@
(select-state
(edit-path new-step request)
(init-step-params- new-step request))))))
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.15s")
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
"x-transition-type" (or transition-type "none")})))
(wrap-ensure-step)
(wrap-schema-enforce :query-schema
@@ -260,7 +274,7 @@
(render-wizard wizard
(-> request
(assoc :multi-form-state (discard-changes current-step multi-form-state))))
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.15s")
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
"x-transition-type" (or transition-type "none")})))
(wrap-schema-enforce :query-schema
[:map
@@ -319,8 +333,19 @@
(defn open-wizard-handler [{:keys [wizard current-step] :as request}]
(modal-response
[:div {:x-data (hx/json {"transitionType" "none"})
"@htmx:after-request" "if(event.detail.xhr.getResponseHeader('x-transition-type')) { $data.transitionType = event.detail.xhr.getResponseHeader('x-transition-type');}"}
[:div#transitioner.flex-1 {:x-data (hx/json {"transitionType" "none"})
:x-ref "transitioner"
:class ""
"@htmx:after-request" "if(event.detail.xhr.getResponseHeader('x-transition-type')) {
$refs.transitioner.classList.remove('forward')
$refs.transitioner.classList.remove('backward');
$refs.transitioner.classList.add('group/transition')
$refs.transitioner.classList.add(event.detail.xhr.getResponseHeader('x-transition-type'));
} else {
$refs.transitioner.classList.remove('group/transition')
}
"}
(render-wizard wizard request)]))
@@ -335,24 +360,6 @@
(wrap-init-multi-form-state
handler
(fn parse-multi-form-state [request]
(println "HERE WE ARE FULL")
(clojure.pprint/pprint (:step-params (:form-params request)))
(println "OK NOW")
(clojure.pprint/pprint (:step-params (map->MultiStepFormState (mc/decode [:map
[:snapshot {:optional true
:decode/arbitrary
#(clojure.edn/read-string {:readers clj-time.coerce/data-readers
:eof nil}
%)}
[:maybe :any]]
[:edit-path {:optional true :decode/arbitrary (fn [z]
(clojure.edn/read-string z))} [:maybe [:sequential {:min 0} any?]]]
[:step-params {:optional true}
[:maybe
:any]]]
(:form-params request)
main-transformer))))
(map->MultiStepFormState (mc/decode [:map
[:snapshot {:optional true
:decode/arbitrary
@@ -368,7 +375,7 @@
(:form-params request)
main-transformer)))))
(comment
#_(comment
(def f {"snapshot"
"{:invoices [{:invoice_id 17592297837035, :amount 23.0, :invoice {:db/id 17592297837035, :invoice/vendor {:db/id 17592186045722, :vendor/name \"Sysco\"}, :invoice/client {:db/id 17592232555238}, :invoice/outstanding-balance 23.0, :invoice/invoice-number \"702,34\"}} {:invoice_id 17592297837049, :amount 23.0, :invoice {:db/id 17592297837049, :invoice/vendor {:db/id 17592186045722, :vendor/name \"Sysco\"}, :invoice/client {:db/id 17592232555238}, :invoice/outstanding-balance 23.0, :invoice/invoice-number \"80[234234\"}}], :client 17592232555238}",
"edit-path" "[]",