tweaks
This commit is contained in:
@@ -17,15 +17,16 @@
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils :refer [apply-middleware-to-all-handlers check-allowance
|
||||
check-location-belongs clj-date-schema entity-id
|
||||
html-response modal-response money
|
||||
wrap-form-4xx-2 wrap-schema-enforce]]
|
||||
html-response main-transformer modal-response
|
||||
money wrap-form-4xx-2 wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[iol-ion.query :refer [dollars=]]
|
||||
[iol-ion.utils :refer [remove-nils]])
|
||||
[iol-ion.utils :refer [remove-nils]]
|
||||
[malli.core :as m])
|
||||
(:import
|
||||
[java.util UUID]))
|
||||
|
||||
@@ -33,20 +34,20 @@
|
||||
[:and
|
||||
[:map
|
||||
[:db/id {:optional true} [:maybe entity-id]]
|
||||
[:journal-entry/client [:entity-map {:pull [:db/id :client/name :client/locations]}]]
|
||||
[:journal-entry/client {:optional false} [:entity-map {:pull [:db/id :client/name :client/locations] }]]
|
||||
[:journal-entry/date clj-date-schema]
|
||||
[:journal-entry/vendor {:optional true :default nil}
|
||||
[:entity-map {:pull [:db/id :vendor/name]}]]
|
||||
[:journal-entry/vendor {:optional false :default nil}
|
||||
[:entity-map {:pull [:db/id :vendor/name] }]]
|
||||
[:journal-entry/amount {:min 0.01}
|
||||
money]
|
||||
[:journal-entry/line-items
|
||||
[:vector {:coerce? true}
|
||||
[:and
|
||||
[:map
|
||||
[:journal-entry-line/account [:and [:entity-map {:pull a/default-read}]
|
||||
[:journal-entry-line/account [:and [:entity-map {:pull a/default-read }]
|
||||
[:fn {:error/message "Not an allowed account."}
|
||||
(fn check-allow [x]
|
||||
(check-allowance x :account/default-allowance))]]]
|
||||
(check-allowance (:db/id x) :account/default-allowance))]]]
|
||||
[:journal-entry-line/debit {:optional true :default nil} [:maybe money]]
|
||||
[:journal-entry-line/credit {:optional true :default nil} [:maybe money]]
|
||||
[:journal-entry-line/location :string]]
|
||||
@@ -69,7 +70,6 @@
|
||||
(map :journal-entry-line/credit)
|
||||
(filter identity)
|
||||
(reduce + 0.0)))))]])
|
||||
|
||||
(defn- account-typeahead*
|
||||
[{:keys [name value client-id x-model]}]
|
||||
[:div.flex.flex-col
|
||||
@@ -92,7 +92,7 @@
|
||||
(com/select {:options (into [["" ""]]
|
||||
(cond account-location
|
||||
[[account-location account-location]]
|
||||
|
||||
|
||||
:else
|
||||
(for [c (seq client-locations)]
|
||||
[c c])))
|
||||
@@ -109,7 +109,7 @@
|
||||
(pull-attr (dc/db conn) :client/locations))})))
|
||||
|
||||
(defn- line-item-row*
|
||||
[account client-id client-locations]
|
||||
[account client client-locations]
|
||||
(com/data-grid-row
|
||||
(-> {:x-data (hx/json {:accountId (or (:db/id (fc/field-value (:journal-entry-line/account account)))
|
||||
(fc/field-value (:journal-entry-line/account account)))
|
||||
@@ -134,7 +134,7 @@
|
||||
:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/account-typeahead))
|
||||
:x-init "$watch('clientId', cid => $dispatch('changed', $data));"}]
|
||||
(account-typeahead* {:value (fc/field-value)
|
||||
:client-id client-id
|
||||
:client-id (:db/id client)
|
||||
:name (fc/field-name)
|
||||
:x-model "accountId"}))))
|
||||
(fc/with-field :journal-entry-line/location
|
||||
@@ -149,9 +149,10 @@
|
||||
:hx-swap "outerHTML"
|
||||
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId || '', 'account-id': event.detail.accountId || '', value: event.detail.location || ''}" (fc/field-name))
|
||||
:hx-get (bidi/path-for ssr-routes/only-routes ::route/location-select)
|
||||
:x-init "$watch('clientId', cid => $dispatch('changed', $data)); $watch('accountId', cid => $dispatch('changed', $data) )"}]
|
||||
:x-dispatch:changed "[clientId, accountId]"
|
||||
#_#_:x-init "$watch('clientId', cid => $dispatch('changed', $data)); $watch('accountId', cid => $dispatch('changed', $data) )"}]
|
||||
(location-select* {:name (fc/field-name)
|
||||
:account-location (:account/location (:account/location (:journal-entry-line/account @account)))
|
||||
:account-location (:account/location (:journal-entry-line/account @account))
|
||||
:client-locations client-locations
|
||||
:x-model "location"
|
||||
:value (fc/field-value)}))))
|
||||
@@ -176,8 +177,8 @@
|
||||
|
||||
(defn account-typeahead [{{:keys [name value client-id] :as qp} :query-params}]
|
||||
(html-response (account-typeahead* {:name name
|
||||
:value value
|
||||
:client-id client-id
|
||||
:value (dc/pull (dc/db conn) a/default-read value)
|
||||
:client-id client-id
|
||||
:x-model "accountId"})))
|
||||
|
||||
(defn form* [request]
|
||||
@@ -260,7 +261,6 @@
|
||||
|
||||
|
||||
(defn new [request]
|
||||
(alog/peek ::FP (:form-params request))
|
||||
(modal-response
|
||||
(com/modal {:hx-target "this"
|
||||
:hx-indicator "this"}
|
||||
|
||||
Reference in New Issue
Block a user