Allows for deleting of transaction rules
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -46,7 +46,8 @@
|
||||
[malli.core :as mc]
|
||||
[malli.util :as mut]
|
||||
[slingshot.slingshot :refer [try+]]
|
||||
[malli.error :as me]))
|
||||
[malli.error :as me]
|
||||
[auto-ap.solr :as solr]))
|
||||
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
@@ -216,23 +217,12 @@
|
||||
updated-vendor (dc/pull (dc/db conn)
|
||||
default-read
|
||||
(or (get tempids (:db/id entity)) (:db/id entity)))]
|
||||
#_(solr/index-documents-raw solr/impl
|
||||
"accounts"
|
||||
(into [{"id" (:db/id updated-account)
|
||||
"account_id" (:db/id updated-account)
|
||||
"name" (:account/name updated-account)
|
||||
"numeric_code" (:account/numeric-code updated-account)
|
||||
"location" (:account/location updated-account)
|
||||
"applicability" (some-> updated-account :account/applicability clojure.core/name)}]
|
||||
(for [o (:account/client-overrides updated-account)]
|
||||
{"id" (:db/id o)
|
||||
"account_id" (:db/id updated-account)
|
||||
"name" (:account-client-override/name o)
|
||||
"numeric_code" (:account/numeric-code updated-account)
|
||||
"location" (:account/location updated-account)
|
||||
"applicability" (clojure.core/name (:account/applicability updated-account))
|
||||
"client_id" (:db/id (:account-client-override/client o))
|
||||
"account_client_override_id" (:db/id o)})))
|
||||
(solr/index-documents-raw
|
||||
solr/impl
|
||||
"vendors"
|
||||
[{"id" (:db/id updated-vendor)
|
||||
"name" (:vendor/name updated-vendor)
|
||||
"hidden" (boolean (:vendor/hidden updated-vendor))}])
|
||||
(html-response
|
||||
(row* identity updated-vendor {:flash? true})
|
||||
:headers (cond-> {"hx-trigger" "modalclose"}
|
||||
@@ -397,8 +387,6 @@
|
||||
(com/data-grid-cell {:class "align-top"}
|
||||
(com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"} svg/x)))))
|
||||
|
||||
;; TODO when a validation fails, only re render that page
|
||||
|
||||
(defn terms-modal [{:keys [form-errors entity form-params]}]
|
||||
(com/stacked-modal-card-2
|
||||
1
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
[cemerick.url :as url]
|
||||
[clojure.string :as str]
|
||||
[hiccup2.core :as hiccup]
|
||||
[malli.transform :as mt2]))
|
||||
[malli.transform :as mt2]
|
||||
[auto-ap.ssr.hiccup-helper :as hh]))
|
||||
|
||||
(defn row* [gridspec user entity {:keys [flash? delete-after-settle? request] :as options}]
|
||||
(defn row* [gridspec user entity {:keys [flash? delete-after-settle? request class] :as options}]
|
||||
(let [cells (->> gridspec
|
||||
:headers
|
||||
(filter (fn [h]
|
||||
@@ -35,8 +36,8 @@
|
||||
[:input {:type :hidden :name "id" :value ((:id-fn gridspec) entity)}]]
|
||||
((:row-buttons gridspec) request entity))))] ;; TODO double check usage of row buttons user and identity in callers
|
||||
(apply com/data-grid-row
|
||||
{:class (when flash?
|
||||
"live-added")
|
||||
{:class (cond-> (or class "")
|
||||
flash? (hh/add-class "live-added"))
|
||||
"_" (hiccup/raw (when delete-after-settle?
|
||||
" on htmx:afterSettle wait 400ms then remove me"))
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"/test" ::test
|
||||
"/new" {:get ::new-dialog}
|
||||
["/" [#"\d+" :db/id] "/edit"] ::edit-dialog
|
||||
["/" [#"\d+" :db/id] "/delete"] ::delete
|
||||
["/" [#"\d+" :db/id] "/run"] {:get ::execute-dialog
|
||||
:post ::execute}
|
||||
"/check-badges" ::check-badges
|
||||
|
||||
Reference in New Issue
Block a user