Streamlines more user interface

This commit is contained in:
Bryce
2024-03-27 11:36:41 -07:00
parent 5c2d3d4487
commit 13a083e053
4 changed files with 30 additions and 23 deletions

View File

@@ -234,7 +234,13 @@
clients (some->> client-ids clients (some->> client-ids
seq seq
(pull-many (dc/db conn) (pull-many (dc/db conn)
d-clients/full-read))] '[:db/id :client/name :client/code :client/locations
:client/matches :client/feature-flags
{:client/bank-accounts [:db/id
{:bank-account/type [:db/ident]}
:bank-account/number
:bank-account/name
:bank-account/code]}]))]
(mu/with-context {:clients (take 10 (map :client/code clients))} (mu/with-context {:clients (take 10 (map :client/code clients))}
(handler (assoc request (handler (assoc request

View File

@@ -324,12 +324,13 @@
(handler (handler
(assoc request :wizard (hydrate-from-request linear-wizard request)))))) (assoc request :wizard (hydrate-from-request linear-wizard request))))))
(defn open-wizard-handler [{:keys [wizard current-step] :as request}] (defn open-wizard-handler [{:keys [wizard current-step query-params] :as request}]
(modal-response (cond->
[:div#transitioner.flex-1 {:x-data (hx/json {"transitionType" "none"}) (modal-response
:x-ref "transitioner" [:div#transitioner.flex-1 {:x-data (hx/json {"transitionType" "none"})
:class "" :x-ref "transitioner"
"@htmx:after-request" "if(event.detail.xhr.getResponseHeader('x-transition-type')) { :class ""
"@htmx:after-request" "if(event.detail.xhr.getResponseHeader('x-transition-type')) {
$refs.transitioner.classList.remove('forward') $refs.transitioner.classList.remove('forward')
$refs.transitioner.classList.remove('backward'); $refs.transitioner.classList.remove('backward');
$refs.transitioner.classList.add('group/transition') $refs.transitioner.classList.add('group/transition')
@@ -339,7 +340,8 @@
$refs.transitioner.classList.remove('group/transition') $refs.transitioner.classList.remove('group/transition')
} }
"} "}
(render-wizard wizard request)])) (render-wizard wizard request)])
(get query-params :replace-modal) (assoc-in [:headers "hx-trigger"] "modalswap")))

View File

@@ -143,7 +143,6 @@
(mut/select-keys (mm/form-schema linear-wizard) #{:invoice/client :invoice/vendor :invoice/date :invoice/due :invoice/scheduled-payment :invoice/total :invoice/invoice-number :customize-due-and-scheduled?})) (mut/select-keys (mm/form-schema linear-wizard) #{:invoice/client :invoice/vendor :invoice/date :invoice/due :invoice/scheduled-payment :invoice/total :invoice/invoice-number :customize-due-and-scheduled?}))
(render-step [this request] (render-step [this request]
(alog/peek ::check (:multi-form-state request))
(mm/default-render-step (mm/default-render-step
linear-wizard this linear-wizard this
:head [:div.p-2 "New invoice"] :head [:div.p-2 "New invoice"]
@@ -437,7 +436,6 @@
mm/Initializable mm/Initializable
(init-step-params (init-step-params
[_ current request] [_ current request]
(alog/peek ::step (:step-params current))
(if (not (seq (:invoice/expense-accounts (:step-params current)))) (if (not (seq (:invoice/expense-accounts (:step-params current))))
(assoc (:step-params current) :invoice/expense-accounts [{:db/id "123" (assoc (:step-params current) :invoice/expense-accounts [{:db/id "123"
:invoice-expense-account/location "Shared" :invoice-expense-account/location "Shared"
@@ -473,10 +471,12 @@
(com/button {:color :primary (com/button {:color :primary
:class "w-24" :class "w-24"
:hx-get (hu/url (bidi.bidi/path-for ssr-routes/only-routes ::route/pay-wizard) :hx-get (hu/url (bidi.bidi/path-for ssr-routes/only-routes ::route/pay-wizard)
{:selected (:db/id snapshot)})} "Pay now") {:selected (:db/id snapshot)
:replace-modal true})} "Pay now")
(com/button {:color :secondary (com/button {:color :secondary
:class "w-24" :class "w-24"
:hx-get (bidi.bidi/path-for ssr-routes/only-routes ::route/new-wizard)} "Add another") :hx-get (hu/url (bidi.bidi/path-for ssr-routes/only-routes ::route/new-wizard)
{:replace-modal true})} "Add another")
(com/button {:class "w-24" (com/button {:class "w-24"
"@click" "$dispatch('modalclose')"} "@click" "$dispatch('modalclose')"}
"Close")]) "Close")])
@@ -552,7 +552,6 @@
[:basic-details [:basic-details
:accounts :accounts
:next-steps]) :next-steps])
(get-step [this step-key] (get-step [this step-key]
(let [step-key-result (mc/parse mm/step-key-schema step-key) (let [step-key-result (mc/parse mm/step-key-schema step-key)
[step-key-type step-key] step-key-result] [step-key-type step-key] step-key-result]
@@ -562,7 +561,6 @@
step-key))) step-key)))
(form-schema [_] new-form-schema) (form-schema [_] new-form-schema)
(submit [this {:keys [multi-form-state request-method identity] :as request}] (submit [this {:keys [multi-form-state request-method identity] :as request}]
(let [invoice (:snapshot multi-form-state) (let [invoice (:snapshot multi-form-state)
client-id (->db-id (:invoice/client invoice)) client-id (->db-id (:invoice/client invoice))
vendor-id (->db-id (:invoice/vendor invoice)) vendor-id (->db-id (:invoice/vendor invoice))
@@ -584,8 +582,6 @@
(maybe-spread-locations) (maybe-spread-locations)
(update :invoice/date coerce/to-date) (update :invoice/date coerce/to-date)
(update :invoice/due coerce/to-date))]] (update :invoice/due coerce/to-date))]]
(alog/peek ::test transaction)
(assert-invoice-amounts-add-up (second transaction)) (assert-invoice-amounts-add-up (second transaction))
(assert-no-conflicting invoice) (assert-no-conflicting invoice)
(exception->4xx #(assert-can-see-client (:identity request) client-id)) (exception->4xx #(assert-can-see-client (:identity request) client-id))
@@ -612,6 +608,8 @@
#_(html-response [:div] #_(html-response [:div]
:headers {"hx-trigger" "modalclose,invalidated"}))) :headers {"hx-trigger" "modalclose,invalidated"})))
(def new-wizard (->NewWizard2 nil nil)) (def new-wizard (->NewWizard2 nil nil))
@@ -667,12 +665,12 @@
(defn account-prediction [{:keys [multi-form-state form-errors]}] (defn account-prediction [{:keys [multi-form-state form-errors]}]
(let [vendor (clientize-vendor (get-vendor (:invoice/vendor (:step-params multi-form-state))) (let [vendor (clientize-vendor (get-vendor (:invoice/vendor (:step-params multi-form-state)))
(->db-id (:invoice/client (:step-params multi-form-state)))) ] (->db-id (:invoice/client (:step-params multi-form-state))))]
(html-response (html-response
(if-let [account-name (:account/name (:vendor/default-account vendor))] (if-let [account-name (:account/name (:vendor/default-account vendor))]
[:div {:class "transition duration-300 ease-in-out htmx-added:opacity-0 opacity-100"} [:div {:class "transition duration-300 ease-in-out htmx-added:opacity-0 opacity-100"}
[:label {:class "block mb-2 text-sm font-medium text-gray-900 dark:text-white"} "Default expense account"] [:label {:class "block mb-2 text-sm font-medium text-gray-900 dark:text-white"} "Default expense account"]
[:div.flex.gap-2.items-center (com/pill {:color :primary} account-name) [:div.flex.gap-2.items-center (com/pill {:color :primary} account-name)
(com/validated-save-button (cond-> {:errors form-errors (com/validated-save-button (cond-> {:errors form-errors
;;:x-data (hx/json {}) ;;:x-data (hx/json {})

View File

@@ -81,15 +81,16 @@ input[type=number] {
"x-show" "open" "x-show" "open"
":aria-hidden" "!open" ":aria-hidden" "!open"
"x-data" (hx/json {"open" false "x-data" (hx/json {"open" false
"forceBackground" false
"unexpectedError" false}) "unexpectedError" false})
"x-on:htmx:response-error" "unexpectedError=true;" "x-on:htmx:response-error" "unexpectedError=true;"
"x-on:htmx:before-request" "unexpectedError=false" "x-on:htmx:before-request" "unexpectedError=false"
"@modalopen.document" "open=true; unexpectedError=null" "@modalopen.document" "open=true; unexpectedError=null"
"@modalclose.document" "open=false" "@modalclose.document" "open=false"
"@modalswap.document" "open=false; setTimeout(() => open=true)"} "@modalswap.document" "forceBackground=true; open=false; setTimeout(() => {open=true;forceBackground=false;}, 100)"}
[:div {:class "bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40 md:p-12" [:div {:class "bg-gray-900 bg-opacity-50 dark:bg-opacity-80 fixed inset-0 z-40 md:p-12"
"x-show" "open" "x-show" "open || forceBackground"
":aria-hidden" "!open" ":aria-hidden" "!open"
"x-transition:enter" "duration-300" "x-transition:enter" "duration-300"
"x-transition:enter-start" "!bg-opacity-0" "x-transition:enter-start" "!bg-opacity-0"