From d7edf0221cc390cc24a647a627f9c5b4de9d49ec Mon Sep 17 00:00:00 2001 From: Bryce Date: Tue, 24 Oct 2023 12:29:48 -0700 Subject: [PATCH] revamp more --- src/clj/auto_ap/ssr/admin/accounts.clj | 19 ++++--------------- src/clj/auto_ap/ssr/users.clj | 3 --- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/clj/auto_ap/ssr/admin/accounts.clj b/src/clj/auto_ap/ssr/admin/accounts.clj index 3e95993e..3fd9557f 100644 --- a/src/clj/auto_ap/ssr/admin/accounts.clj +++ b/src/clj/auto_ap/ssr/admin/accounts.clj @@ -136,14 +136,14 @@ :parse-query-params (comp (query-params/parse-key :code query-params/parse-long) (helper/default-parse-query-params grid-page)) - :action-buttons (fn [request] + :action-buttons (fn [_] [(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes :admin-account-new-dialog)) :hx-target "#modal-content" :hx-swap "innerHTML" :color :primary} "New Account")]) - :row-buttons (fn [request entity] + :row-buttons (fn [_ entity] [(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes :admin-account-edit-dialog :db/id (:db/id entity))) @@ -184,16 +184,15 @@ (let [entity (cond-> form-params (= :post request-method) (assoc :db/id "new")) _ (cond (= :post request-method) - (when-let [extant (seq (dc/q '[:find ?x :in $ ?nc :where [?x :account/numeric-code ?nc]] (dc/db conn) (:account/numeric-code entity)))] + (when (seq (dc/q '[:find ?x :in $ ?nc :where [?x :account/numeric-code ?nc]] (dc/db conn) (:account/numeric-code entity))) (field-validation-error (format "The code %d is already in use." (:account/numeric-code entity)) [:account/numeric-code] :form form-params)) ) - ;; TODO the following would work better if the schema was hydrated automatically with needed values _ (some->> form-params :account/client-overrides (group-by :account-client-override/client) - (filter (fn [[client overrides]] + (filter (fn [[_ overrides]] (> (count overrides) 1))) (map first) seq @@ -235,16 +234,6 @@ :headers {"hx-trigger" "modalclose" "hx-retarget" (format "#account-table tr[data-id=\"%d\"]" (:db/id updated-account))}))) -;; TODO use cursor -;; TODO index based list not dbid - -;; TODO lots of weird edge cases with indexes -;; for example, what happens when you have 0, 1, 2, but then delete 1? -;; what happens when you delete 2 but then add another one? -;; preference is that the field parsing logic does better grouping of what -;; goes with what, building index on the server side -;; not needing to pass index in - ;; TODO decide when cursors are used. other cases it's not, some are (defn client-override* [override] (com/data-grid-row (-> {:x-ref "p" diff --git a/src/clj/auto_ap/ssr/users.clj b/src/clj/auto_ap/ssr/users.clj index 3040f057..c7f5fec4 100644 --- a/src/clj/auto_ap/ssr/users.clj +++ b/src/clj/auto_ap/ssr/users.clj @@ -369,8 +369,6 @@ :new? true} [] (client-row* fc/*current*)))) - - (def key->handler (apply-middleware-to-all-handlers {:users (helper/page-route grid-page) @@ -396,4 +394,3 @@ (-> h (wrap-admin) (wrap-client-redirect-unauthenticated))))) -