more cleanup.
This commit is contained in:
@@ -31,10 +31,9 @@
|
|||||||
@apply opacity-100 !important;
|
@apply opacity-100 !important;
|
||||||
@apply scale-100 !important;
|
@apply scale-100 !important;
|
||||||
@apply -translate-x-1/2 !important;
|
@apply -translate-x-1/2 !important;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.htmx-added.swipe-left-swap , .htmx-added .swipe-left-swap{
|
.swipe-left-swap {
|
||||||
@apply opacity-100;
|
@apply opacity-100;
|
||||||
@apply scale-100;
|
@apply scale-100;
|
||||||
@apply translate-x-0;
|
@apply translate-x-0;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -13,6 +13,7 @@
|
|||||||
[auto-ap.datomic.accounts :as d-accounts]
|
[auto-ap.datomic.accounts :as d-accounts]
|
||||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||||
[auto-ap.query-params :as query-params]
|
[auto-ap.query-params :as query-params]
|
||||||
|
[auto-ap.routes.admin.transaction-rules :as route]
|
||||||
[auto-ap.routes.utils
|
[auto-ap.routes.utils
|
||||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||||
[auto-ap.ssr-routes :as ssr-routes]
|
[auto-ap.ssr-routes :as ssr-routes]
|
||||||
@@ -51,7 +52,7 @@
|
|||||||
(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"
|
||||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||||
:admin-transaction-rule-table)
|
::route/table)
|
||||||
"hx-target" "#entity-table"
|
"hx-target" "#entity-table"
|
||||||
"hx-indicator" "#entity-table"}
|
"hx-indicator" "#entity-table"}
|
||||||
|
|
||||||
@@ -183,30 +184,25 @@
|
|||||||
(query-params/parse-key :vendor #(dc/pull (dc/db conn) '[:vendor/name :db/id] (Long/parseLong %)))
|
(query-params/parse-key :vendor #(dc/pull (dc/db conn) '[:vendor/name :db/id] (Long/parseLong %)))
|
||||||
(helper/default-parse-query-params grid-page))
|
(helper/default-parse-query-params grid-page))
|
||||||
:action-buttons (fn [request]
|
:action-buttons (fn [request]
|
||||||
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/new-dialog))
|
||||||
:admin-transaction-rule-new-dialog))
|
|
||||||
: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-get (str (bidi/path-for ssr-routes/only-routes
|
::route/execute-dialog
|
||||||
:admin-transaction-rule-execute-results
|
:db/id (:db/id entity))}
|
||||||
:db/id (:db/id entity)))}
|
|
||||||
svg/play)
|
svg/play)
|
||||||
(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
(com/icon-button {:hx-get (bidi/path-for ssr-routes/only-routes
|
||||||
:admin-transaction-rule-edit-dialog
|
::route/edit-dialog
|
||||||
:db/id (:db/id entity)))}
|
:db/id (:db/id entity))}
|
||||||
svg/pencil)])
|
svg/pencil)])
|
||||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes :admin)}
|
||||||
:admin)}
|
|
||||||
"Admin"]
|
"Admin"]
|
||||||
|
[:a {:href (bidi/path-for ssr-routes/only-routes ::route/page)}
|
||||||
[:a {:href (bidi/path-for ssr-routes/only-routes
|
|
||||||
:admin-transaction-rules)}
|
|
||||||
"Transaction Rules"]]
|
"Transaction Rules"]]
|
||||||
:title "Rules"
|
:title "Rules"
|
||||||
:entity-name "Rule"
|
:entity-name "Rule"
|
||||||
:route :admin-transaction-rule-table
|
:route ::route/table
|
||||||
:headers [{:key "client"
|
:headers [{:key "client"
|
||||||
:name "Client"
|
:name "Client"
|
||||||
:sort-key "client"
|
:sort-key "client"
|
||||||
@@ -284,7 +280,7 @@
|
|||||||
[:transaction-rule/bank-account]
|
[:transaction-rule/bank-account]
|
||||||
:form form-params)))
|
:form form-params)))
|
||||||
|
|
||||||
(defn transaction-rule-save [{:keys [form-params request-method identity] :as request}]
|
(defn save [{:keys [form-params request-method identity] :as request}]
|
||||||
(validate-transaction-rule form-params)
|
(validate-transaction-rule form-params)
|
||||||
(let [entity (cond-> form-params
|
(let [entity (cond-> form-params
|
||||||
(= :post request-method) (assoc :db/id "new")
|
(= :post request-method) (assoc :db/id "new")
|
||||||
@@ -307,13 +303,15 @@
|
|||||||
(def transaction-read '[{:transaction/client [:client/name]
|
(def transaction-read '[{:transaction/client [:client/name]
|
||||||
:transaction/bank-account [:bank-account/name]}
|
:transaction/bank-account [:bank-account/name]}
|
||||||
:transaction/description-original
|
:transaction/description-original
|
||||||
|
:db/id
|
||||||
[:transaction/date :xform clj-time.coerce/from-date]])
|
[:transaction/date :xform clj-time.coerce/from-date]])
|
||||||
|
|
||||||
|
|
||||||
(defn transaction-rule-test-table* [{{:transaction-rule/keys [description client bank-account amount-lte amount-gte dom-lte dom-gte yodlee-merchant]}
|
(defn transaction-rule-test-table* [{{:transaction-rule/keys [description client bank-account amount-lte amount-gte dom-lte dom-gte yodlee-merchant]}
|
||||||
:entity
|
:entity
|
||||||
clients :clients
|
clients :clients
|
||||||
checkboxes? :checkboxes?}]
|
checkboxes? :checkboxes?
|
||||||
|
only-uncoded? :only-uncoded?}]
|
||||||
(let [valid-clients (extract-client-ids clients
|
(let [valid-clients (extract-client-ids clients
|
||||||
client)
|
client)
|
||||||
|
|
||||||
@@ -366,20 +364,26 @@
|
|||||||
'[(>= ?dom ?dom-gte)]]}
|
'[(>= ?dom ?dom-gte)]]}
|
||||||
:args [dom-gte]})
|
:args [dom-gte]})
|
||||||
|
|
||||||
|
only-uncoded?
|
||||||
|
(merge-query {:query {:where ['[or [?e :transaction/approval-status :transaction-approval-status/unapproved]
|
||||||
|
[(missing? $ ?e :transaction/approval-status)]]]}})
|
||||||
|
|
||||||
true
|
true
|
||||||
(merge-query {:query {:where ['[?e :transaction/id]]}}))
|
(merge-query {:query {:where ['[?e :transaction/id]]}}))
|
||||||
results (->>
|
results (->>
|
||||||
(query2 query)
|
(query2 query)
|
||||||
(map first))]
|
(map first))]
|
||||||
|
|
||||||
[:div
|
[:div#transaction-test-results
|
||||||
[:h2.my-4.text-lg.flex "Matching transactions" [:div.ml-4.relative (com/badge {:class "text-[0.6rem]"} (let [cnt (count results)]
|
[:h2.my-4.text-lg.flex {:x-data (hx/json {:resultCount (count results)})} "Matching transactions"
|
||||||
(if (>= cnt 99)
|
[:div.ml-4.relative (com/badge {:class "text-[0.6rem]"} (let [cnt (count results)]
|
||||||
"99+"
|
(if (>= cnt 99)
|
||||||
cnt)))]]
|
"99+"
|
||||||
|
cnt)))]
|
||||||
|
[:div.flex.justify-end.flex-1 [:div.gutter]]]
|
||||||
(com/data-grid
|
(com/data-grid
|
||||||
{:headers [(when checkboxes?
|
{:headers [(when checkboxes?
|
||||||
(com/data-grid-checkbox-header {}))
|
(com/data-grid-checkbox-header {:name "all"}))
|
||||||
(com/data-grid-header {} "Client")
|
(com/data-grid-header {} "Client")
|
||||||
(com/data-grid-header {} "Bank")
|
(com/data-grid-header {} "Bank")
|
||||||
(com/data-grid-header {} "Date")
|
(com/data-grid-header {} "Date")
|
||||||
@@ -388,20 +392,20 @@
|
|||||||
(com/data-grid-row
|
(com/data-grid-row
|
||||||
{}
|
{}
|
||||||
(when checkboxes?
|
(when checkboxes?
|
||||||
(com/data-grid-cell {} (com/checkbox {})))
|
(com/data-grid-cell {} (com/checkbox {:name "transaction-id" :value (:db/id r)})))
|
||||||
(com/data-grid-cell {} (-> r :transaction/client :client/name))
|
(com/data-grid-cell {} (-> r :transaction/client :client/name))
|
||||||
(com/data-grid-cell {} (-> r :transaction/bank-account :bank-account/name))
|
(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/date (atime/unparse-local atime/normal-date)))
|
||||||
(com/data-grid-cell {} (some-> r :transaction/description-original )))))]))
|
(com/data-grid-cell {} (some-> r :transaction/description-original )))))]))
|
||||||
|
|
||||||
(defn transaction-rule-test [{:keys [form-params request-method identity] :as request
|
(defn test [{:keys [form-params request-method identity] :as request
|
||||||
entity :form-params}]
|
entity :form-params}]
|
||||||
(validate-transaction-rule form-params)
|
(validate-transaction-rule form-params)
|
||||||
(html-response
|
(html-response
|
||||||
(com/stacked-modal-card
|
(com/stacked-modal-card
|
||||||
1
|
1
|
||||||
{}
|
{}
|
||||||
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"] [:div.ml-4.relative (com/badge {} 100 #_(count results))]]
|
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"] ]
|
||||||
(transaction-rule-test-table* {:entity entity
|
(transaction-rule-test-table* {:entity entity
|
||||||
:clients (:clients request)})
|
:clients (:clients request)})
|
||||||
[:div.flex.justify-between
|
[:div.flex.justify-between
|
||||||
@@ -410,11 +414,11 @@
|
|||||||
:class "w-32"}
|
:class "w-32"}
|
||||||
"Back")
|
"Back")
|
||||||
(com/button (cond-> {:color :primary
|
(com/button (cond-> {:color :primary
|
||||||
:hx-vals (hx/json (:raw-form-params request))
|
:hx-include "#my-form"
|
||||||
:class "w-32"
|
: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 ::route/save))
|
||||||
(not (:db/id form-params)) (assoc :hx-post (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 ::route/save)))
|
||||||
"Save rule")])
|
"Save rule")])
|
||||||
:headers (-> {}
|
:headers (-> {}
|
||||||
(assoc "hx-trigger-after-settle" "modalnext")
|
(assoc "hx-trigger-after-settle" "modalnext")
|
||||||
@@ -422,6 +426,8 @@
|
|||||||
(assoc "hx-reswap" "beforeend"))))
|
(assoc "hx-reswap" "beforeend"))))
|
||||||
|
|
||||||
|
|
||||||
|
;; TODO only uncoded
|
||||||
|
|
||||||
|
|
||||||
(defn- location-select*
|
(defn- location-select*
|
||||||
[{:keys [ name account-location client-locations value]}]
|
[{:keys [ name account-location client-locations value]}]
|
||||||
@@ -476,7 +482,7 @@
|
|||||||
[:div {:hx-trigger "changed"
|
[:div {:hx-trigger "changed"
|
||||||
:hx-target "next div"
|
:hx-target "next div"
|
||||||
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId, value: event.detail.accountId}" account-name)
|
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId, value: event.detail.accountId}" account-name)
|
||||||
:hx-get (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-account-typeahead))
|
:hx-get (str (bidi/path-for ssr-routes/only-routes ::route/account-typeahead))
|
||||||
:x-init "$watch('clientId', cid => $dispatch('changed', $data));"}]
|
:x-init "$watch('clientId', cid => $dispatch('changed', $data));"}]
|
||||||
(account-typeahead* {:value (fc/field-value)
|
(account-typeahead* {:value (fc/field-value)
|
||||||
:client-id client-id
|
:client-id client-id
|
||||||
@@ -492,7 +498,7 @@
|
|||||||
:hx-target "next *"
|
:hx-target "next *"
|
||||||
:hx-swap "outerHTML"
|
:hx-swap "outerHTML"
|
||||||
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId || '', 'account-id': event.detail.accountId || '', value: event.detail.location}" (fc/field-name) )
|
:hx-vals (format "js:{name: '%s', 'client-id': event.detail.clientId || '', 'account-id': event.detail.accountId || '', value: event.detail.location}" (fc/field-name) )
|
||||||
:hx-get (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-location-select)
|
:hx-get (bidi/path-for ssr-routes/only-routes ::route/location-select)
|
||||||
:x-init "$watch('clientId', cid => $dispatch('changed', $data)); $watch('accountId', cid => $dispatch('changed', $data) )"}]
|
:x-init "$watch('clientId', cid => $dispatch('changed', $data)); $watch('accountId', cid => $dispatch('changed', $data) )"}]
|
||||||
(location-select* {:name (fc/field-name)
|
(location-select* {:name (fc/field-name)
|
||||||
:account-location (:account/location (cond->> (:transaction-rule-account/account @account)
|
:account-location (:account/location (cond->> (:transaction-rule-account/account @account)
|
||||||
@@ -531,7 +537,7 @@
|
|||||||
:x-trap "true"
|
:x-trap "true"
|
||||||
(if (:db/id entity)
|
(if (:db/id entity)
|
||||||
:hx-put
|
:hx-put
|
||||||
:hx-post) (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-edit-save))}
|
:hx-post) (str (bidi/path-for ssr-routes/only-routes ::route/save))}
|
||||||
[:fieldset {:class "hx-disable"
|
[:fieldset {:class "hx-disable"
|
||||||
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client form-params))
|
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client form-params))
|
||||||
(:transaction-rule/client form-params)
|
(:transaction-rule/client form-params)
|
||||||
@@ -664,7 +670,7 @@
|
|||||||
(fc/cursor-map #(transaction-rule-account-row* % (:transaction-rule/client form-params) client-locations))
|
(fc/cursor-map #(transaction-rule-account-row* % (:transaction-rule/client form-params) client-locations))
|
||||||
(com/data-grid-new-row {:colspan 4
|
(com/data-grid-new-row {:colspan 4
|
||||||
:hx-get (bidi/path-for ssr-routes/only-routes
|
:hx-get (bidi/path-for ssr-routes/only-routes
|
||||||
:admin-transaction-rule-new-account)
|
::route/new-account)
|
||||||
:index (count (fc/field-value))
|
:index (count (fc/field-value))
|
||||||
:tr-params (hx/bind-alpine-vals {} {:client-id "clientId"})}
|
:tr-params (hx/bind-alpine-vals {} {:client-id "clientId"})}
|
||||||
"New account")))))
|
"New account")))))
|
||||||
@@ -676,15 +682,13 @@
|
|||||||
:value (fc/field-value)
|
:value (fc/field-value)
|
||||||
:name (fc/field-name)
|
:name (fc/field-name)
|
||||||
:size :small
|
:size :small
|
||||||
:orientation :horizontal})))
|
:orientation :horizontal})))]]]
|
||||||
|
|
||||||
]]]
|
|
||||||
[:div
|
[:div
|
||||||
(com/form-errors {:errors (:errors fc/*form-errors*)})
|
(com/form-errors {:errors (:errors fc/*form-errors*)})
|
||||||
[:div.flex.justify-end
|
[:div.flex.justify-end
|
||||||
|
|
||||||
(com/validated-save-button {:errors form-errors :color :secondary
|
(com/validated-save-button {:errors form-errors :color :secondary
|
||||||
:hx-post (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-test)
|
:hx-post (bidi/path-for ssr-routes/only-routes ::route/test)
|
||||||
:hx-include "#my-form"}
|
:hx-include "#my-form"}
|
||||||
|
|
||||||
"Test rule")
|
"Test rule")
|
||||||
@@ -742,7 +746,7 @@
|
|||||||
[:transaction-rule-account/location [:string {:min 1 :error/message "required"}]]
|
[:transaction-rule-account/location [:string {:min 1 :error/message "required"}]]
|
||||||
[:transaction-rule-account/percentage percentage])]]))
|
[:transaction-rule-account/percentage percentage])]]))
|
||||||
|
|
||||||
(defn transaction-dialog [{:keys [entity form-params form-errors]}]
|
(defn edit-dialog [{:keys [entity form-params form-errors]}]
|
||||||
(modal-response (dialog* {:entity entity
|
(modal-response (dialog* {:entity entity
|
||||||
:form-params (or (when (seq form-params)
|
:form-params (or (when (seq form-params)
|
||||||
form-params)
|
form-params)
|
||||||
@@ -751,16 +755,31 @@
|
|||||||
{})
|
{})
|
||||||
:form-errors form-errors})))
|
:form-errors form-errors})))
|
||||||
|
|
||||||
(defn transaction-rule-execute-results [{:keys [entity clients]}]
|
(defn check-badges [{query-params :query-params}]
|
||||||
|
(html-response
|
||||||
|
[:div (if (not-empty (:all query-params))
|
||||||
|
(com/pill {:color :secondary}
|
||||||
|
|
||||||
|
[:span "All " [:span {:x-text "resultCount" :x-data "{}"}] " transactions"])
|
||||||
|
(com/pill {:color :primary}
|
||||||
|
(str (count (:transaction-id query-params)) " transactions")))]))
|
||||||
|
|
||||||
|
(defn execute-dialog [{:keys [entity clients]}]
|
||||||
(modal-response
|
(modal-response
|
||||||
(com/modal{}
|
(com/modal{}
|
||||||
(com/stacked-modal-card
|
(com/stacked-modal-card
|
||||||
0
|
0
|
||||||
{}
|
{}
|
||||||
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"]]
|
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"]]
|
||||||
(transaction-rule-test-table* {:entity entity
|
[:div#my-form
|
||||||
:clients clients
|
{:hx-get (bidi/path-for ssr-routes/only-routes ::route/check-badges)
|
||||||
:checkboxes? true})
|
:hx-trigger "change"
|
||||||
|
:hx-target "#transaction-test-results .gutter"
|
||||||
|
:hx-include "this"}
|
||||||
|
(transaction-rule-test-table* {:entity entity
|
||||||
|
:clients clients
|
||||||
|
:checkboxes? true
|
||||||
|
:only-uncoded? true})]
|
||||||
[:div.flex.justify-end (com/validated-save-button {:form "my-form"} "Code transactions")]))
|
[:div.flex.justify-end (com/validated-save-button {:form "my-form"} "Code transactions")]))
|
||||||
:headers (-> {}
|
:headers (-> {}
|
||||||
(assoc "hx-trigger-after-settle" "modalnext")
|
(assoc "hx-trigger-after-settle" "modalnext")
|
||||||
@@ -772,56 +791,60 @@
|
|||||||
(def key->handler
|
(def key->handler
|
||||||
(apply-middleware-to-all-handlers
|
(apply-middleware-to-all-handlers
|
||||||
(->>
|
(->>
|
||||||
{:admin-transaction-rules (helper/page-route grid-page)
|
{::route/page (helper/page-route grid-page)
|
||||||
:admin-transaction-rule-table (helper/table-route grid-page)
|
::route/table (helper/table-route grid-page)
|
||||||
:admin-transaction-rule-new-account (-> new-account
|
::route/new-account (-> new-account
|
||||||
(wrap-schema-decode :query-schema [:map
|
(wrap-schema-decode :query-schema [:map
|
||||||
[:client-id {:optional true}
|
[:client-id {:optional true}
|
||||||
[:maybe entity-id]]
|
[:maybe entity-id]]
|
||||||
[:index {:optional true
|
[:index {:optional true
|
||||||
:default 0} [nat-int? {:default 0}]]])
|
:default 0} [nat-int? {:default 0}]]])
|
||||||
wrap-admin wrap-client-redirect-unauthenticated)
|
wrap-admin wrap-client-redirect-unauthenticated)
|
||||||
:admin-transaction-rule-location-select (-> location-select
|
::route/location-select (-> location-select
|
||||||
(wrap-schema-decode :query-schema [:map
|
(wrap-schema-decode :query-schema [:map
|
||||||
[:name :string]
|
[:name :string]
|
||||||
[:client-id {:optional true}
|
[:client-id {:optional true}
|
||||||
[:maybe entity-id]]
|
[:maybe entity-id]]
|
||||||
[:account-id {:optional true}
|
[:account-id {:optional true}
|
||||||
[:maybe entity-id]]]))
|
[:maybe entity-id]]]))
|
||||||
:admin-transaction-rule-account-typeahead (-> account-typeahead
|
::route/account-typeahead (-> account-typeahead
|
||||||
(wrap-schema-decode :query-schema [:map
|
(wrap-schema-decode :query-schema [:map
|
||||||
[:name :string]
|
[:name :string]
|
||||||
[:client-id {:optional true}
|
[:client-id {:optional true}
|
||||||
[:maybe entity-id]]
|
[:maybe entity-id]]
|
||||||
[:value {:optional true}
|
[:value {:optional true}
|
||||||
[:maybe entity-id]]]))
|
[:maybe entity-id]]]))
|
||||||
:admin-transaction-rule-save (-> transaction-rule-save
|
::route/save (-> save
|
||||||
(wrap-entity [:form-params :db/id] default-read)
|
(wrap-entity [:form-params :db/id] default-read)
|
||||||
(wrap-schema-decode :form-schema form-schema)
|
(wrap-schema-decode :form-schema form-schema)
|
||||||
(wrap-nested-form-params)
|
(wrap-nested-form-params)
|
||||||
(wrap-form-4xx-2 (-> transaction-dialog
|
(wrap-form-4xx-2 (-> edit-dialog
|
||||||
(wrap-entity [:form-params :db/id] default-read))))
|
(wrap-entity [:form-params :db/id] default-read))))
|
||||||
|
|
||||||
:admin-transaction-rule-test (-> transaction-rule-test
|
::route/test (-> test
|
||||||
(wrap-entity [:form-params :db/id] default-read)
|
(wrap-entity [:form-params :db/id] default-read)
|
||||||
(wrap-schema-decode :form-schema form-schema)
|
(wrap-schema-decode :form-schema form-schema)
|
||||||
(wrap-nested-form-params)
|
(wrap-nested-form-params)
|
||||||
(wrap-form-4xx-2 (-> transaction-dialog
|
(wrap-form-4xx-2 (-> edit-dialog
|
||||||
(wrap-entity [:form-params :db/id] default-read))))
|
(wrap-entity [:form-params :db/id] default-read))))
|
||||||
|
|
||||||
:admin-transaction-rule-execute-results (-> transaction-rule-execute-results
|
::route/check-badges (-> check-badges
|
||||||
(wrap-entity [:route-params :db/id] default-read)
|
(wrap-schema-decode :query-schema [:map
|
||||||
(wrap-schema-decode :route-schema [:map [:db/id entity-id]]))
|
[:transaction-id {:optional true}
|
||||||
:admin-transaction-rule-filled-account (-> transaction-dialog
|
[:maybe [:vector {:decode/arbitrary (fn [x]
|
||||||
(wrap-entity [:form-params :db/id] default-read)
|
(if (sequential? x)
|
||||||
(wrap-schema-decode :form-schema form-schema)
|
x
|
||||||
(wrap-nested-form-params)
|
[x]))}
|
||||||
(wrap-form-4xx-2 (-> transaction-dialog
|
entity-id]]]
|
||||||
(wrap-entity [:form-params :db/id] default-read))))
|
[:all {:optional true} [:maybe :string]]]))
|
||||||
:admin-transaction-rule-edit-dialog (-> transaction-dialog
|
::route/execute-dialog (-> execute-dialog
|
||||||
(wrap-entity [:route-params :db/id] default-read)
|
(wrap-entity [:route-params :db/id] default-read)
|
||||||
(wrap-schema-decode :route-schema [:map [:db/id entity-id]]))
|
(wrap-schema-decode :route-schema [:map [:db/id entity-id]]))
|
||||||
:admin-transaction-rule-new-dialog transaction-dialog})
|
|
||||||
|
::route/edit-dialog (-> edit-dialog
|
||||||
|
(wrap-entity [:route-params :db/id] default-read)
|
||||||
|
(wrap-schema-decode :route-schema [:map [:db/id entity-id]]))
|
||||||
|
::route/new-dialog edit-dialog})
|
||||||
(fn [h]
|
(fn [h]
|
||||||
(-> h
|
(-> h
|
||||||
(wrap-admin)
|
(wrap-admin)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
(defn checkbox-header- [params & rest]
|
(defn checkbox-header- [params & rest]
|
||||||
[:th {:scope "col", :class "p-4"}
|
[:th {:scope "col", :class "p-4"}
|
||||||
[:div {:class "flex items-center"}
|
[:div {:class "flex items-center"}
|
||||||
[:input {:id "checkbox-all", :type "checkbox", :class inputs/default-checkbox-classes}]
|
[:input {:id "checkbox-all", :type "checkbox", :class inputs/default-checkbox-classes :name (:name params) :value (:value params)}]
|
||||||
[:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]])
|
[:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]])
|
||||||
|
|
||||||
(defn data-grid- [{:keys [headers thead-params id]} & rest]
|
(defn data-grid- [{:keys [headers thead-params id]} & rest]
|
||||||
|
|||||||
@@ -204,5 +204,5 @@
|
|||||||
[:input {:type "hidden" :value value :name name}])
|
[:input {:type "hidden" :value value :name name}])
|
||||||
|
|
||||||
(defn checkbox- [params & rest]
|
(defn checkbox- [params & rest]
|
||||||
[:input {:type "checkbox" :class (hh/add-class default-checkbox-classes (:class params ""))}
|
[:input (merge params {:type "checkbox" :class (hh/add-class default-checkbox-classes (:class params ""))})
|
||||||
rest])
|
rest])
|
||||||
|
|||||||
@@ -12,17 +12,9 @@
|
|||||||
\"foo[bar][][baz]\"
|
\"foo[bar][][baz]\"
|
||||||
=> [\"foo\" \"bar\" \"\" \"baz\"]"
|
=> [\"foo\" \"bar\" \"\" \"baz\"]"
|
||||||
[param-name]
|
[param-name]
|
||||||
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:(\[.*?\])|\(.*?\))*)" (name param-name))
|
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:\[.*?\])*)" (name param-name))
|
||||||
keys (if ks (map second (re-seq #"(\[.*?\]|\(.*?\))" ks)))]
|
keys (if ks (map second (re-seq #"\[(.*?)\]" ks)))]
|
||||||
(cons k
|
(cons k keys)))
|
||||||
(map (fn [k]
|
|
||||||
(let [[_ indexed-match] (re-matches k "\((.*?)\)")
|
|
||||||
[_ keyed-match] (re-matches k "\[(.*?)\]")]
|
|
||||||
(if indexed-match
|
|
||||||
[:index indexed-match]
|
|
||||||
[:key indexed-match])))))))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn- assoc-vec [m k v]
|
(defn- assoc-vec [m k v]
|
||||||
(let [m (if (contains? m k) m (assoc m k []))]
|
(let [m (if (contains? m k) m (assoc m k []))]
|
||||||
|
|||||||
16
src/cljc/auto_ap/routes/admin/transaction_rules.cljc
Normal file
16
src/cljc/auto_ap/routes/admin/transaction_rules.cljc
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
(ns auto-ap.routes.admin.transaction-rules)
|
||||||
|
|
||||||
|
(def routes {"" {:get ::page
|
||||||
|
:put ::save
|
||||||
|
:post ::save}
|
||||||
|
"/table" ::table
|
||||||
|
"/account/filled" ::dialog-filled
|
||||||
|
"/account/new" ::new-account
|
||||||
|
"/account/location-select" ::location-select
|
||||||
|
"/account/typeahead" ::account-typeahead
|
||||||
|
"/test" ::test
|
||||||
|
"/new" {:get ::new-dialog}
|
||||||
|
[[#"\d+" :db/id] "/edit"] ::edit-dialog
|
||||||
|
[[#"\d+" :db/id] "/run"] ::execute-dialog
|
||||||
|
"/check-badges" ::check-badges
|
||||||
|
})
|
||||||
2
src/cljc/auto_ap/ssr/admin/transaction_rules.cljc
Normal file
2
src/cljc/auto_ap/ssr/admin/transaction_rules.cljc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
(ns auto-ap.ssr.admin.transaction-rules)
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
(ns auto-ap.ssr-routes)
|
(ns auto-ap.ssr-routes
|
||||||
|
(:require [auto-ap.routes.admin.transaction-rules :as tr-routes]))
|
||||||
|
|
||||||
(def routes {"impersonate" :impersonate
|
(def routes {"impersonate" :impersonate
|
||||||
"logout" :logout
|
"logout" :logout
|
||||||
@@ -33,19 +34,7 @@
|
|||||||
"/new" {:get :admin-job-start-dialog}
|
"/new" {:get :admin-job-start-dialog}
|
||||||
"/subform" :admin-job-subform}
|
"/subform" :admin-job-subform}
|
||||||
"/ezcater-xls" :admin-ezcater-xls
|
"/ezcater-xls" :admin-ezcater-xls
|
||||||
"/transaction-rule" {"" {:get :admin-transaction-rules
|
"/transaction-rule" tr-routes/routes}
|
||||||
:put :admin-transaction-rule-save
|
|
||||||
:post :admin-transaction-rule-save}
|
|
||||||
"/table" :admin-transaction-rule-table
|
|
||||||
"/account/filled" :admin-transaction-rule-filled-account
|
|
||||||
"/account/new" :admin-transaction-rule-new-account
|
|
||||||
"/account/location-select" :admin-transaction-rule-location-select
|
|
||||||
"/account/typeahead" :admin-transaction-rule-account-typeahead
|
|
||||||
"/test" :admin-transaction-rule-test
|
|
||||||
"/new" {:get :admin-transaction-rule-new-dialog}
|
|
||||||
[[#"\d+" :db/id] "/edit"] :admin-transaction-rule-edit-dialog
|
|
||||||
[[#"\d+" :db/id] "/run"] :admin-transaction-rule-execute-results
|
|
||||||
}}
|
|
||||||
"transaction" {"/insights" {"" :transaction-insights
|
"transaction" {"/insights" {"" :transaction-insights
|
||||||
"/table" :transaction-insight-table
|
"/table" :transaction-insight-table
|
||||||
["/code/" [#"\d+" :transaction-id]] {:post :transaction-insight-code}
|
["/code/" [#"\d+" :transaction-id]] {:post :transaction-insight-code}
|
||||||
|
|||||||
Reference in New Issue
Block a user