horizontal

This commit is contained in:
2026-05-26 11:57:59 -07:00
parent ae0788e6dd
commit 85652a7ce7

View File

@@ -44,7 +44,7 @@
(def transaction-approval-status (def transaction-approval-status
{:transaction-approval-status/unapproved "Unapproved" {:transaction-approval-status/unapproved "Unapproved"
:transaction-approval-status/approved "Approved" :transaction-approval-status/approved "Approved"
:transaction-approval-status/suppressed "Suppressed"}) :transaction-approval-status/suppressed "Client Review"})
(def row* (partial helper/row* grid-page)) (def row* (partial helper/row* grid-page))
@@ -218,23 +218,23 @@
'[:account/location]))) '[:account/location])))
:client-locations (pull-attr (dc/db conn) :client/locations client-id) :client-locations (pull-attr (dc/db conn) :client/locations client-id)
:value (fc/field-value)})))) :value (fc/field-value)}))))
(fc/with-field :transaction-account/amount (fc/with-field :transaction-account/amount
(com/data-grid-cell (com/data-grid-cell
{} {}
(com/validated-field (com/validated-field
{:errors (fc/field-errors)} {:errors (fc/field-errors)}
(if (= "%" amount-mode) (if (= "%" amount-mode)
(com/text-input {:name (fc/field-name) (com/text-input {:name (fc/field-name)
:class "w-16 account-amount-field"
:value (fc/field-value)
:type "number"
:step "0.01"})
(com/money-input {:name (fc/field-name)
:class "w-16 account-amount-field" :class "w-16 account-amount-field"
:value (fc/field-value) :value (fc/field-value)})))))
:type "number" (com/data-grid-cell {:class "align-top"}
:step "0.01"}) (com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"
(com/money-input {:name (fc/field-name) :class "account-remove-action"} svg/x))))
:class "w-16 account-amount-field"
:value (fc/field-value)})))))
(com/data-grid-cell {:class "align-top"}
(com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"
:class "account-remove-action"} svg/x))))
(defn- account-field-name [index field] (defn- account-field-name [index field]
(str "step-params[transaction/accounts][" index "][" (str "step-params[transaction/accounts][" index "]["
@@ -253,42 +253,42 @@
:data-key "show" :data-key "show"
:x-ref "p"} :x-ref "p"}
hx/alpine-mount-then-appear) hx/alpine-mount-then-appear)
(com/hidden {:name (account-field-name index :db/id) (com/hidden {:name (account-field-name index :db/id)
:value (or (:db/id account) "")}) :value (or (:db/id account) "")})
(com/data-grid-cell (com/data-grid-cell
{}
(com/validated-field
{} {}
(com/validated-field (account-typeahead* {:value (:transaction-account/account account)
{} :client-id client-id
(account-typeahead* {:value (:transaction-account/account account) :name (account-field-name index :transaction-account/account)
:client-id client-id :x-model "accountId"})))
:name (account-field-name index :transaction-account/account) (com/data-grid-cell
:x-model "accountId"}))) {}
(com/data-grid-cell (com/validated-field
{} {}
(com/validated-field (location-select* {:name (account-field-name index :transaction-account/location)
{} :account-location (:account/location (cond->> (:transaction-account/account account)
(location-select* {:name (account-field-name index :transaction-account/location) (nat-int? (:transaction-account/account account)) (dc/pull (dc/db conn)
:account-location (:account/location (cond->> (:transaction-account/account account) '[:account/location])))
(nat-int? (:transaction-account/account account)) (dc/pull (dc/db conn) :client-locations (pull-attr (dc/db conn) :client/locations client-id)
'[:account/location]))) :value (:transaction-account/location account)})))
:client-locations (pull-attr (dc/db conn) :client/locations client-id) (com/data-grid-cell
:value (:transaction-account/location account)}))) {}
(com/data-grid-cell (com/validated-field
{} {}
(com/validated-field (if (= "%" amount-mode)
{} (com/text-input {:name (account-field-name index :transaction-account/amount)
(if (= "%" amount-mode) :class "w-16 account-amount-field"
(com/text-input {:name (account-field-name index :transaction-account/amount) :value (:transaction-account/amount account)
:type "number"
:step "0.01"})
(com/money-input {:name (account-field-name index :transaction-account/amount)
:class "w-16 account-amount-field" :class "w-16 account-amount-field"
:value (:transaction-account/amount account) :value (:transaction-account/amount account)}))))
:type "number" (com/data-grid-cell {:class "align-top"}
:step "0.01"}) (com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"
(com/money-input {:name (account-field-name index :transaction-account/amount) :class "account-remove-action"} svg/x))))
:class "w-16 account-amount-field"
:value (:transaction-account/amount account)}))))
(com/data-grid-cell {:class "align-top"}
(com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"
:class "account-remove-action"} svg/x))))
(defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}] (defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}]
(html-response (location-select* {:name name (html-response (location-select* {:name name
@@ -389,36 +389,36 @@
:index (count (:transaction/accounts snapshot)) :index (count (:transaction/accounts snapshot))
:tr-params {:hx-vals (hx/json {:client-id (:transaction/client snapshot)})}} :tr-params {:hx-vals (hx/json {:client-id (:transaction/client snapshot)})}}
"New account") "New account")
(com/data-grid-row {:class "account-total-row"} (com/data-grid-row {:class "account-total-row"}
(com/data-grid-cell {}) (com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TOTAL"]) (com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TOTAL"])
(com/data-grid-cell {:id "total" (com/data-grid-cell {:id "total"
:class "text-right" :class "text-right"
:hx-trigger "change from:closest form target:.amount-field" :hx-trigger "change from:closest form target:.amount-field"
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-total) :hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-total)
:hx-target "this" :hx-target "this"
:hx-swap "innerHTML"} :hx-swap "innerHTML"}
(account-total* request)) (account-total* request))
(com/data-grid-cell {})) (com/data-grid-cell {}))
(com/data-grid-row {:class "account-balance-row"} (com/data-grid-row {:class "account-balance-row"}
(com/data-grid-cell {}) (com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "BALANCE"]) (com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "BALANCE"])
(com/data-grid-cell {:id "total" (com/data-grid-cell {:id "total"
:class "text-right" :class "text-right"
:hx-trigger "change from:closest form target:.amount-field" :hx-trigger "change from:closest form target:.amount-field"
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-balance) :hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-balance)
:hx-target "this" :hx-target "this"
:hx-swap "innerHTML"} :hx-swap "innerHTML"}
(account-balance* request)) (account-balance* request))
(com/data-grid-cell {})) (com/data-grid-cell {}))
(com/data-grid-row {:class "account-grand-total-row"} (com/data-grid-row {:class "account-grand-total-row"}
(com/data-grid-cell {}) (com/data-grid-cell {})
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TRANSACTION TOTAL"]) (com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TRANSACTION TOTAL"])
(com/data-grid-cell {:class "text-right"} (com/data-grid-cell {:class "text-right"}
(format "$%,.2f" total)) (format "$%,.2f" total))
(com/data-grid-cell {}))))) (com/data-grid-cell {})))))
(defn toggle-amount-mode [request] (defn toggle-amount-mode [request]
(let [snapshot (-> request :multi-form-state :snapshot) (let [snapshot (-> request :multi-form-state :snapshot)
@@ -940,15 +940,28 @@
;; Memo field ;; Memo field
;; Approval status field ;; Approval status field
(fc/with-field :transaction/approval-status (fc/with-field :transaction/approval-status
(com/validated-field (com/validated-field
{:label "Status" {:label "Status"
:errors (fc/field-errors)} :errors (fc/field-errors)}
(com/radio-card {:options (mapv (fn [[k v]] {:value (name k) :content v}) (let [current-value (name (or (fc/field-value) :transaction-approval-status/unapproved))]
transaction-approval-status) [:div {:x-data (hx/json {:approvalStatus current-value})}
:value (name (or (fc/field-value) :transaction-approval-status/unapproved)) (com/hidden {:name (fc/field-name)
:name (fc/field-name)}))) :value current-value
":value" "approvalStatus"})
[:div {:class "inline-flex rounded-md shadow-sm", :role "group"}
(com/button-group-button {"@click" "approvalStatus = 'approved'"
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'approved' }"
:class "rounded-l-lg"}
"Approved")
(com/button-group-button {"@click" "approvalStatus = 'unapproved'"
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'unapproved' }"}
"Unapproved")
(com/button-group-button {"@click" "approvalStatus = 'suppressed'"
":class" "{ '!bg-primary-200 text-primary-800': approvalStatus === 'suppressed' }"
:class "rounded-r-lg"}
"Client Review")]])))
(fc/with-field :transaction/accounts (fc/with-field :transaction/accounts
(com/validated-field (com/validated-field
{:errors (fc/field-errors)} {:errors (fc/field-errors)}
@@ -956,7 +969,7 @@
(account-grid-body* request)]))]]]]) (account-grid-body* request)]))]]]])
: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]
@@ -1404,9 +1417,9 @@
(defn- render-account-grid-body [request] (defn- render-account-grid-body [request]
(fc/start-form (:multi-form-state request) nil (fc/start-form (:multi-form-state request) nil
(fc/with-field :step-params (fc/with-field :step-params
(fc/with-field :transaction/accounts (fc/with-field :transaction/accounts
(account-grid-body* request))))) (account-grid-body* request)))))
(defn edit-vendor-changed-handler [request] (defn edit-vendor-changed-handler [request]
(let [multi-form-state (:multi-form-state request) (let [multi-form-state (:multi-form-state request)
@@ -1420,7 +1433,7 @@
0.0)) 0.0))
amount-mode (or (:amount-mode snapshot) "$") amount-mode (or (:amount-mode snapshot) "$")
existing-accounts (or (seq (:transaction/accounts step-params)) existing-accounts (or (seq (:transaction/accounts step-params))
(seq (:transaction/accounts snapshot))) (seq (:transaction/accounts snapshot)))
default-account (when (and (empty? existing-accounts) vendor-id client-id) default-account (when (and (empty? existing-accounts) vendor-id client-id)
(vendor-default-account vendor-id client-id)) (vendor-default-account vendor-id client-id))
render-request render-request