From 84d6f455ffb4e5ad8b260877b95b136e362d62e6 Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 23 Oct 2023 15:02:36 -0700 Subject: [PATCH] Makes cursor-seq for lists --- src/clj/auto_ap/ssr/admin/accounts.clj | 7 ++----- src/clj/auto_ap/ssr/admin/transaction_rules.clj | 5 +---- src/clj/auto_ap/ssr/form_cursor.clj | 10 ++++++++++ src/clj/auto_ap/ssr/users.clj | 8 ++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/clj/auto_ap/ssr/admin/accounts.clj b/src/clj/auto_ap/ssr/admin/accounts.clj index 6146ef91..c1ce0feb 100644 --- a/src/clj/auto_ap/ssr/admin/accounts.clj +++ b/src/clj/auto_ap/ssr/admin/accounts.clj @@ -376,11 +376,8 @@ (com/data-grid-header {} "Account name") (com/data-grid-header {})] :id "client-override-table"} - (when (fc/field-value) - (doall - (for [override fc/*current*] - (fc/with-cursor override - (client-override* override))))) + (fc/cursor-map + #(client-override* %)) (com/data-grid-row {:class "new-row"} (com/data-grid-cell {:colspan 3 diff --git a/src/clj/auto_ap/ssr/admin/transaction_rules.clj b/src/clj/auto_ap/ssr/admin/transaction_rules.clj index 5cd9dcf9..16f7f10e 100644 --- a/src/clj/auto_ap/ssr/admin/transaction_rules.clj +++ b/src/clj/auto_ap/ssr/admin/transaction_rules.clj @@ -549,10 +549,7 @@ (com/data-grid-header {:class "w-16"} "%") (com/data-grid-header {:class "w-16"})] :id "transaction-rule-account-table"} - (when (fc/field-value) - (doall (for [tra fc/*current*] - (fc/with-cursor tra - (transaction-rule-account-row* entity tra))))) + (fc/cursor-map #(transaction-rule-account-row* entity %)) (com/data-grid-row {:class "new-row"} (com/data-grid-cell {:colspan 4 diff --git a/src/clj/auto_ap/ssr/form_cursor.clj b/src/clj/auto_ap/ssr/form_cursor.clj index eef97db2..02c65ba4 100644 --- a/src/clj/auto_ap/ssr/form_cursor.clj +++ b/src/clj/auto_ap/ssr/form_cursor.clj @@ -45,3 +45,13 @@ (every? string? errors))))) +(defn cursor-map + ([f] (cursor-map *current* f)) + ([cursor f] + (when (field-value) + (doall + (for [n cursor] + (with-cursor n + (f n))))))) + + diff --git a/src/clj/auto_ap/ssr/users.clj b/src/clj/auto_ap/ssr/users.clj index 46c5ca19..e225fef3 100644 --- a/src/clj/auto_ap/ssr/users.clj +++ b/src/clj/auto_ap/ssr/users.clj @@ -322,9 +322,7 @@ (com/data-grid {:headers [(com/data-grid-header {} "Client") (com/data-grid-header {} )] :id "client-table"} - (doall (for [client fc/*current*] - (fc/with-cursor client - (client-row* client)))) + (fc/cursor-map #(client-row* %)) (com/data-grid-row {:class "new-row"} (com/data-grid-cell {:colspan 2 @@ -337,9 +335,7 @@ :hx-vals (hiccup/raw "js:{index: countRows(\"#client-table\")}") :hx-target "#edit-form .new-row" :hx-swap "beforebegin"} - "New override")]))) - )) - [:div#form-errors [:span.error-content]]] + "New override")])))))] [:div [:div [:div#form-errors (when (:errors fc/*form-errors*) [:span.error-content