progress on updating users
This commit is contained in:
@@ -59,19 +59,19 @@
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
:admin-transaction-rule-table)
|
||||
:admin-transaction-rule-table)
|
||||
"hx-target" "#transaction-rule-table"
|
||||
"hx-indicator" "#transaction-rule-table"}
|
||||
|
||||
[:fieldset.space-y-6
|
||||
[:fieldset.space-y-6
|
||||
(com/field {:label "Vendor"}
|
||||
(com/typeahead {:name "vendor"
|
||||
:placeholder "Search..."
|
||||
:url (bidi/path-for ssr-routes/only-routes
|
||||
:vendor-search)
|
||||
:id (str "vendor-search")
|
||||
:value [(:db/id (:vendor (:parsed-query-params request)))
|
||||
(:vendor/name (:vendor (:parsed-query-params request)))]}))
|
||||
(com/typeahead-2 {:name "vendor"
|
||||
:placeholder "Search..."
|
||||
:url (bidi/path-for ssr-routes/only-routes
|
||||
:vendor-search)
|
||||
:id (str "vendor-search")
|
||||
:value [(:db/id (:vendor (:parsed-query-params request)))
|
||||
(:vendor/name (:vendor (:parsed-query-params request)))]}))
|
||||
(com/field {:label "Note"}
|
||||
(com/text-input {:name "note"
|
||||
:id "note"
|
||||
@@ -193,7 +193,7 @@
|
||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
||||
:admin-transaction-rule-new-dialog))
|
||||
:hx-target "#modal-content"
|
||||
:hx-swap "innerHTML"
|
||||
:hx-swap "outerHTML"
|
||||
:color :primary}
|
||||
"New Transaction Rule")])
|
||||
:row-buttons (fn [request entity]
|
||||
@@ -201,7 +201,7 @@
|
||||
:admin-transaction-rule-edit-dialog
|
||||
:db/id (:db/id entity)))
|
||||
:hx-target "#modal-content"
|
||||
:hx-swap "innerHTML"}
|
||||
:hx-swap "outerHTML"}
|
||||
svg/pencil)])
|
||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:admin)}
|
||||
@@ -220,7 +220,8 @@
|
||||
{:key "bank-account"
|
||||
:name "Bank account"
|
||||
:sort-key "bank-account"
|
||||
:render #(-> % :transaction-rule/bank-account :bank-account/name)}
|
||||
:render #(-> % :transaction-rule/bank-account :bank-account/name)
|
||||
:show-starting "lg"}
|
||||
{:key "description"
|
||||
:name "Description"
|
||||
:sort-key "description"
|
||||
@@ -233,7 +234,8 @@
|
||||
(com/pill {:color :red} (format "more than $%.2f" amount-gte)))
|
||||
|
||||
(when amount-lte
|
||||
(com/pill {:color :primary} (format "less than $%.2f" amount-lte)))])}
|
||||
(com/pill {:color :primary} (format "less than $%.2f" amount-lte)))])
|
||||
:show-starting "md"}
|
||||
{:key "note"
|
||||
:name "Note"
|
||||
:sort-key "note"
|
||||
@@ -401,16 +403,17 @@
|
||||
(defn dialog* [& {:keys [entity form-params form-errors]}]
|
||||
(com/modal
|
||||
{:modal-class "max-w-2xl"}
|
||||
(com/modal-card
|
||||
{}
|
||||
[:div.flex [:div.p-2 "Transaction Rule"]]
|
||||
[:form#edit-form (merge {:hx-ext "response-targets"
|
||||
:hx-swap "outerHTML swap:300ms"
|
||||
:hx-target "#modal-holder"
|
||||
:hx-target-400 "#form-errors .error-content"
|
||||
:x-trap "true"
|
||||
:class "group/form"}
|
||||
form-params)
|
||||
|
||||
[:form#edit-form (merge {:hx-ext "response-targets"
|
||||
:hx-swap "outerHTML swap:300ms"
|
||||
:hx-target "#modal-holder"
|
||||
:hx-target-400 "#form-errors .error-content"
|
||||
:x-trap "true"
|
||||
:class "group/form"}
|
||||
form-params)
|
||||
(com/modal-card
|
||||
{}
|
||||
[:div.flex [:div.p-2 "Transaction Rule"]]
|
||||
[:fieldset {:class "hx-disable" :hx-disinherit "hx-target"
|
||||
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client entity))
|
||||
(:transaction-rule/client entity))})}
|
||||
@@ -448,43 +451,42 @@
|
||||
(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)
|
||||
:x-model "clientId"
|
||||
: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))})]))
|
||||
(-> {: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)
|
||||
:x-model "clientId"
|
||||
: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.w-96
|
||||
[:div#bank-account-changer {:hx-get (bidi/path-for ssr-routes/only-routes :bank-account-typeahead)
|
||||
:hx-trigger "changed"
|
||||
:hx-target "next *"
|
||||
:hx-include "#bank-account-changer"
|
||||
:hx-swap "innerHTML"
|
||||
(-> {:label "Bank Account"
|
||||
:errors (fc/field-errors)
|
||||
:x-show "bankAccountFilter"}
|
||||
hx/alpine-appear)
|
||||
[:div.w-96
|
||||
[:div#bank-account-changer {:hx-get (bidi/path-for ssr-routes/only-routes :bank-account-typeahead)
|
||||
:hx-trigger "changed"
|
||||
:hx-target "next *"
|
||||
:hx-include "#bank-account-changer"
|
||||
:hx-swap "innerHTML"
|
||||
|
||||
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId}" (fc/field-name))
|
||||
:x-init "$watch('clientId', cid => $dispatch('changed', $data))"}]
|
||||
|
||||
(bank-account-typeahead* {:client-id ((some-fn :db/id identity) (:transaction-rule/client entity))
|
||||
:name (fc/field-name)
|
||||
:value (fc/field-value)})]))
|
||||
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId}" (fc/field-name))
|
||||
:x-init "$watch('clientId', cid => $dispatch('changed', $data))"}]
|
||||
|
||||
(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"}
|
||||
@@ -511,18 +513,18 @@
|
||||
[: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)})))
|
||||
{: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)})))])]
|
||||
{: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
|
||||
@@ -549,24 +551,24 @@
|
||||
(doall (for [tra fc/*current*]
|
||||
(fc/with-cursor tra
|
||||
(transaction-rule-account-row* entity tra)))))
|
||||
(com/data-grid-row
|
||||
{:class "new-row"}
|
||||
(com/data-grid-cell {:colspan 4
|
||||
:class "bg-gray-100"}
|
||||
[:div.flex.justify-center
|
||||
(com/a-button {:hx-get (bidi/path-for ssr-routes/only-routes
|
||||
:admin-transaction-rule-new-account)
|
||||
:color :secondary
|
||||
:hx-include "#edit-form"
|
||||
:hx-ext "rename-params"
|
||||
:hx-rename-params-ex (cheshire/generate-string {"transaction-rule/client" "client-id"
|
||||
"index" "index"})
|
||||
:hx-vals (hiccup/raw "js:{index: countRows(\"#transaction-rule-account-table\")}")
|
||||
:hx-target "#edit-form .new-row"
|
||||
:hx-swap "beforebegin"}
|
||||
"New account")])))
|
||||
(com/data-grid-row
|
||||
{:class "new-row"}
|
||||
(com/data-grid-cell {:colspan 4
|
||||
:class "bg-gray-100"}
|
||||
[:div.flex.justify-center
|
||||
(com/a-button {:hx-get (bidi/path-for ssr-routes/only-routes
|
||||
:admin-transaction-rule-new-account)
|
||||
:color :secondary
|
||||
:hx-include "#edit-form"
|
||||
:hx-ext "rename-params"
|
||||
:hx-rename-params-ex (cheshire/generate-string {"transaction-rule/client" "client-id"
|
||||
"index" "index"})
|
||||
:hx-vals (hiccup/raw "js:{index: countRows(\"#transaction-rule-account-table\")}")
|
||||
:hx-target "#edit-form .new-row"
|
||||
:hx-swap "beforebegin"}
|
||||
"New account")])))
|
||||
(com/errors {:errors (fc/field-errors)})))
|
||||
|
||||
|
||||
(fc/with-field :transaction-rule/transaction-approval-status
|
||||
(com/validated-field {:label "Approval status"
|
||||
:errors (fc/field-errors)}
|
||||
@@ -578,12 +580,11 @@
|
||||
|
||||
[:div#form-errors (when (:errors fc/*form-errors*)
|
||||
[:span.error-content
|
||||
(com/errors {:errors (:errors fc/*form-errors*)})])]
|
||||
(com/button {:color :primary :form "edit-form" :type "submit" :class (cond-> "w-32"
|
||||
(seq form-errors) (->
|
||||
(hh/add-class "animate-shake")))}
|
||||
"Save")])]]
|
||||
[:div])))
|
||||
(com/errors {:errors (:errors fc/*form-errors*)})])]])]
|
||||
[:div (com/button {:color :primary :form "edit-form" :type "submit" :class (cond-> "w-32"
|
||||
(seq form-errors) (->
|
||||
(hh/add-class "animate-shake")))}
|
||||
"Save")])]))
|
||||
|
||||
|
||||
;; TODO Should forms have some kind of helper to render an individual field? saving
|
||||
|
||||
Reference in New Issue
Block a user