Uses cursors for simplicity, uses common grid bottom

This commit is contained in:
2023-10-23 23:46:01 -07:00
parent 84d6f455ff
commit 48347bb8c5
8 changed files with 98 additions and 90 deletions

View File

@@ -323,19 +323,11 @@
(com/data-grid-header {} )]
:id "client-table"}
(fc/cursor-map #(client-row* %))
(com/data-grid-row
{:class "new-row"}
(com/data-grid-cell {:colspan 2
:class "bg-gray-100"}
[:div.flex.justify-center
(com/a-button {:hx-get (bidi/path-for ssr-routes/only-routes
:user-client-new)
:color :secondary
:hx-include "#edit-form"
:hx-vals (hiccup/raw "js:{index: countRows(\"#client-table\")}")
:hx-target "#edit-form .new-row"
:hx-swap "beforebegin"}
"New override")])))))]
(com/data-grid-new-row {:colspan 2
:index (count (fc/field-value))
:hx-get (bidi/path-for ssr-routes/only-routes
:user-client-new)}
"Assign new client"))))]
[:div
[:div [:div#form-errors (when (:errors fc/*form-errors*)
[:span.error-content
@@ -374,14 +366,10 @@
:headers {"hx-trigger" "modalopen"})))
(defn new-client [{ {:keys [index]} :query-params}]
(let [index (or index 0)
account {:user/clients (conj (into [] (repeat index {}))
{:db/id nil
:new? true})}] ;; TODO schema decode is not working
(html-response
(fc/start-form account []
(fc/with-cursor (get-in fc/*current* [:user/clients index])
(client-row* fc/*current*))))))
(html-response
(fc/start-form-with-prefix [:user/clients (or index 0)] {:db/id nil
:new? true} []
(client-row* fc/*current*))))
(def key->handler
(apply-middleware-to-all-handlers