Lots of less customization when creating and editing forms
This commit is contained in:
@@ -341,8 +341,6 @@
|
||||
(nat-int? value) (dc/pull (dc/db conn) d-accounts/default-read))
|
||||
client-id)))})])
|
||||
|
||||
|
||||
|
||||
(defn- transaction-rule-account-row*
|
||||
[transaction-rule account]
|
||||
(com/data-grid-row {}
|
||||
@@ -352,56 +350,58 @@
|
||||
(com/hidden {:name (fc/field-name)
|
||||
:value (fc/field-value)}))
|
||||
(fc/with-field :transaction-rule-account/account
|
||||
(com/data-grid-cell {}
|
||||
[:div {:hx-trigger (hx/trigger-field-change :name "transaction-rule/client"
|
||||
:from "#edit-form")
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hx/vals {:name account-name})
|
||||
:hx-ext "rename-params"
|
||||
:hx-rename-params-ex (hx/json {:transaction-rule/client "client-id"
|
||||
:name "name"
|
||||
account-name "value"})
|
||||
:hx-get (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-account-typeahead))
|
||||
:hx-swap "innerHTML"}
|
||||
(account-typeahead* {:value (fc/field-value)
|
||||
:client-id (:db/id (:transaction-rule/client transaction-rule))
|
||||
:name (fc/field-name)})
|
||||
(println "HERE" (cursor/path fc/*current*))
|
||||
(println "DATA "fc/*form-data*)
|
||||
(println "ERR" fc/*form-errors*)
|
||||
(println (fc/field-errors))
|
||||
(com/errors {:errors (fc/field-errors)})]))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
[:div {:hx-trigger (hx/trigger-field-change :name "transaction-rule/client"
|
||||
:from "#edit-form")
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hx/vals {:name account-name})
|
||||
:hx-ext "rename-params"
|
||||
:hx-rename-params-ex (hx/json {:transaction-rule/client "client-id"
|
||||
:name "name"
|
||||
account-name "value"})
|
||||
:hx-get (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-account-typeahead))
|
||||
:hx-swap "innerHTML"}
|
||||
(account-typeahead* {:value (fc/field-value)
|
||||
:client-id (:db/id (:transaction-rule/client transaction-rule))
|
||||
:name (fc/field-name)})])))
|
||||
(fc/with-field :transaction-rule-account/location
|
||||
(com/data-grid-cell {}
|
||||
[:div [:div {:hx-trigger (hx/triggers
|
||||
(hx/trigger-field-change :name "transaction-rule/client"
|
||||
:from "#edit-form")
|
||||
(hx/trigger-field-change :name account-name
|
||||
:from "#edit-form"))
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hx/vals {:name (fc/field-name)})
|
||||
:hx-ext "rename-params"
|
||||
:hx-rename-params-ex (hx/json {"transaction-rule/client" "client-id"
|
||||
account-name "account-id"
|
||||
"name" "name"
|
||||
(fc/field-name) "value"})
|
||||
:hx-get (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-location-select)
|
||||
:hx-swap "innerHTML"}
|
||||
(location-select* {:name (fc/field-name)
|
||||
:account-location (:account/location (cond->> (:transaction-rule-account/account @account)
|
||||
(nat-int? (:transaction-rule-account/account @account)) (dc/pull (dc/db conn)
|
||||
'[:account/location])))
|
||||
:client-locations (:client/locations (:transaction-rule/client transaction-rule))
|
||||
:value (fc/field-value)})]
|
||||
(com/errors {:errors (fc/field-errors)})]
|
||||
))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
[:div [:div {:hx-trigger (hx/triggers
|
||||
(hx/trigger-field-change :name "transaction-rule/client"
|
||||
:from "#edit-form")
|
||||
(hx/trigger-field-change :name account-name
|
||||
:from "#edit-form"))
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hx/vals {:name (fc/field-name)})
|
||||
:hx-ext "rename-params"
|
||||
:hx-rename-params-ex (hx/json {"transaction-rule/client" "client-id"
|
||||
account-name "account-id"
|
||||
"name" "name"
|
||||
(fc/field-name) "value"})
|
||||
:hx-get (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-location-select)
|
||||
:hx-swap "innerHTML"}
|
||||
(location-select* {:name (fc/field-name)
|
||||
:account-location (:account/location (cond->> (:transaction-rule-account/account @account)
|
||||
(nat-int? (:transaction-rule-account/account @account)) (dc/pull (dc/db conn)
|
||||
'[:account/location])))
|
||||
:client-locations (:client/locations (:transaction-rule/client transaction-rule))
|
||||
:value (fc/field-value)})]])))
|
||||
(fc/with-field :transaction-rule-account/percentage
|
||||
(com/data-grid-cell (com/money-input {:name (fc/field-name)
|
||||
:class "w-16"
|
||||
:value (some-> (fc/field-value)
|
||||
(* 100 )
|
||||
(long ))})
|
||||
(com/errors {:errors (fc/field-errors)})))))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/money-input {:name (fc/field-name)
|
||||
:class "w-16"
|
||||
:value (some-> (fc/field-value)
|
||||
(* 100 )
|
||||
(long ))}))))))
|
||||
(com/data-grid-cell
|
||||
(com/a-icon-button
|
||||
{"_" (hiccup/raw "on click halt the event then transition the closest <tr />'s opacity to 0 then remove closest <tr />")
|
||||
@@ -434,6 +434,7 @@
|
||||
:errors (fc/field-errors)}
|
||||
[:div.w-96
|
||||
(com/typeahead {:name (fc/field-name)
|
||||
:error? (fc/error?)
|
||||
:class "w-96"
|
||||
:placeholder "Search..."
|
||||
:url (bidi/path-for ssr-routes/only-routes :company-search)
|
||||
@@ -465,6 +466,7 @@
|
||||
(com/validated-field {:label "Description"
|
||||
:errors (fc/field-errors)}
|
||||
(com/text-input {:name (fc/field-name)
|
||||
:error? (fc/error?)
|
||||
:placeholder "HOME DEPOT"
|
||||
:class "w-96"
|
||||
:value (fc/field-value)})))
|
||||
@@ -489,19 +491,19 @@
|
||||
(com/field {:label "Day of month"}
|
||||
[:div.flex.gap-2
|
||||
(fc/with-field :transaction-rule/dom-gte
|
||||
[:div.flex.flex-col
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})
|
||||
(com/errors {:errors (fc/field-errors)})])
|
||||
(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
|
||||
[:div.flex.flex-col
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})
|
||||
(com/errors {:errors (fc/field-errors)})])])
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/int-input {:name (fc/field-name)
|
||||
:placeholder ">="
|
||||
:class "w-24"
|
||||
:value (fc/field-value)})))])
|
||||
|
||||
[:h2.text-lg "Outcomes"]
|
||||
(fc/with-field :transaction-rule/vendor
|
||||
@@ -625,7 +627,7 @@
|
||||
(def transaction-rule-schema (mc/schema
|
||||
[:map
|
||||
[:db/id {:optional true} [:maybe entity-id]]
|
||||
[:transaction-rule/client entity-id]
|
||||
[:transaction-rule/client {:optional true} [:maybe entity-id]]
|
||||
[:transaction-rule/description [:and regex
|
||||
[:string {:min 3}]]]
|
||||
[:transaction-rule/bank-account [:maybe entity-id]]
|
||||
@@ -639,7 +641,7 @@
|
||||
(many-entity {:min 1}
|
||||
[:db/id [:or entity-id temp-id]]
|
||||
[:transaction-rule-account/account entity-id]
|
||||
[:transaction-rule-account/location :string]
|
||||
[:transaction-rule-account/location [:string {:min 1 :error/message "required"}]]
|
||||
[:transaction-rule-account/percentage percentage])]]))
|
||||
|
||||
(def key->handler
|
||||
|
||||
Reference in New Issue
Block a user