Allows for deleting of transaction rules

This commit is contained in:
2023-11-03 16:53:36 -07:00
parent 3f7f0a0aaf
commit 320d7c73df
6 changed files with 55 additions and 36 deletions

View File

@@ -133,13 +133,10 @@
"amount-gte" ['[?e :transaction-rule/amount-gte ?sort-amount-gte]]}
query-params)
(seq valid-clients)
(merge-query {:query {:in ['[?xx ...]]
:where ['(or-join [?e]
(and [?e :transaction-rule/client ?xx])
(and (not [?e :transaction-rule/client])
[?e :transaction-rule/note]))]}
:args [valid-clients]})
(= 1 (count valid-clients))
(merge-query {:query {:in '[?x]
:where '[[?e :transaction-rule/client ?x]]}
:args [(first valid-clients)]})
(-> query-params :vendor :db/id)
(merge-query {:query {:in ['?vendor-id]
@@ -195,7 +192,12 @@
:color :primary}
"New Transaction Rule")])
:row-buttons (fn [request entity]
[(com/icon-button {:hx-get (bidi/path-for ssr-routes/only-routes
[(com/icon-button {:hx-delete (bidi/path-for ssr-routes/only-routes
::route/delete
:db/id (:db/id entity))
:hx-confirm "Are you sure you want to delete?"}
svg/trash)
(com/icon-button {:hx-get (bidi/path-for ssr-routes/only-routes
::route/execute-dialog
:db/id (:db/id entity))}
svg/play)
@@ -787,8 +789,6 @@
(count ids)
(count all-results))})})))
(defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}]
(html-response (location-select* {:name name
:value value
@@ -868,6 +868,11 @@
(assoc "hx-retarget" ".modal-stack")
(assoc "hx-reswap" "beforeend"))))
(defn delete [{:keys [entity] :as request}]
@(dc/transact conn [[:db/retractEntity (:db/id entity)]])
(html-response (row* (:identity request) entity {:delete-after-settle? true :class "live-removed"})
:headers {"hx-retarget" (format "#entity-table tr[data-id=\"%d\"]" (:db/id entity))}))
(def key->handler
@@ -875,6 +880,9 @@
(->>
{::route/page (helper/page-route grid-page)
::route/table (helper/table-route grid-page)
::route/delete (-> delete
(wrap-entity [:route-params :db/id] default-read)
(wrap-schema-enforce :route-params [:map [:db/id entity-id]]))
::route/new-account (-> new-account
(wrap-schema-enforce :query-schema [:map
[:client-id {:optional true}
@@ -904,7 +912,6 @@
(wrap-entity [:form-params :db/id] default-read))))
::route/execute (-> execute
(wrap-entity [:route-params :db/id] default-read)
(wrap-entity [:route-params :db/id] default-read)
(wrap-schema-enforce :route-schema [:map [:db/id entity-id]])
(wrap-schema-enforce :form-schema