adds general ledger links, allows starting new.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
:hx-target-400 "#form-errors .error-content"
|
||||
:hx-trigger "submit"
|
||||
:hx-target "this"
|
||||
"x-trap" "true" })
|
||||
"x-trap" "true"})
|
||||
|
||||
(defprotocol ModalWizardStep
|
||||
(step-key [this])
|
||||
@@ -99,11 +99,11 @@
|
||||
(step-name (get-step linear-wizard n))])))))
|
||||
(defn back-button [linear-wizard step 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))})
|
||||
{: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))})
|
||||
:class "dark:text-blue-500"}
|
||||
"Back"])
|
||||
|
||||
@@ -226,25 +226,28 @@
|
||||
:else
|
||||
"forward")))
|
||||
|
||||
(defn render-navigate [{ {:keys [wizard] :as request} :request to-step :to-step}]
|
||||
(let [current-step (get-current-step wizard)
|
||||
wizard (navigate wizard to-step)
|
||||
new-step (get-current-step wizard)
|
||||
transition-type (get-transition-type wizard (step-key current-step) to-step)]
|
||||
(html-response
|
||||
(render-wizard wizard
|
||||
(-> request
|
||||
(assoc :multi-form-state (-> (:multi-form-state request)
|
||||
(merge-multi-form-state)
|
||||
(select-state (edit-path new-step request) {})
|
||||
(#(cond-> %
|
||||
(satisfies? Initializable new-step)
|
||||
(assoc :step-params
|
||||
(init-step-params new-step % request))))))))
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
|
||||
"x-transition-type" (or transition-type "none")})))
|
||||
|
||||
(def next-handler
|
||||
(-> (fn [{:keys [wizard] :as request}]
|
||||
(let [current-step (get-current-step wizard)
|
||||
to-step (:to (:query-params request))
|
||||
wizard (navigate wizard to-step)
|
||||
new-step (get-current-step wizard)
|
||||
transition-type (get-transition-type wizard (step-key current-step) to-step)]
|
||||
(html-response
|
||||
(render-wizard wizard
|
||||
(-> request
|
||||
(assoc :multi-form-state (-> (:multi-form-state request)
|
||||
(merge-multi-form-state)
|
||||
(select-state (edit-path new-step request) {})
|
||||
(#(cond-> %
|
||||
(satisfies? Initializable new-step)
|
||||
(assoc :step-params
|
||||
(init-step-params new-step % request))))))))
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
|
||||
"x-transition-type" (or transition-type "none")})))
|
||||
(render-navigate {:request request
|
||||
:to-step (:to (:query-params request))}))
|
||||
(wrap-ensure-step)
|
||||
(wrap-schema-enforce :query-schema
|
||||
[:map
|
||||
@@ -321,9 +324,9 @@
|
||||
(defn open-wizard-handler [{:keys [wizard current-step] :as request}]
|
||||
(modal-response
|
||||
[: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')) {
|
||||
: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')
|
||||
@@ -361,19 +364,17 @@
|
||||
:any]]]
|
||||
(:form-params request)
|
||||
main-transformer)))))
|
||||
|
||||
#_(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" "[]",
|
||||
"current-step" ":payment-details",
|
||||
"mode" "advanced",
|
||||
"step-params"
|
||||
{"invoices"
|
||||
{"0" {"invoice_id" "17592297837035", "amount" "1"},
|
||||
"1" {"invoice_id" "17592297837049", "amount" "23.00"}}}})
|
||||
(mc/decode [:map [:step-params {:optional true} [:maybe :any]]]
|
||||
f
|
||||
main-transformer)
|
||||
|
||||
)
|
||||
#_(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" "[]",
|
||||
"current-step" ":payment-details",
|
||||
"mode" "advanced",
|
||||
"step-params"
|
||||
{"invoices"
|
||||
{"0" {"invoice_id" "17592297837035", "amount" "1"},
|
||||
"1" {"invoice_id" "17592297837049", "amount" "23.00"}}}})
|
||||
(mc/decode [:map [:step-params {:optional true} [:maybe :any]]]
|
||||
f
|
||||
main-transformer))
|
||||
Reference in New Issue
Block a user