improvements
This commit is contained in:
@@ -181,7 +181,8 @@
|
||||
|
||||
(defn transaction-account-row* [{:keys [value client-id amount-mode total]}]
|
||||
(com/data-grid-row
|
||||
(-> {:x-data (hx/json {:show (boolean (not (fc/field-value (:new? value))))
|
||||
(-> {:class "account-row"
|
||||
:x-data (hx/json {:show (boolean (not (fc/field-value (:new? value))))
|
||||
:accountId (fc/field-value (:transaction-account/account value))})
|
||||
:data-key "show"
|
||||
:x-ref "p"}
|
||||
@@ -217,22 +218,23 @@
|
||||
'[:account/location])))
|
||||
:client-locations (pull-attr (dc/db conn) :client/locations client-id)
|
||||
:value (fc/field-value)}))))
|
||||
(fc/with-field :transaction-account/amount
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(if (= "%" amount-mode)
|
||||
(com/text-input {:name (fc/field-name)
|
||||
:class "w-16"
|
||||
:value (fc/field-value)
|
||||
:type "number"
|
||||
:step "0.01"})
|
||||
(com/money-input {:name (fc/field-name)
|
||||
:class "w-16"
|
||||
: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)"} svg/x))))
|
||||
(fc/with-field :transaction-account/amount
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(if (= "%" amount-mode)
|
||||
(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"
|
||||
: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]
|
||||
(str "step-params[transaction/accounts][" index "]["
|
||||
@@ -245,46 +247,48 @@
|
||||
|
||||
(defn transaction-account-row-no-cursor* [{:keys [account index client-id amount-mode total]}]
|
||||
(com/data-grid-row
|
||||
(-> {:x-data (hx/json {:show true
|
||||
(-> {:class "account-row"
|
||||
:x-data (hx/json {:show true
|
||||
:accountId (:transaction-account/account account)})
|
||||
:data-key "show"
|
||||
:x-ref "p"}
|
||||
hx/alpine-mount-then-appear)
|
||||
(com/hidden {:name (account-field-name index :db/id)
|
||||
:value (or (:db/id account) "")})
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
(com/hidden {:name (account-field-name index :db/id)
|
||||
:value (or (:db/id account) "")})
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(account-typeahead* {:value (:transaction-account/account account)
|
||||
:client-id client-id
|
||||
:name (account-field-name index :transaction-account/account)
|
||||
:x-model "accountId"})))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
(com/validated-field
|
||||
{}
|
||||
(account-typeahead* {:value (:transaction-account/account account)
|
||||
:client-id client-id
|
||||
:name (account-field-name index :transaction-account/account)
|
||||
:x-model "accountId"})))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(location-select* {:name (account-field-name index :transaction-account/location)
|
||||
:account-location (:account/location (cond->> (:transaction-account/account account)
|
||||
(nat-int? (:transaction-account/account account)) (dc/pull (dc/db conn)
|
||||
'[:account/location])))
|
||||
:client-locations (pull-attr (dc/db conn) :client/locations client-id)
|
||||
:value (:transaction-account/location account)})))
|
||||
(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)
|
||||
(nat-int? (:transaction-account/account account)) (dc/pull (dc/db conn)
|
||||
'[:account/location])))
|
||||
:client-locations (pull-attr (dc/db conn) :client/locations client-id)
|
||||
:value (:transaction-account/location account)})))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(if (= "%" amount-mode)
|
||||
(com/text-input {:name (account-field-name index :transaction-account/amount)
|
||||
:class "w-16"
|
||||
:value (:transaction-account/amount account)
|
||||
:type "number"
|
||||
:step "0.01"})
|
||||
(com/money-input {:name (account-field-name index :transaction-account/amount)
|
||||
:class "w-16"
|
||||
: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)"} svg/x))))
|
||||
(com/validated-field
|
||||
{}
|
||||
(if (= "%" amount-mode)
|
||||
(com/text-input {:name (account-field-name index :transaction-account/amount)
|
||||
:class "w-16 account-amount-field"
|
||||
: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"
|
||||
: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}]
|
||||
(html-response (location-select* {:name name
|
||||
@@ -385,36 +389,36 @@
|
||||
:index (count (:transaction/accounts snapshot))
|
||||
:tr-params {:hx-vals (hx/json {:client-id (:transaction/client snapshot)})}}
|
||||
"New account")
|
||||
(com/data-grid-row {}
|
||||
(com/data-grid-cell {})
|
||||
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TOTAL"])
|
||||
(com/data-grid-cell {:id "total"
|
||||
:class "text-right"
|
||||
:hx-trigger "change from:closest form target:.amount-field"
|
||||
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-total)
|
||||
:hx-target "this"
|
||||
:hx-swap "innerHTML"}
|
||||
(account-total* request))
|
||||
(com/data-grid-cell {}))
|
||||
(com/data-grid-row {:class "account-total-row"}
|
||||
(com/data-grid-cell {})
|
||||
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "TOTAL"])
|
||||
(com/data-grid-cell {:id "total"
|
||||
:class "text-right"
|
||||
:hx-trigger "change from:closest form target:.amount-field"
|
||||
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-total)
|
||||
:hx-target "this"
|
||||
:hx-swap "innerHTML"}
|
||||
(account-total* request))
|
||||
(com/data-grid-cell {}))
|
||||
|
||||
(com/data-grid-row {}
|
||||
(com/data-grid-cell {})
|
||||
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "BALANCE"])
|
||||
(com/data-grid-cell {:id "total"
|
||||
:class "text-right"
|
||||
:hx-trigger "change from:closest form target:.amount-field"
|
||||
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-balance)
|
||||
:hx-target "this"
|
||||
:hx-swap "innerHTML"}
|
||||
(account-balance* request))
|
||||
(com/data-grid-cell {}))
|
||||
(com/data-grid-row {:class "account-balance-row"}
|
||||
(com/data-grid-cell {})
|
||||
(com/data-grid-cell {:class "text-right"} [:span.font-bold.text-right "BALANCE"])
|
||||
(com/data-grid-cell {:id "total"
|
||||
:class "text-right"
|
||||
:hx-trigger "change from:closest form target:.amount-field"
|
||||
:hx-put (bidi.bidi/path-for ssr-routes/only-routes ::route/account-balance)
|
||||
:hx-target "this"
|
||||
:hx-swap "innerHTML"}
|
||||
(account-balance* request))
|
||||
(com/data-grid-cell {}))
|
||||
|
||||
(com/data-grid-row {}
|
||||
(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"}
|
||||
(format "$%,.2f" total))
|
||||
(com/data-grid-cell {})))))
|
||||
(com/data-grid-row {:class "account-grand-total-row"}
|
||||
(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"}
|
||||
(format "$%,.2f" total))
|
||||
(com/data-grid-cell {})))))
|
||||
|
||||
(defn toggle-amount-mode [request]
|
||||
(let [snapshot (-> request :multi-form-state :snapshot)
|
||||
@@ -952,7 +956,7 @@
|
||||
(account-grid-body* request)]))]]]])
|
||||
:footer
|
||||
(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"} "Done"))
|
||||
:next-button (com/button {:color :primary :x-ref "next" :class "w-32 wizard-save-action"} "Done"))
|
||||
:validation-route ::route/edit-wizard-navigate)))
|
||||
|
||||
(defmulti save-handler (fn [request]
|
||||
|
||||
Reference in New Issue
Block a user