This commit is contained in:
2023-10-27 15:08:06 -07:00
parent 1e64afce8d
commit a4678c8fde
6 changed files with 111 additions and 55 deletions

View File

@@ -371,7 +371,9 @@
(map first))]
(html-response
(com/modal-card {:class "fade-in transition duration-300"}
(com/stacked-modal-card
1
{}
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"] [:div.ml-4.relative (com/badge {} (count results))]]
(com/data-grid
{:headers [(com/data-grid-header {} "Client")
@@ -385,21 +387,23 @@
(com/data-grid-cell {} (-> r :transaction/bank-account :bank-account/name))
(com/data-grid-cell {} (some-> r :transaction/date (atime/unparse-local atime/normal-date)))
(com/data-grid-cell {} (some-> r :transaction/description-original )))))
[:div
[:div.flex.justify-between
(com/button {"@click" "$dispatch('modalpop')"
:class "w-32"}
"Back")
(com/button (cond-> {:color :primary
:hx-vals (hx/json (:raw-form-params request))
:class "w-32"
}
(:db/id form-params) (assoc :hx-put (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save))
(:db/id form-params) (assoc :hx-put (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save))
(not (:db/id form-params)) (assoc :hx-post (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save)))
"Save")
(com/button {:hx-vals (hx/json (:raw-form-params request))
:hx-put (bidi/path-for ssr-routes/only-routes
:admin-transaction-rule-filled-account
)} "Back")
"Save rule")
])
:headers (-> {}
(assoc "hx-retarget" ".modal-card")
(assoc "hx-reswap" "outerHTML")))))
(assoc "hx-trigger-after-settle" "modalnext")
(assoc "hx-retarget" ".modal-stack")
(assoc "hx-reswap" "beforeend")))))
@@ -500,20 +504,20 @@
{:modal-class "max-w-2xl"
:hx-target "this"}
[:form {:hx-ext "response-targets"
:hx-target-400 "#form-errors .error-content"
:x-trap "true"
:class "w-full h-full"
(if (:db/id entity)
:hx-put
:hx-post) (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-edit-save))}
(com/modal-card
{}
[:div.flex [:div.p-2 "Transaction Rule"]]
[:fieldset {:class "hx-disable"
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client form-params))
(:transaction-rule/client form-params)
(:db/id (:transaction-rule/client entity)))})}
(com/stacked-modal-card
0
{}
[:div.flex [:div.p-2 "Transaction Rule"]]
[:form#my-form {:hx-ext "response-targets"
:hx-target-400 "#form-errors .error-content"
:x-trap "true"
(if (:db/id entity)
:hx-put
:hx-post) (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-edit-save))}
[:fieldset {:class "hx-disable"
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client form-params))
(:transaction-rule/client form-params)
(:db/id (:transaction-rule/client entity)))})}
[:div.space-y-1
(when-let [id (:db/id entity)]
@@ -553,13 +557,13 @@
(hx/alpine-appear))
[: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)
:x-model "clientId"
:value (fc/field-value)
:content-fn (fn [c] (pull-attr (dc/db conn) :client/name c))})]))
: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)
:content-fn (fn [c] (pull-attr (dc/db conn) :client/name c))})]))
(fc/with-field :transaction-rule/bank-account
(com/validated-field
@@ -625,11 +629,11 @@
:errors (fc/field-errors)}
[:div.w-96
(com/typeahead {:name (fc/field-name)
:placeholder "Search..."
:url (bidi/path-for ssr-routes/only-routes :vendor-search)
:class "w-96"
:value (fc/field-value)
:content-fn #(pull-attr (dc/db conn) :vendor/name %)})]))
:placeholder "Search..."
:url (bidi/path-for ssr-routes/only-routes :vendor-search)
:class "w-96"
:value (fc/field-value)
:content-fn #(pull-attr (dc/db conn) :vendor/name %)})]))
(fc/with-field :transaction-rule/accounts
(com/validated-field
@@ -656,14 +660,18 @@
:size :small
:orientation :horizontal})))
]]
[:div
(com/form-errors {:errors (:errors fc/*form-errors*)})
(com/validated-save-button {:errors form-errors} "Save rule")
(com/validated-save-button {:errors form-errors :color :secondary
:hx-post (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-test)}
]]]
[:div
(com/form-errors {:errors (:errors fc/*form-errors*)})
[:div.flex.justify-end
(com/validated-save-button {:errors form-errors :color :secondary
:hx-post (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-test)
:hx-include "#my-form"}
"Test rule")])])))
"Test rule")
(com/validated-save-button {:errors form-errors
:form "my-form"} "Save rule")]]))))
(defn new-account [{{:keys [client-id index]} :query-params}]
@@ -716,7 +724,6 @@
[:transaction-rule-account/percentage percentage])]]))
(defn transaction-dialog [{:keys [entity form-params form-errors]}]
(clojure.pprint/pprint form-params)
(modal-response (dialog* {:entity entity
:form-params (or (when (seq form-params)
form-params)