revamp more

This commit is contained in:
2023-10-24 12:29:48 -07:00
parent a8cce0377d
commit d7edf0221c
2 changed files with 4 additions and 18 deletions

View File

@@ -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"

View File

@@ -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)))))