Uses cursors for simplicity, uses common grid bottom
This commit is contained in:
@@ -248,7 +248,8 @@
|
||||
(defn client-override* [override]
|
||||
(com/data-grid-row (-> {:x-ref "p"
|
||||
:data-key "show"
|
||||
:x-data (hx/json {:show (boolean (not (:new? override)))})}
|
||||
:x-data (hx/json {:show (boolean (doto (not (fc/field-value (:new? override)))
|
||||
println))})}
|
||||
hx/alpine-mount-then-appear)
|
||||
(fc/with-field :db/id
|
||||
(com/hidden {:name (fc/field-name)
|
||||
@@ -378,19 +379,12 @@
|
||||
:id "client-override-table"}
|
||||
(fc/cursor-map
|
||||
#(client-override* %))
|
||||
(com/data-grid-row
|
||||
{:class "new-row"}
|
||||
(com/data-grid-cell {:colspan 3
|
||||
:class "bg-gray-100"}
|
||||
[:div.flex.justify-center
|
||||
(com/a-button {:hx-get (bidi/path-for ssr-routes/only-routes
|
||||
:admin-account-client-override-new)
|
||||
:color :secondary
|
||||
:hx-include "#edit-form"
|
||||
:hx-vals (hiccup/raw "js:{index: countRows(\"#client-override-table\")}")
|
||||
:hx-target "#edit-form .new-row"
|
||||
:hx-swap "beforebegin"}
|
||||
"New override")])))))
|
||||
|
||||
(com/data-grid-new-row {:colspan 3
|
||||
:index (count (fc/field-value))
|
||||
:hx-get (bidi/path-for ssr-routes/only-routes
|
||||
:admin-account-client-override-new)}
|
||||
"New override"))))
|
||||
|
||||
]
|
||||
[:div
|
||||
@@ -401,14 +395,13 @@
|
||||
"Save account")])]])]))
|
||||
|
||||
(defn new-client-override [{ {:keys [index]} :query-params}]
|
||||
(let [index (or index 0)
|
||||
account {:account/client-overrides (conj (into [] (repeat index {}))
|
||||
{:db/id (str (java.util.UUID/randomUUID))
|
||||
:new? true})}] ;; TODO schema decode is not working
|
||||
(html-response
|
||||
(fc/start-form account []
|
||||
(fc/with-cursor (get-in fc/*current* [:account/client-overrides index])
|
||||
(client-override* fc/*current*))))))
|
||||
(html-response
|
||||
(fc/start-form-with-prefix
|
||||
[:account/client-overrides (or index 0)]
|
||||
{:db/id (str (java.util.UUID/randomUUID))
|
||||
:new? true}
|
||||
[]
|
||||
(client-override* fc/*current*))))
|
||||
|
||||
(defn account-edit-dialog [request]
|
||||
(let [account (some-> request :route-params :db/id (#(dc/pull (dc/db conn) default-read %)))]
|
||||
|
||||
Reference in New Issue
Block a user