Makes appear logic work right
This commit is contained in:
@@ -423,84 +423,109 @@
|
||||
(when-let [id (:db/id entity)]
|
||||
(com/hidden {:name "db/id"
|
||||
:value id}))
|
||||
|
||||
(fc/with-field :transaction-rule/client
|
||||
|
||||
(com/validated-field
|
||||
{:label "Client"
|
||||
:errors (fc/field-errors)}
|
||||
[:div.w-96
|
||||
(com/typeahead-2 {:name (fc/field-name)
|
||||
:x-init "$el.focus()"
|
||||
:error? (fc/error?)
|
||||
:class "w-96"
|
||||
:placeholder "Search..."
|
||||
:url (bidi/path-for ssr-routes/only-routes :company-search)
|
||||
:id (str "form-client-search")
|
||||
:value (fc/field-value)
|
||||
:value-fn (some-fn :db/id identity)
|
||||
:content-fn (fn [c] (cond->> c
|
||||
(nat-int? c) (dc/pull (dc/db conn) '[:client/name])
|
||||
true :client/name))})]))
|
||||
|
||||
(fc/with-field :transaction-rule/bank-account
|
||||
(com/validated-field {:label "Bank Account"
|
||||
:errors (fc/field-errors)}
|
||||
[:div#bank-account-spot.w-96 {:hx-get (bidi/path-for ssr-routes/only-routes :bank-account-typeahead)
|
||||
:hx-trigger (hx/trigger-field-change :name "transaction-rule/client"
|
||||
:from "#edit-form")
|
||||
:hx-swap "innerHTML"
|
||||
:hx-ext "rename-params"
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hx/vals {:name (fc/field-name)})
|
||||
:hx-rename-params-ex (cheshire/generate-string {"transaction-rule/client" "client-id"
|
||||
"name" "name"})}
|
||||
(bank-account-typeahead* {:client-id ((some-fn :db/id identity) (:transaction-rule/client entity))
|
||||
:name (fc/field-name)
|
||||
:value (fc/field-value)})]))
|
||||
|
||||
(fc/with-field :transaction-rule/description
|
||||
(com/validated-field {:label "Description"
|
||||
:errors (fc/field-errors)}
|
||||
(com/text-input {:name (fc/field-name)
|
||||
:error? (fc/error?)
|
||||
:error? (fc/error?)
|
||||
:x-init "$el.focus()"
|
||||
:placeholder "HOME DEPOT"
|
||||
:class "w-96"
|
||||
:value (fc/field-value)})))
|
||||
[:div.filters {:x-data (hx/json {:clientFilter (boolean (fc/field-value (:transaction-rule/client fc/*current*)))
|
||||
:bankAccountFilter (boolean (fc/field-value (:transaction-rule/bank-account fc/*current*)))
|
||||
:amountFilter (boolean (or (fc/field-value (:transaction-rule/amount-gte fc/*current*))
|
||||
(fc/field-value (:transaction-rule/amount-lte fc/*current*))))
|
||||
:domFilter (boolean (or (fc/field-value (:transaction-rule/dom-gte fc/*current*))
|
||||
(fc/field-value (:transaction-rule/dom-lte fc/*current*))))})}
|
||||
|
||||
(com/field {:label "Amount"}
|
||||
[:div.flex.gap-2
|
||||
(fc/with-field :transaction-rule/amount-gte
|
||||
[:div.flex.flex-col
|
||||
(com/money-input {:name (fc/field-name)
|
||||
[:div.flex.gap-2.mb-2
|
||||
(com/a-button {"@click" "clientFilter=true"
|
||||
"x-show" "!clientFilter"} "Filter client")
|
||||
(com/a-button {"@click" "bankAccountFilter=true"
|
||||
"x-show" "clientFilter && !bankAccountFilter"} "Filter bank account")
|
||||
(com/a-button {"@click" "amountFilter=true"
|
||||
"x-show" "!amountFilter"} "Filter amount")
|
||||
(com/a-button {"@click" "domFilter=true"
|
||||
"x-show" "!domFilter"} "Filter day of month")]
|
||||
(fc/with-field :transaction-rule/client
|
||||
|
||||
(com/validated-field
|
||||
(-> {:label "Client"
|
||||
:errors (fc/field-errors)
|
||||
:x-show "clientFilter"}
|
||||
(hx/alpine-appear))
|
||||
[:div.w-96
|
||||
(com/typeahead-2 {:name (fc/field-name)
|
||||
:error? (fc/error?)
|
||||
:class "w-96"
|
||||
:placeholder "Search..."
|
||||
:url (bidi/path-for ssr-routes/only-routes :company-search)
|
||||
:id (str "form-client-search")
|
||||
:value (fc/field-value)
|
||||
:value-fn (some-fn :db/id identity)
|
||||
:content-fn (fn [c] (cond->> c
|
||||
(nat-int? c) (dc/pull (dc/db conn) '[:client/name])
|
||||
true :client/name))})]))
|
||||
|
||||
(fc/with-field :transaction-rule/bank-account
|
||||
(com/validated-field
|
||||
(-> {:label "Bank Account"
|
||||
:errors (fc/field-errors)
|
||||
:x-show "bankAccountFilter"}
|
||||
hx/alpine-appear)
|
||||
[:div#bank-account-spot.w-96 {:hx-get (bidi/path-for ssr-routes/only-routes :bank-account-typeahead)
|
||||
:hx-trigger (hx/trigger-field-change :name "transaction-rule/client"
|
||||
:from "#edit-form")
|
||||
:hx-swap "innerHTML"
|
||||
:hx-ext "rename-params"
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hx/vals {:name (fc/field-name)})
|
||||
:hx-rename-params-ex (cheshire/generate-string {"transaction-rule/client" "client-id"
|
||||
"name" "name"})}
|
||||
(bank-account-typeahead* {:client-id ((some-fn :db/id identity) (:transaction-rule/client entity))
|
||||
:name (fc/field-name)
|
||||
:value (fc/field-value)})]))
|
||||
|
||||
|
||||
|
||||
(com/field (-> {:label "Amount"
|
||||
:x-show "amountFilter"}
|
||||
hx/alpine-appear)
|
||||
[:div.flex.gap-2
|
||||
(fc/with-field :transaction-rule/amount-gte
|
||||
[:div.flex.flex-col
|
||||
(com/money-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})
|
||||
(com/errors {:errors (fc/field-errors)})])
|
||||
(fc/with-field :transaction-rule/amount-lte
|
||||
[:div.flex.flex-col
|
||||
(com/money-input {:name (fc/field-name)
|
||||
:placeholder "<="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})
|
||||
(com/errors {:errors (fc/field-errors)})])])
|
||||
|
||||
(com/field (-> {:label "Day of month"
|
||||
:x-show "domFilter"}
|
||||
hx/alpine-appear)
|
||||
[:div.flex.gap-2
|
||||
(fc/with-field :transaction-rule/dom-gte
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})
|
||||
(com/errors {:errors (fc/field-errors)})])
|
||||
(fc/with-field :transaction-rule/amount-lte
|
||||
[:div.flex.flex-col
|
||||
(com/money-input {:name (fc/field-name)
|
||||
:placeholder "<="
|
||||
:value (fc/field-value)})))
|
||||
(fc/with-field :transaction-rule/dom-lte
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})
|
||||
(com/errors {:errors (fc/field-errors)})])])
|
||||
|
||||
(com/field {:label "Day of month"}
|
||||
[:div.flex.gap-2
|
||||
(fc/with-field :transaction-rule/dom-gte
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})))
|
||||
(fc/with-field :transaction-rule/dom-lte
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})))])
|
||||
:value (fc/field-value)})))])]
|
||||
|
||||
[:h2.text-lg "Outcomes"]
|
||||
(fc/with-field :transaction-rule/vendor
|
||||
|
||||
Reference in New Issue
Block a user