Allows for deleting of transaction rules
This commit is contained in:
@@ -81,6 +81,18 @@
|
|||||||
animation-direction: alternate;
|
animation-direction: alternate;
|
||||||
animation-timing-function: ease-in-out;
|
animation-timing-function: ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.live-removed {
|
||||||
|
animation: pulse-red 300ms 2;
|
||||||
|
animation-direction: alternate;
|
||||||
|
animation-timing-function: ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dark .live-removed {
|
||||||
|
animation: pulse-dark-red 300ms 2 !important;
|
||||||
|
animation-direction: alternate;
|
||||||
|
animation-timing-function: ease-in-out;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
.live-added {
|
.live-added {
|
||||||
@apply bg-white;
|
@apply bg-white;
|
||||||
@@ -97,6 +109,16 @@
|
|||||||
100% { @apply bg-green-700;}
|
100% { @apply bg-green-700;}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes pulse-red {
|
||||||
|
0% { @apply bg-white; }
|
||||||
|
100% { @apply bg-red-300 dark:bg-red-700;}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse-dark-red {
|
||||||
|
0% { @apply dark:bg-red-700; }
|
||||||
|
100% { @apply bg-red-700;}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
|
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator {
|
||||||
display: inherit !important;
|
display: inherit !important;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -133,13 +133,10 @@
|
|||||||
"amount-gte" ['[?e :transaction-rule/amount-gte ?sort-amount-gte]]}
|
"amount-gte" ['[?e :transaction-rule/amount-gte ?sort-amount-gte]]}
|
||||||
query-params)
|
query-params)
|
||||||
|
|
||||||
(seq valid-clients)
|
(= 1 (count valid-clients))
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in '[?x]
|
||||||
:where ['(or-join [?e]
|
:where '[[?e :transaction-rule/client ?x]]}
|
||||||
(and [?e :transaction-rule/client ?xx])
|
:args [(first valid-clients)]})
|
||||||
(and (not [?e :transaction-rule/client])
|
|
||||||
[?e :transaction-rule/note]))]}
|
|
||||||
:args [valid-clients]})
|
|
||||||
|
|
||||||
(-> query-params :vendor :db/id)
|
(-> query-params :vendor :db/id)
|
||||||
(merge-query {:query {:in ['?vendor-id]
|
(merge-query {:query {:in ['?vendor-id]
|
||||||
@@ -195,7 +192,12 @@
|
|||||||
:color :primary}
|
:color :primary}
|
||||||
"New Transaction Rule")])
|
"New Transaction Rule")])
|
||||||
:row-buttons (fn [request entity]
|
: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
|
::route/execute-dialog
|
||||||
:db/id (:db/id entity))}
|
:db/id (:db/id entity))}
|
||||||
svg/play)
|
svg/play)
|
||||||
@@ -787,8 +789,6 @@
|
|||||||
(count ids)
|
(count ids)
|
||||||
(count all-results))})})))
|
(count all-results))})})))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}]
|
(defn location-select [{{:keys [name account-id client-id value] :as qp} :query-params}]
|
||||||
(html-response (location-select* {:name name
|
(html-response (location-select* {:name name
|
||||||
:value value
|
:value value
|
||||||
@@ -868,6 +868,11 @@
|
|||||||
(assoc "hx-retarget" ".modal-stack")
|
(assoc "hx-retarget" ".modal-stack")
|
||||||
(assoc "hx-reswap" "beforeend"))))
|
(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
|
(def key->handler
|
||||||
@@ -875,6 +880,9 @@
|
|||||||
(->>
|
(->>
|
||||||
{::route/page (helper/page-route grid-page)
|
{::route/page (helper/page-route grid-page)
|
||||||
::route/table (helper/table-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
|
::route/new-account (-> new-account
|
||||||
(wrap-schema-enforce :query-schema [:map
|
(wrap-schema-enforce :query-schema [:map
|
||||||
[:client-id {:optional true}
|
[:client-id {:optional true}
|
||||||
@@ -904,7 +912,6 @@
|
|||||||
(wrap-entity [:form-params :db/id] default-read))))
|
(wrap-entity [:form-params :db/id] default-read))))
|
||||||
|
|
||||||
::route/execute (-> execute
|
::route/execute (-> execute
|
||||||
(wrap-entity [:route-params :db/id] default-read)
|
|
||||||
(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 :route-schema [:map [:db/id entity-id]])
|
||||||
(wrap-schema-enforce :form-schema
|
(wrap-schema-enforce :form-schema
|
||||||
|
|||||||
@@ -46,7 +46,8 @@
|
|||||||
[malli.core :as mc]
|
[malli.core :as mc]
|
||||||
[malli.util :as mut]
|
[malli.util :as mut]
|
||||||
[slingshot.slingshot :refer [try+]]
|
[slingshot.slingshot :refer [try+]]
|
||||||
[malli.error :as me]))
|
[malli.error :as me]
|
||||||
|
[auto-ap.solr :as solr]))
|
||||||
|
|
||||||
(defn filters [request]
|
(defn filters [request]
|
||||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||||
@@ -216,23 +217,12 @@
|
|||||||
updated-vendor (dc/pull (dc/db conn)
|
updated-vendor (dc/pull (dc/db conn)
|
||||||
default-read
|
default-read
|
||||||
(or (get tempids (:db/id entity)) (:db/id entity)))]
|
(or (get tempids (:db/id entity)) (:db/id entity)))]
|
||||||
#_(solr/index-documents-raw solr/impl
|
(solr/index-documents-raw
|
||||||
"accounts"
|
solr/impl
|
||||||
(into [{"id" (:db/id updated-account)
|
"vendors"
|
||||||
"account_id" (:db/id updated-account)
|
[{"id" (:db/id updated-vendor)
|
||||||
"name" (:account/name updated-account)
|
"name" (:vendor/name updated-vendor)
|
||||||
"numeric_code" (:account/numeric-code updated-account)
|
"hidden" (boolean (:vendor/hidden updated-vendor))}])
|
||||||
"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)})))
|
|
||||||
(html-response
|
(html-response
|
||||||
(row* identity updated-vendor {:flash? true})
|
(row* identity updated-vendor {:flash? true})
|
||||||
:headers (cond-> {"hx-trigger" "modalclose"}
|
:headers (cond-> {"hx-trigger" "modalclose"}
|
||||||
@@ -397,8 +387,6 @@
|
|||||||
(com/data-grid-cell {:class "align-top"}
|
(com/data-grid-cell {:class "align-top"}
|
||||||
(com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"} svg/x)))))
|
(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]}]
|
(defn terms-modal [{:keys [form-errors entity form-params]}]
|
||||||
(com/stacked-modal-card-2
|
(com/stacked-modal-card-2
|
||||||
1
|
1
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
[cemerick.url :as url]
|
[cemerick.url :as url]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[hiccup2.core :as hiccup]
|
[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
|
(let [cells (->> gridspec
|
||||||
:headers
|
:headers
|
||||||
(filter (fn [h]
|
(filter (fn [h]
|
||||||
@@ -35,8 +36,8 @@
|
|||||||
[:input {:type :hidden :name "id" :value ((:id-fn gridspec) entity)}]]
|
[: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
|
((:row-buttons gridspec) request entity))))] ;; TODO double check usage of row buttons user and identity in callers
|
||||||
(apply com/data-grid-row
|
(apply com/data-grid-row
|
||||||
{:class (when flash?
|
{:class (cond-> (or class "")
|
||||||
"live-added")
|
flash? (hh/add-class "live-added"))
|
||||||
"_" (hiccup/raw (when delete-after-settle?
|
"_" (hiccup/raw (when delete-after-settle?
|
||||||
" on htmx:afterSettle wait 400ms then remove me"))
|
" on htmx:afterSettle wait 400ms then remove me"))
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"/test" ::test
|
"/test" ::test
|
||||||
"/new" {:get ::new-dialog}
|
"/new" {:get ::new-dialog}
|
||||||
["/" [#"\d+" :db/id] "/edit"] ::edit-dialog
|
["/" [#"\d+" :db/id] "/edit"] ::edit-dialog
|
||||||
|
["/" [#"\d+" :db/id] "/delete"] ::delete
|
||||||
["/" [#"\d+" :db/id] "/run"] {:get ::execute-dialog
|
["/" [#"\d+" :db/id] "/run"] {:get ::execute-dialog
|
||||||
:post ::execute}
|
:post ::execute}
|
||||||
"/check-badges" ::check-badges
|
"/check-badges" ::check-badges
|
||||||
|
|||||||
Reference in New Issue
Block a user