Made error page look pretty good

This commit is contained in:
2023-10-30 20:47:55 -07:00
parent a5672d8954
commit 3d5c307760
6 changed files with 24 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@@ -210,10 +210,7 @@
(com/modal ;; TODO we need a cleaner way to have forms that wrap the whole. In this cas (com/modal ;; TODO we need a cleaner way to have forms that wrap the whole. In this cas
{} {}
[:form {:hx-post (bidi/path-for ssr-routes/only-routes :admin-job-start) [:form {:hx-post (bidi/path-for ssr-routes/only-routes :admin-job-start)
:class "h-full w-full" :class "h-full w-full"}
"x-on:htmx:response-error" "unexpectedError=true"
"x-on:htmx:before-request" "unexpectedError=false"
:x-data (hx/json {:unexpectedError false})}
[:fieldset {:class "hx-disable h-full w-full"} [:fieldset {:class "hx-disable h-full w-full"}
(com/modal-card {} (com/modal-card {}
[:div.m-2 "New job"] [:div.m-2 "New job"]
@@ -243,8 +240,7 @@
[:div#sub-form (subform* {:name (fc/with-field :name (fc/field-value))}) ]] [:div#sub-form (subform* {:name (fc/with-field :name (fc/field-value))}) ]]
[:div [:div
[:div#5xx-error.bg-red-100.mb-2.p-1 {:x-show "unexpectedError"}
"An unexpected error has occured."]
(com/form-errors {:errors (:errors fc/*form-errors*)}) (com/form-errors {:errors (:errors fc/*form-errors*)})
(com/validated-save-button {:errors form-errors} "Run job")])]])))) (com/validated-save-button {:errors form-errors} "Run job")])]]))))

View File

@@ -53,7 +53,8 @@
[clojure.set :as set] [clojure.set :as set]
[clojure.string :as str] [clojure.string :as str]
[datomic.api :as dc] [datomic.api :as dc]
[malli.core :as mc])) [malli.core :as mc]
[auto-ap.logging :as alog]))
(defn filters [request] (defn filters [request]
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms" [:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
@@ -777,9 +778,9 @@
(-> t :transaction/client :client/locations))))]) (-> t :transaction/client :client/locations))))])
transactions) transactions)
identity) identity)
(doseq [n transactions] (doseq [n transactions]
(solr/touch-with-ledger (:db/id n))) (solr/touch-with-ledger (:db/id n)))
(html-response [:div] (html-response [:div]
:headers {"hx-trigger" (hx/json {:modalclose "" :headers {"hx-trigger" (hx/json {:modalclose ""
:notification (format "Successfully coded %d of %d transactions!" :notification (format "Successfully coded %d of %d transactions!"

View File

@@ -6,7 +6,9 @@
(defn modal- [params & children] (defn modal- [params & children]
[:div (-> params [:div (-> params
(assoc "@click.outside" "open=false" (assoc "@click.outside" "open=false"
:x-data (hx/json {:index 0 :hidingIndex -1}) :x-data (hx/json {:index 0 :hidingIndex -1 :unexpectedError false})
"x-on:htmx:response-error" "unexpectedError=true"
"x-on:htmx:before-request" "unexpectedError=false"
:x-ref "modalStack" :x-ref "modalStack"
"@modalnext" "@modalnext"
"$refs.modalStack.children[index].setAttribute('x-transition:leave-end', '-translate-x-full scale-0 opacity-0' ); "$refs.modalStack.children[index].setAttribute('x-transition:leave-end', '-translate-x-full scale-0 opacity-0' );
@@ -43,7 +45,12 @@
#_[:div.bg-green-300.w-full.h-64 #_[:div.bg-green-300.w-full.h-64
"hello"] "hello"]
content] content]
(when footer [:div {:class "p-4 shrink-0"} footer])]]) (when footer [:div {:class "p-4"}
[:span.items-center.bg-red-100.text-red-800.text-xs.font-medium.mb-2.p-1.rounded-full.inline-flex (hx/alpine-appear {:x-show "unexpectedError" :class "dark:bg-red-900 dark:text-red-300"})
[:span {:class "w-2 h-2 mr-1 bg-red-500 rounded-full"}]
[:span.px-2.py-0.5 "An unexpected error has occured. Integreat staff have been notified."]]
[:div {:class "shrink-0"}
footer]])]])
(defn stacked-modal-card- [index params header content footer] (defn stacked-modal-card- [index params header content footer]
@@ -60,4 +67,8 @@
[:div {:class "px-6 space-y-6 overflow-y-scroll w-full shrink"} [:div {:class "px-6 space-y-6 overflow-y-scroll w-full shrink"}
content] content]
(when footer [:div {:class "p-4 shrink-0"} footer])]) (when footer [:div {:class "p-4"}
[:span.items-center.bg-red-100.text-red-800.text-xs.font-medium.mb-2.p-1.rounded-full.inline-flex (hx/alpine-appear {:x-show "unexpectedError" :class "dark:bg-red-900 dark:text-red-300"})
[:span {:class "w-2 h-2 bg-red-500 rounded-full"}]
[:span.px-2.py-0.5 "An unexpected error has occured. Integreat staff have been notified."]]
[:div {:class "shrink-0"}]footer])])

View File

@@ -10,8 +10,8 @@
"/account/typeahead" ::account-typeahead "/account/typeahead" ::account-typeahead
"/test" ::test "/test" ::test
"/new" {:get ::new-dialog} "/new" {:get ::new-dialog}
[[#"\d+" :db/id] "/edit"] ::edit-dialog ["/" [#"\d+" :db/id] "/edit"] ::edit-dialog
[[#"\d+" :db/id] "/run"] {:get ::execute-dialog ["/" [#"\d+" :db/id] "/run"] {:get ::execute-dialog
:post ::execute} :post ::execute}
"/check-badges" ::check-badges "/check-badges" ::check-badges
}) })

View File

@@ -20,13 +20,13 @@
"/client/new" :user-client-new "/client/new" :user-client-new
"/table" :user-table "/table" :user-table
"/impersonate" :user-impersonate "/impersonate" :user-impersonate
[[#"\d+" :db/id] "/edit"] {:get :user-edit-dialog}} ["/" [#"\d+" :db/id] "/edit"] {:get :user-edit-dialog}}
"/account" {"" {:get :admin-accounts "/account" {"" {:get :admin-accounts
:put :admin-account-save :put :admin-account-save
:post :admin-account-save} :post :admin-account-save}
"/table" :admin-account-table "/table" :admin-account-table
"/new" {:get :admin-account-new-dialog} "/new" {:get :admin-account-new-dialog}
[[#"\d+" :db/id] "/edit"] :admin-account-edit-dialog ["/" [#"\d+" :db/id] "/edit"] :admin-account-edit-dialog
"/override/new" :admin-account-client-override-new} "/override/new" :admin-account-client-override-new}
"/background-job" {"" {:get :admin-jobs "/background-job" {"" {:get :admin-jobs
:post :admin-job-start} :post :admin-job-start}