Streamlines more user interface
This commit is contained in:
@@ -234,7 +234,13 @@
|
||||
clients (some->> client-ids
|
||||
seq
|
||||
(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))}
|
||||
(handler (assoc request
|
||||
|
||||
@@ -324,12 +324,13 @@
|
||||
(handler
|
||||
(assoc request :wizard (hydrate-from-request linear-wizard request))))))
|
||||
|
||||
(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')) {
|
||||
(defn open-wizard-handler [{:keys [wizard current-step query-params] :as request}]
|
||||
(cond->
|
||||
(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')) {
|
||||
$refs.transitioner.classList.remove('forward')
|
||||
$refs.transitioner.classList.remove('backward');
|
||||
$refs.transitioner.classList.add('group/transition')
|
||||
@@ -339,7 +340,8 @@
|
||||
$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")))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
(def new-form-schema
|
||||
[:map
|
||||
[:customize-due-and-scheduled? {:optional true :default false :decode/arbitrary (fn [x] (if (= "" x)
|
||||
false
|
||||
false
|
||||
x))} [:maybe :boolean]]
|
||||
[:invoice/client entity-id]
|
||||
[:invoice/date clj-date-schema]
|
||||
@@ -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?}))
|
||||
|
||||
(render-step [this request]
|
||||
(alog/peek ::check (:multi-form-state request))
|
||||
(mm/default-render-step
|
||||
linear-wizard this
|
||||
:head [:div.p-2 "New invoice"]
|
||||
@@ -194,7 +193,7 @@
|
||||
:x-model "vendorId"})]))
|
||||
|
||||
|
||||
[:div.flex.items-center.gap-2
|
||||
[:div.flex.items-center.gap-2
|
||||
(fc/with-field :invoice/date
|
||||
(com/validated-field
|
||||
{:label "Date"
|
||||
@@ -437,7 +436,6 @@
|
||||
mm/Initializable
|
||||
(init-step-params
|
||||
[_ current request]
|
||||
(alog/peek ::step (:step-params current))
|
||||
(if (not (seq (:invoice/expense-accounts (:step-params current))))
|
||||
(assoc (:step-params current) :invoice/expense-accounts [{:db/id "123"
|
||||
:invoice-expense-account/location "Shared"
|
||||
@@ -473,10 +471,12 @@
|
||||
(com/button {:color :primary
|
||||
:class "w-24"
|
||||
: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
|
||||
: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"
|
||||
"@click" "$dispatch('modalclose')"}
|
||||
"Close")])
|
||||
@@ -552,7 +552,6 @@
|
||||
[:basic-details
|
||||
:accounts
|
||||
:next-steps])
|
||||
|
||||
(get-step [this step-key]
|
||||
(let [step-key-result (mc/parse mm/step-key-schema step-key)
|
||||
[step-key-type step-key] step-key-result]
|
||||
@@ -562,7 +561,6 @@
|
||||
step-key)))
|
||||
(form-schema [_] new-form-schema)
|
||||
(submit [this {:keys [multi-form-state request-method identity] :as request}]
|
||||
|
||||
(let [invoice (:snapshot multi-form-state)
|
||||
client-id (->db-id (:invoice/client invoice))
|
||||
vendor-id (->db-id (:invoice/vendor invoice))
|
||||
@@ -584,8 +582,6 @@
|
||||
(maybe-spread-locations)
|
||||
(update :invoice/date coerce/to-date)
|
||||
(update :invoice/due coerce/to-date))]]
|
||||
(alog/peek ::test transaction)
|
||||
|
||||
(assert-invoice-amounts-add-up (second transaction))
|
||||
(assert-no-conflicting invoice)
|
||||
(exception->4xx #(assert-can-see-client (:identity request) client-id))
|
||||
@@ -612,6 +608,8 @@
|
||||
#_(html-response [:div]
|
||||
:headers {"hx-trigger" "modalclose,invalidated"})))
|
||||
|
||||
|
||||
|
||||
(def new-wizard (->NewWizard2 nil nil))
|
||||
|
||||
|
||||
@@ -667,13 +665,13 @@
|
||||
|
||||
(defn account-prediction [{:keys [multi-form-state form-errors]}]
|
||||
(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
|
||||
(if-let [account-name (:account/name (:vendor/default-account vendor))]
|
||||
[: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"]
|
||||
[:div.flex.gap-2.items-center (com/pill {:color :primary} account-name)
|
||||
[: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)
|
||||
(com/validated-save-button (cond-> {:errors form-errors
|
||||
;;:x-data (hx/json {})
|
||||
:class "w-24"
|
||||
|
||||
@@ -81,15 +81,16 @@ input[type=number] {
|
||||
"x-show" "open"
|
||||
":aria-hidden" "!open"
|
||||
"x-data" (hx/json {"open" false
|
||||
"forceBackground" false
|
||||
"unexpectedError" false})
|
||||
"x-on:htmx:response-error" "unexpectedError=true;"
|
||||
"x-on:htmx:before-request" "unexpectedError=false"
|
||||
"@modalopen.document" "open=true; unexpectedError=null"
|
||||
"@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"
|
||||
"x-show" "open"
|
||||
"x-show" "open || forceBackground"
|
||||
":aria-hidden" "!open"
|
||||
"x-transition:enter" "duration-300"
|
||||
"x-transition:enter-start" "!bg-opacity-0"
|
||||
|
||||
Reference in New Issue
Block a user