transaction dialog now uses sidebar.
This commit is contained in:
@@ -163,7 +163,7 @@
|
|||||||
:else
|
:else
|
||||||
[:div "No action possible."])]])
|
[:div "No action possible."])]])
|
||||||
|
|
||||||
(defn default-render-step [linear-wizard step & {:keys [head body footer validation-route discard-route width-height-class]}]
|
(defn default-render-step [linear-wizard step & {:keys [head body footer validation-route discard-route width-height-class side-panel]}]
|
||||||
(let [is-last? (= (step-key step) (last (steps linear-wizard)))]
|
(let [is-last? (= (step-key step) (last (steps linear-wizard)))]
|
||||||
(com/modal-card-advanced
|
(com/modal-card-advanced
|
||||||
{"@keydown.enter.prevent.stop" "if ($refs.next ) {$refs.next.click()}"
|
{"@keydown.enter.prevent.stop" "if ($refs.next ) {$refs.next.click()}"
|
||||||
@@ -201,6 +201,10 @@
|
|||||||
head)
|
head)
|
||||||
#_(com/modal-header-attachment {})
|
#_(com/modal-header-attachment {})
|
||||||
[:div.flex.shrink.overflow-auto.grow
|
[:div.flex.shrink.overflow-auto.grow
|
||||||
|
(when side-panel
|
||||||
|
[:div.grow-0.w-64.bg-gray-50.border-r.hidden.md:block.overflow-y-auto
|
||||||
|
{:class "max-h-full"}
|
||||||
|
side-panel])
|
||||||
(when (:render-timeline? linear-wizard)
|
(when (:render-timeline? linear-wizard)
|
||||||
[:div.grow-0.pr-6.pt-2.bg-gray-100.self-stretch.hidden.md:block #_{:style "margin-left:-20px"}
|
[: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)])
|
(render-timeline linear-wizard step validation-route)])
|
||||||
|
|||||||
@@ -484,135 +484,36 @@
|
|||||||
(format "$%,.2f" total))
|
(format "$%,.2f" total))
|
||||||
(com/data-grid-cell {})))])))
|
(com/data-grid-cell {})))])))
|
||||||
|
|
||||||
(defrecord BasicDetailsStep [linear-wizard]
|
(defn transaction-details-panel [tx]
|
||||||
mm/ModalWizardStep
|
[:div.p-4.space-y-4
|
||||||
(step-name [_]
|
[:h3.text-sm.font-semibold.text-gray-900.uppercase.tracking-wider "Details"]
|
||||||
"Transaction Details")
|
[:div.space-y-3
|
||||||
(step-key [_]
|
|
||||||
:basic-details)
|
|
||||||
|
|
||||||
(edit-path [_ _]
|
|
||||||
[])
|
|
||||||
|
|
||||||
(step-schema [_]
|
|
||||||
(mc/schema [:map
|
|
||||||
[:db/id {:optional true} [:maybe entity-id]]]))
|
|
||||||
|
|
||||||
(render-step
|
|
||||||
[this {:keys [multi-form-state] :as request}]
|
|
||||||
(let [tx-id (mm/get-mfs-field multi-form-state :db/id)
|
|
||||||
tx (d-transactions/get-by-id tx-id)]
|
|
||||||
(alog/info ::TRANSACTION :i multi-form-state)
|
|
||||||
(mm/default-render-step
|
|
||||||
linear-wizard this
|
|
||||||
:head [:div.p-2 "Edit transaction"]
|
|
||||||
:body (mm/default-step-body
|
|
||||||
{}
|
|
||||||
[:div {:x-data (hx/json {:clientId (or (fc/field-value (:transaction/client fc/*current*))
|
|
||||||
(:db/id (:client request)))})}
|
|
||||||
|
|
||||||
;; Read-only transaction details
|
|
||||||
[:div.mb-6.border.rounded-lg.p-4.bg-gray-50
|
|
||||||
[:h3.text-lg.font-semibold.mb-2 "Transaction Details"]
|
|
||||||
[:div.grid.grid-cols-2.gap-4
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Amount"]
|
[:div.text-xs.font-medium.text-gray-500 "Amount"]
|
||||||
[:div.text-base (format "$%,.2f" (Math/abs (:transaction/amount tx)))]]
|
[:div.text-sm.font-medium.text-gray-900 (format "$%,.2f" (Math/abs (:transaction/amount tx)))]]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Date"]
|
[:div.text-xs.font-medium.text-gray-500 "Date"]
|
||||||
[:div.text-base (some-> tx :transaction/date coerce/to-date-time (atime/unparse-local atime/normal-date))]]
|
[:div.text-sm.text-gray-900 (some-> tx :transaction/date coerce/to-date-time (atime/unparse-local atime/normal-date))]]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Bank Account"]
|
[:div.text-xs.font-medium.text-gray-500 "Bank Account"]
|
||||||
[:div.text-base (or (-> tx :transaction/bank-account :bank-account/name) "-")]]
|
[:div.text-sm.text-gray-900 (or (-> tx :transaction/bank-account :bank-account/name) "-")]]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Post Date"]
|
[:div.text-xs.font-medium.text-gray-500 "Post Date"]
|
||||||
[:div.text-base (some-> tx :transaction/post-date coerce/to-date-time (atime/unparse-local atime/normal-date))]]
|
[:div.text-sm.text-gray-900 (some-> tx :transaction/post-date coerce/to-date-time (atime/unparse-local atime/normal-date))]]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Original Description"]
|
[:div.text-xs.font-medium.text-gray-500 "Description"]
|
||||||
[:div.text-base (or (:transaction/description-original tx) "-")]]
|
[:div.text-sm.text-gray-900.truncate.cursor-help
|
||||||
|
{:title (or (:transaction/description-original tx) "No original description")}
|
||||||
|
(or (:transaction/description-simple tx) "-")]]
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Simplified Description"]
|
[:div.text-xs.font-medium.text-gray-500 "Check Number"]
|
||||||
[:div.text-base (or (:transaction/description-simple tx) "-")]]
|
[:div.text-sm.text-gray-900 (or (:transaction/check-number tx) "-")]]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Check Number"]
|
[:div.text-xs.font-medium.text-gray-500 "Status"]
|
||||||
[:div.text-base (or (:transaction/check-number tx) "-")]]
|
[:div.text-sm.text-gray-900 (or (some-> tx :transaction/status) "-")]]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Status"]
|
[:div.text-xs.font-medium.text-gray-500 "Transaction Type"]
|
||||||
[:div.text-base (or (some-> tx :transaction/status) "-")]]
|
[:div.text-sm.text-gray-900 (or (some-> tx :transaction/type) "-")]]]])
|
||||||
|
|
||||||
[:div
|
|
||||||
[:div.text-sm.font-medium.text-gray-500 "Transaction Type"]
|
|
||||||
[:div.text-base (or (some-> tx :transaction/type) "-")]]]]
|
|
||||||
|
|
||||||
;; Transaction Links Section
|
|
||||||
#_[:div.mb-6.border.rounded-lg.p-4.bg-gray-50
|
|
||||||
[:h3.text-lg.font-semibold.mb-2 "Transaction Links"]
|
|
||||||
(let [tx-id (mm/get-mfs-field multi-form-state :db/id)
|
|
||||||
db-history (dc/history (dc/db conn))
|
|
||||||
|
|
||||||
;; Get current and historical payments linked to this transaction
|
|
||||||
current-payment (when-let [payment-id (-> (dc/pull (dc/db conn)
|
|
||||||
'[:transaction/payment]
|
|
||||||
tx-id)
|
|
||||||
:transaction/payment
|
|
||||||
:db/id)]
|
|
||||||
{:entity-id payment-id :active true})
|
|
||||||
historical-payments (when tx-id
|
|
||||||
(->> (dc/q '[:find ?payment ?inst ?added
|
|
||||||
:in $ ?e
|
|
||||||
:where
|
|
||||||
[?e :transaction/payment ?payment ?tx ?added]
|
|
||||||
[?tx :db/txInstant ?inst]]
|
|
||||||
db-history tx-id)
|
|
||||||
(map (fn [[id date op]] {:entity-id id
|
|
||||||
:date date
|
|
||||||
:op op}))))
|
|
||||||
|
|
||||||
all-payments historical-payments]
|
|
||||||
|
|
||||||
[:div
|
|
||||||
;; Payments section
|
|
||||||
[:div.mb-3
|
|
||||||
[:h4.font-medium.text-gray-700 "Linked Payments:"]
|
|
||||||
(if (seq all-payments)
|
|
||||||
[:ul.list-disc.pl-6.mt-1
|
|
||||||
(for [{:keys [entity-id date op]} all-payments
|
|
||||||
:let [payment (dc/pull (dc/db conn)
|
|
||||||
'[:db/id :payment/invoice-number
|
|
||||||
[:payment/date :xform clj-time.coerce/from-date]
|
|
||||||
{:payment/vendor [:vendor/name]}]
|
|
||||||
entity-id)]]
|
|
||||||
[:li.text-sm.text-gray-600 {:class (when-not op "line-through")}
|
|
||||||
(if op [:span.text-green-600 "✓ "] "")
|
|
||||||
(str "Payment #" (:payment/invoice-number payment) " - "
|
|
||||||
(-> payment :payment/vendor :vendor/name))])]
|
|
||||||
[:p.text-sm.text-gray-500.italic "No payments linked to this transaction"])]])]]
|
|
||||||
|
|
||||||
;; Invoices section
|
|
||||||
|
|
||||||
;; Hidden ID field
|
|
||||||
(fc/with-field :db/id
|
|
||||||
(com/hidden {:name (fc/field-name)
|
|
||||||
:value (fc/field-value)}))
|
|
||||||
|
|
||||||
;; Editable fields section
|
|
||||||
;; Vendor field
|
|
||||||
)
|
|
||||||
:footer
|
|
||||||
(mm/default-step-footer linear-wizard this :validation-route ::route/edit-wizard-navigate)
|
|
||||||
:validation-route ::route/edit-wizard-navigate)))
|
|
||||||
|
|
||||||
mm/Initializable
|
|
||||||
(init-step-params
|
|
||||||
[_ current request]
|
|
||||||
(:step-params current)))
|
|
||||||
|
|
||||||
(defn get-available-payments [request]
|
(defn get-available-payments [request]
|
||||||
(let [tx-id (or (get-in request [:form-params :transaction-id])
|
(let [tx-id (or (get-in request [:form-params :transaction-id])
|
||||||
@@ -856,9 +757,13 @@
|
|||||||
(mm/form-schema linear-wizard))
|
(mm/form-schema linear-wizard))
|
||||||
|
|
||||||
(render-step [this {{:keys [snapshot] :as multi-form-state} :multi-form-state :as request}]
|
(render-step [this {{:keys [snapshot] :as multi-form-state} :multi-form-state :as request}]
|
||||||
|
(let [tx-id (mm/get-mfs-field multi-form-state :db/id)
|
||||||
|
tx (d-transactions/get-by-id tx-id)]
|
||||||
(mm/default-render-step
|
(mm/default-render-step
|
||||||
linear-wizard this
|
linear-wizard this
|
||||||
:head [:div.p-2 "Transaction Actions"]
|
:head [:div.p-2 "Edit Transaction"]
|
||||||
|
:width-height-class " md:w-[950px] md:h-[650px] "
|
||||||
|
:side-panel (transaction-details-panel tx)
|
||||||
:body (mm/default-step-body
|
:body (mm/default-step-body
|
||||||
{}
|
{}
|
||||||
[:div
|
[:div
|
||||||
@@ -956,7 +861,8 @@
|
|||||||
:class "rounded-l-lg"}
|
:class "rounded-l-lg"}
|
||||||
"Approved")
|
"Approved")
|
||||||
(com/button-group-button {"@click" "approvalStatus = 'unapproved'"
|
(com/button-group-button {"@click" "approvalStatus = 'unapproved'"
|
||||||
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'unapproved' }"}
|
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'unapproved' }"
|
||||||
|
:class "rounded-r-lg"}
|
||||||
"Unapproved")
|
"Unapproved")
|
||||||
(com/button-group-button {"@click" "approvalStatus = 'suppressed'"
|
(com/button-group-button {"@click" "approvalStatus = 'suppressed'"
|
||||||
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'suppressed' }"
|
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'suppressed' }"
|
||||||
@@ -970,7 +876,7 @@
|
|||||||
:footer
|
:footer
|
||||||
(mm/default-step-footer linear-wizard this :validation-route ::route/edit-wizard-navigate
|
(mm/default-step-footer linear-wizard this :validation-route ::route/edit-wizard-navigate
|
||||||
:next-button (com/button {:color :primary :x-ref "next" :class "w-32 wizard-save-action"} "Done"))
|
:next-button (com/button {:color :primary :x-ref "next" :class "w-32 wizard-save-action"} "Done"))
|
||||||
:validation-route ::route/edit-wizard-navigate)))
|
:validation-route ::route/edit-wizard-navigate))))
|
||||||
|
|
||||||
(defmulti save-handler (fn [request]
|
(defmulti save-handler (fn [request]
|
||||||
(-> request :multi-form-state :snapshot :action)))
|
(-> request :multi-form-state :snapshot :action)))
|
||||||
@@ -1369,7 +1275,7 @@
|
|||||||
(get-current-step [this]
|
(get-current-step [this]
|
||||||
(if current-step
|
(if current-step
|
||||||
(mm/get-step this current-step)
|
(mm/get-step this current-step)
|
||||||
(mm/get-step this :basic-details)))
|
(mm/get-step this :links)))
|
||||||
(render-wizard [this {:keys [multi-form-state] :as request}]
|
(render-wizard [this {:keys [multi-form-state] :as request}]
|
||||||
(mm/default-render-wizard
|
(mm/default-render-wizard
|
||||||
this request
|
this request
|
||||||
@@ -1379,13 +1285,11 @@
|
|||||||
(str (bidi/path-for ssr-routes/only-routes ::route/edit-submit))))
|
(str (bidi/path-for ssr-routes/only-routes ::route/edit-submit))))
|
||||||
:render-timeline? false))
|
:render-timeline? false))
|
||||||
(steps [_]
|
(steps [_]
|
||||||
[:basic-details
|
[:links])
|
||||||
:links])
|
|
||||||
(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]
|
||||||
(get {:basic-details (->BasicDetailsStep this)
|
(get {:links (->LinksStep this)}
|
||||||
:links (->LinksStep this)}
|
|
||||||
step-key)))
|
step-key)))
|
||||||
(form-schema [_]
|
(form-schema [_]
|
||||||
edit-form-schema)
|
edit-form-schema)
|
||||||
|
|||||||
Reference in New Issue
Block a user