progress on invoices.
This commit is contained in:
@@ -17,25 +17,31 @@
|
||||
(nil? color)
|
||||
"white"
|
||||
|
||||
(sequential? color)
|
||||
(first color)
|
||||
|
||||
:else
|
||||
color)
|
||||
base-weight (or (when (sequential? color)
|
||||
(second color))
|
||||
500)
|
||||
disabled-weight (when disabled 400)]
|
||||
|
||||
(format " bg-%s-%d hover:bg-%s-%d focus:ring-%s-%d dark:bg-%s-%d dark:hover:bg-%s-%d "
|
||||
base-color
|
||||
(or disabled-weight 500)
|
||||
(or disabled-weight (+ base-weight 0))
|
||||
|
||||
base-color
|
||||
(or disabled-weight 600)
|
||||
(or disabled-weight (+ base-weight 100))
|
||||
|
||||
base-color
|
||||
(or disabled-weight 200)
|
||||
(or disabled-weight (int (* base-weight 0.5)))
|
||||
|
||||
base-color
|
||||
(or disabled-weight 600)
|
||||
(or disabled-weight (+ base-weight 100))
|
||||
|
||||
base-color
|
||||
(or disabled-weight 700)
|
||||
(or disabled-weight (+ base-weight 200))
|
||||
|
||||
)))
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
[auto-ap.ssr.nested-form-params :refer [wrap-nested-form-params]]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [ html-response
|
||||
:refer [html-response
|
||||
assert-schema
|
||||
main-transformer
|
||||
modal-response
|
||||
@@ -31,7 +31,7 @@
|
||||
:hx-trigger "submit"
|
||||
:hx-target "this"
|
||||
"x-trap" "true"
|
||||
:class "h-full w-full" })
|
||||
:class "h-full w-full"})
|
||||
|
||||
(defprotocol ModalWizardStep
|
||||
(step-key [this])
|
||||
@@ -57,7 +57,7 @@
|
||||
(hydrate-from-request [this request])
|
||||
(get-current-step [this])
|
||||
(navigate [this step-key])
|
||||
|
||||
|
||||
(form-schema [this])
|
||||
(steps [this])
|
||||
(get-step [this step-key])
|
||||
@@ -197,9 +197,15 @@
|
||||
(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"
|
||||
@@ -223,25 +229,25 @@
|
||||
|
||||
(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)
|
||||
(init-step-params- new-step request))))))
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.15s")
|
||||
"x-transition-type" (or transition-type "none")})))
|
||||
(wrap-ensure-step)
|
||||
(wrap-schema-enforce :query-schema
|
||||
[:map
|
||||
[:to step-key-schema]])))
|
||||
(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)
|
||||
(init-step-params- new-step request))))))
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.15s")
|
||||
"x-transition-type" (or transition-type "none")})))
|
||||
(wrap-ensure-step)
|
||||
(wrap-schema-enforce :query-schema
|
||||
[:map
|
||||
[:to step-key-schema]])))
|
||||
|
||||
(def discard-handler
|
||||
(->
|
||||
@@ -263,7 +269,7 @@
|
||||
(def submit-handler
|
||||
(-> (fn [{:keys [wizard multi-form-state] :as request}]
|
||||
(submit wizard (-> request
|
||||
(assoc :multi-form-state (merge-multi-form-state multi-form-state)))))
|
||||
(assoc :multi-form-state (merge-multi-form-state multi-form-state)))))
|
||||
(wrap-ensure-step)))
|
||||
|
||||
(defn default-render-wizard [linear-wizard {:keys [multi-form-state form-errors snapshot current-step] :as request} & {:keys [form-params]}]
|
||||
@@ -313,12 +319,8 @@
|
||||
|
||||
(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 {: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');}"}
|
||||
(render-wizard wizard request)]))
|
||||
|
||||
|
||||
@@ -333,6 +335,24 @@
|
||||
(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
|
||||
@@ -346,4 +366,20 @@
|
||||
[:maybe
|
||||
:any]]]
|
||||
(:form-params request)
|
||||
main-transformer)))))
|
||||
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)
|
||||
|
||||
)
|
||||
@@ -2,7 +2,7 @@
|
||||
(:require [auto-ap.ssr.hiccup-helper :as hh]
|
||||
[auto-ap.ssr.hx :as hx]))
|
||||
|
||||
(defn radio- [{:keys [options name title size orientation] :or {size :medium} selected-value :value}]
|
||||
(defn radio-card- [{:keys [options name title size orientation] :or {size :medium} selected-value :value}]
|
||||
[:h3 {:class "mb-4 font-semibold text-gray-900 dark:text-white"} title]
|
||||
[:ul {:class (cond-> "w-48 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg dark:bg-gray-700 dark:border-gray-600 dark:text-white"
|
||||
(= orientation :horizontal) (-> (hh/add-class "flex gap-2 flex-wrap")
|
||||
@@ -26,6 +26,42 @@
|
||||
(str " " "text-sm"))}
|
||||
(= (cond-> selected-value (keyword? selected-value) clojure.core/name) value) (assoc :checked true))]
|
||||
[:label {:for (str "list-" name "-" value)
|
||||
:class
|
||||
(cond-> "w-full ml-2 font-medium text-gray-900 dark:text-gray-300"
|
||||
(= size :small)
|
||||
(str " " "text-xs py-2")
|
||||
|
||||
(= size :medium)
|
||||
(str " " "text-sm py-3")
|
||||
|
||||
(= orientation :horizontal)
|
||||
(hh/remove-class "w-full"))} content]]])])
|
||||
|
||||
(defn radio-list- [{:keys [options name x-model title size orientation] :or {size :medium} selected-value :value}]
|
||||
[:h3 {:class "mb-4 font-semibold text-gray-900 dark:text-white"} title]
|
||||
[:ul {:class (cond-> "w-48 text-sm font-medium text-gray-900"
|
||||
(= orientation :horizontal) (-> (hh/add-class "flex gap-2 flex-wrap")
|
||||
(hh/remove-wildcard ["w-" "rounded-lg" "border" "bg-"])))}
|
||||
(for [{:keys [value content]} options]
|
||||
[:li {:class (cond-> "w-full"
|
||||
(= orientation :horizontal) (-> (hh/remove-wildcard ["w-full" "rounded-"])
|
||||
(hh/add-class "w-auto shrink-0 block px-3")))}
|
||||
[:div {:class (cond-> "flex items-center"
|
||||
(not= orientation :horizontal) (hh/add-class "pl-3"))}
|
||||
[:input (cond-> {:id (str "list-" name "-" value)
|
||||
:x-model x-model
|
||||
:type "radio",
|
||||
:value value
|
||||
:name name
|
||||
:class
|
||||
(cond-> "w-4 h-4 text-blue-600"
|
||||
(= size :small)
|
||||
(str " " "text-xs")
|
||||
|
||||
(= size :medium)
|
||||
(str " " "text-sm"))}
|
||||
(= (cond-> selected-value (keyword? selected-value) clojure.core/name) value) (assoc :checked true))]
|
||||
[:label {:for (str "list-" name "-" value)
|
||||
:class
|
||||
(cond-> "w-full ml-2 font-medium text-gray-900 dark:text-gray-300"
|
||||
(= size :small)
|
||||
|
||||
Reference in New Issue
Block a user