From 5c2d3d4487652a1b7c8d83dfbee64bfaace9d8a9 Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 27 Mar 2024 09:21:25 -0700 Subject: [PATCH] Slightly better UX --- .../auto_ap/ssr/components/multi_modal.clj | 9 ++-- .../ssr/invoice/new_invoice_wizard.clj | 46 +++++++++---------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/clj/auto_ap/ssr/components/multi_modal.clj b/src/clj/auto_ap/ssr/components/multi_modal.clj index 38bd0939..74e626fb 100644 --- a/src/clj/auto_ap/ssr/components/multi_modal.clj +++ b/src/clj/auto_ap/ssr/components/multi_modal.clj @@ -192,7 +192,9 @@ head) #_(com/modal-header-attachment {}) [:div.flex.shrink.overflow-auto.grow - [:div.grow-0.pr-6.pt-2.bg-gray-100.self-stretch.hidden.md:block #_{:style "margin-left:-20px"} (render-timeline linear-wizard step validation-route)] + (when (:render-timeline? linear-wizard) + [:div.grow-0.pr-6.pt-2.bg-gray-100.self-stretch.hidden.md:block #_{:style "margin-left:-20px"} + (render-timeline linear-wizard step validation-route)]) (com/modal-body {} body)] @@ -276,8 +278,9 @@ (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]}] - (let [current-step (get-current-step linear-wizard) +(defn default-render-wizard [linear-wizard {:keys [multi-form-state form-errors snapshot current-step] :as request} & {:keys [form-params render-timeline?] + :or {render-timeline? true}}] + (let [current-step (get-current-step (assoc linear-wizard :render-timeline? render-timeline?)) edit-path (edit-path current-step request)] [:form#wizard-form form-params (fc/start-form multi-form-state (when form-errors {:step-params form-errors}) diff --git a/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj b/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj index 0c35be58..f99dd140 100644 --- a/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj +++ b/src/clj/auto_ap/ssr/invoice/new_invoice_wizard.clj @@ -129,7 +129,6 @@ ;; TODO account / vendor search should use allowances - (defrecord BasicDetailsStep [linear-wizard] mm/ModalWizardStep (step-name [_] @@ -195,25 +194,25 @@ :x-model "vendorId"})])) - (fc/with-field :invoice/date - (com/validated-field - {:label "Date" - :errors (fc/field-errors)} - [:div {:class "w-24"} - (com/date-input {:value (some-> (fc/field-value) - (atime/unparse-local atime/normal-date)) - :name (fc/field-name) - :error? (fc/field-errors) - :x-model "date" - :placeholder "1/1/2024"})])) - (com/validated-field {} - [:div {:x-show "!customizeDueAndScheduled"} - (com/link {"@click" "customizeDueAndScheduled=true" - :x-show "!due && !scheduledPayment"} - "Add due / scheduled payment date") - (com/link {"@click" "customizeDueAndScheduled=true" - :x-show "due || scheduledPayment"} - "Change due / scheduled payment date")]) + [:div.flex.items-center.gap-2 + (fc/with-field :invoice/date + (com/validated-field + {:label "Date" + :errors (fc/field-errors)} + [:div {:class "w-24"} + (com/date-input {:value (some-> (fc/field-value) + (atime/unparse-local atime/normal-date)) + :name (fc/field-name) + :error? (fc/field-errors) + :x-model "date" + :placeholder "1/1/2024"})])) + [:div {:x-show "!customizeDueAndScheduled"} + (com/link {"@click" "customizeDueAndScheduled=true" + :x-show "!due && !scheduledPayment"} + "Add due / scheduled payment date") + (com/link {"@click" "customizeDueAndScheduled=true" + :x-show "due || scheduledPayment"} + "Change due / scheduled payment date")]] (fc/with-field :invoice/due (com/validated-field (hx/alpine-appear {:label "Due (optional)" @@ -221,9 +220,6 @@ :x-show "customizeDueAndScheduled"}) [:div {:class "w-24" :hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/due-date) - :x-hx-val:client-id "clientId" ;; TODO maybe just use the whole form - :x-hx-val:vendor-id "vendorId" - :x-hx-val:date "date" :x-dispatch:changed "[clientId, vendorId, date]" :hx-trigger "changed" :hx-target "this" @@ -392,7 +388,6 @@ (mut/select-keys (mm/form-schema linear-wizard) #{:invoice/expense-accounts})) (render-step [this {{:keys [snapshot] :as multi-form-state} :multi-form-state :as request}] - (alog/peek ::mfs (:step-params (:multi-form-state request))) (mm/default-render-step linear-wizard this :head [:div.p-2 "Invoice accounts "] @@ -551,7 +546,8 @@ :form-params (-> mm/default-form-props (assoc :hx-post - (str (bidi/path-for ssr-routes/only-routes ::route/new-invoice-submit)))))) + (str (bidi/path-for ssr-routes/only-routes ::route/new-invoice-submit)))) + :render-timeline? false)) (steps [_] [:basic-details :accounts