progress on updating users

This commit is contained in:
Bryce
2023-10-22 06:27:55 -07:00
parent 998d29690e
commit a6032e2be2
5 changed files with 109 additions and 105 deletions

View File

@@ -1356,6 +1356,10 @@ input:checked + .toggle-bg {
max-height: 100%; max-height: 100%;
} }
.max-h-\[90vh\] {
max-height: 90vh;
}
.w-1\/2 { .w-1\/2 {
width: 50%; width: 50%;
} }

View File

@@ -65,7 +65,7 @@
[:fieldset.space-y-6 [:fieldset.space-y-6
(com/field {:label "Vendor"} (com/field {:label "Vendor"}
(com/typeahead {:name "vendor" (com/typeahead-2 {:name "vendor"
:placeholder "Search..." :placeholder "Search..."
:url (bidi/path-for ssr-routes/only-routes :url (bidi/path-for ssr-routes/only-routes
:vendor-search) :vendor-search)
@@ -193,7 +193,7 @@
[(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes [(com/button {:hx-get (str (bidi/path-for ssr-routes/only-routes
:admin-transaction-rule-new-dialog)) :admin-transaction-rule-new-dialog))
:hx-target "#modal-content" :hx-target "#modal-content"
:hx-swap "innerHTML" :hx-swap "outerHTML"
:color :primary} :color :primary}
"New Transaction Rule")]) "New Transaction Rule")])
:row-buttons (fn [request entity] :row-buttons (fn [request entity]
@@ -201,7 +201,7 @@
:admin-transaction-rule-edit-dialog :admin-transaction-rule-edit-dialog
:db/id (:db/id entity))) :db/id (:db/id entity)))
:hx-target "#modal-content" :hx-target "#modal-content"
:hx-swap "innerHTML"} :hx-swap "outerHTML"}
svg/pencil)]) svg/pencil)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes :breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:admin)} :admin)}
@@ -220,7 +220,8 @@
{:key "bank-account" {:key "bank-account"
:name "Bank account" :name "Bank account"
:sort-key "bank-account" :sort-key "bank-account"
:render #(-> % :transaction-rule/bank-account :bank-account/name)} :render #(-> % :transaction-rule/bank-account :bank-account/name)
:show-starting "lg"}
{:key "description" {:key "description"
:name "Description" :name "Description"
:sort-key "description" :sort-key "description"
@@ -233,7 +234,8 @@
(com/pill {:color :red} (format "more than $%.2f" amount-gte))) (com/pill {:color :red} (format "more than $%.2f" amount-gte)))
(when amount-lte (when amount-lte
(com/pill {:color :primary} (format "less than $%.2f" amount-lte)))])} (com/pill {:color :primary} (format "less than $%.2f" amount-lte)))])
:show-starting "md"}
{:key "note" {:key "note"
:name "Note" :name "Note"
:sort-key "note" :sort-key "note"
@@ -401,9 +403,7 @@
(defn dialog* [& {:keys [entity form-params form-errors]}] (defn dialog* [& {:keys [entity form-params form-errors]}]
(com/modal (com/modal
{:modal-class "max-w-2xl"} {:modal-class "max-w-2xl"}
(com/modal-card
{}
[:div.flex [:div.p-2 "Transaction Rule"]]
[:form#edit-form (merge {:hx-ext "response-targets" [:form#edit-form (merge {:hx-ext "response-targets"
:hx-swap "outerHTML swap:300ms" :hx-swap "outerHTML swap:300ms"
:hx-target "#modal-holder" :hx-target "#modal-holder"
@@ -411,6 +411,9 @@
:x-trap "true" :x-trap "true"
:class "group/form"} :class "group/form"}
form-params) form-params)
(com/modal-card
{}
[:div.flex [:div.p-2 "Transaction Rule"]]
[:fieldset {:class "hx-disable" :hx-disinherit "hx-target" [:fieldset {:class "hx-disable" :hx-disinherit "hx-target"
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client entity)) :x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client entity))
(:transaction-rule/client entity))})} (:transaction-rule/client entity))})}
@@ -469,8 +472,7 @@
(com/validated-field (com/validated-field
(-> {:label "Bank Account" (-> {:label "Bank Account"
:errors (fc/field-errors) :errors (fc/field-errors)
:x-show "bankAccountFilter" :x-show "bankAccountFilter"}
}
hx/alpine-appear) hx/alpine-appear)
[:div.w-96 [:div.w-96
[:div#bank-account-changer {:hx-get (bidi/path-for ssr-routes/only-routes :bank-account-typeahead) [:div#bank-account-changer {:hx-get (bidi/path-for ssr-routes/only-routes :bank-account-typeahead)
@@ -578,12 +580,11 @@
[:div#form-errors (when (:errors fc/*form-errors*) [:div#form-errors (when (:errors fc/*form-errors*)
[:span.error-content [:span.error-content
(com/errors {:errors (:errors fc/*form-errors*)})])] (com/errors {:errors (:errors fc/*form-errors*)})])]])]
(com/button {:color :primary :form "edit-form" :type "submit" :class (cond-> "w-32" [:div (com/button {:color :primary :form "edit-form" :type "submit" :class (cond-> "w-32"
(seq form-errors) (-> (seq form-errors) (->
(hh/add-class "animate-shake")))} (hh/add-class "animate-shake")))}
"Save")])]] "Save")])]))
[:div])))
;; TODO Should forms have some kind of helper to render an individual field? saving ;; TODO Should forms have some kind of helper to render an individual field? saving

View File

@@ -3,15 +3,15 @@
[auto-ap.ssr.hx :as hx])) [auto-ap.ssr.hx :as hx]))
(defn modal- [params & children] (defn modal- [params & children]
[:div#modal-content {:class "flex items-center justify-between pb-2"} [:div#modal-content {:class ""}
children]) children])
(defn modal-card- [params header content footer] (defn modal-card- [params header content footer]
[:div#modal-card params [:div#modal-card params
[:div {:class "relative bg-white rounded-lg shadow dark:bg-gray-700 dark:text-white modal-content"} [:div {:class "bg-white rounded-lg shadow dark:bg-gray-700 dark:text-white modal-content w-full"}
[:div {:class "flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600"} header] [:div {:class "flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600"} header]
[:div {:class "p-6 space-y-6"} [:div {:class "p-6 space-y-6 overflow-scroll "}
content] content]
[:div footer]]]) (when footer [:div {:class "p-4 "} footer])]])
;; fade-in-settle slide-up-settle duration-300 transition-all ;; fade-in-settle slide-up-settle duration-300 transition-all

View File

@@ -77,13 +77,12 @@ c.clearChoices();
(str (:url params) "?q=")) (str (:url params) "?q="))
:value {:value ((:value-fn params first) (:value params)) :label ((:content-fn params second) (:value params))} :value {:value ((:value-fn params first) (:value params)) :label ((:content-fn params second) (:value params))}
:search "" :search ""
:active 0 :active -1
:elements (if (:value params) :elements (if ((:value-fn params first) (:value params))
[{:value ((:value-fn params first) (:value params)) :label ((:content-fn params second) (:value params))}] [{:value ((:value-fn params first) (:value params)) :label ((:content-fn params second) (:value params))}]
[])}) [])})
:x-modelable "value.value" :x-modelable "value.value"
:x-model (:x-model params) :x-model (:x-model params)}
}
[:a {:class (-> (hh/add-class (or (:class params) "") default-input-classes) [:a {:class (-> (hh/add-class (or (:class params) "") default-input-classes)
(hh/add-class "cursor-pointer")) (hh/add-class "cursor-pointer"))
"@click.prevent" "open = !open;" "@click.prevent" "open = !open;"
@@ -109,7 +108,6 @@ c.clearChoices();
[:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"} [:div {:class "w-3 h-3 m-1 inline ml-1 justify-self-end text-gray-500 self-center"}
svg/drop-down]]] svg/drop-down]]]
[:ul.dropdown-contents {:class "absolute bg-gray-50 dark:bg-gray-600 rounded-lg shadow-lg py-1 w-max z-10 mt-1" [:ul.dropdown-contents {:class "absolute bg-gray-50 dark:bg-gray-600 rounded-lg shadow-lg py-1 w-max z-10 mt-1"
"@keydown.escape" "open = false; value = {value: '', label: '' }" "@keydown.escape" "open = false; value = {value: '', label: '' }"
"x-transition:enter" "ease-[cubic-bezier(.3,2.3,.6,1)] duration-200" "x-transition:enter" "ease-[cubic-bezier(.3,2.3,.6,1)] duration-200"

View File

@@ -206,7 +206,7 @@
(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes (com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
:user-edit-dialog :user-edit-dialog
:db/id (:db/id entity))) :db/id (:db/id entity)))
:hx-target "#modal-holder" :hx-target "#modal-content"
:hx-swap "outerHTML"} :hx-swap "outerHTML"}
svg/pencil)]) svg/pencil)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes :breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
@@ -265,7 +265,7 @@
(html-response (html-response
(row* identity user {:flash? true}) (row* identity user {:flash? true})
:headers {"hx-trigger" "closeModal" :headers {"hx-trigger" "modalclose"
"hx-retarget" (format "#user-table tr[data-id=\"%d\"]" (:db/id user))}))) "hx-retarget" (format "#user-table tr[data-id=\"%d\"]" (:db/id user))})))
(defn user-edit-dialog [request] (defn user-edit-dialog [request]
@@ -315,7 +315,8 @@
[:div#form-errors [:span.error-content]] [:div#form-errors [:span.error-content]]
(com/button {:color :primary :type "submit"} (com/button {:color :primary :type "submit"}
"Save")] "Save")]
[:div])]])))) [:div])]])
:headers {"hx-trigger" "modalopen"})))
(def key->handler (def key->handler
(apply-middleware-to-all-handlers (apply-middleware-to-all-handlers