Adds cleanup to the company 1099 page to make loading clearer.

This commit is contained in:
2023-01-23 20:12:04 -08:00
parent 63ea83af9b
commit 344841420a
4 changed files with 261 additions and 243 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -182,3 +182,15 @@ tbody tr.live-added {
background-color: $primary;
cursor: pointer;
}
.htmx-indicator.button {
opacity: 1.0 !important
}
.htmx-request .button.htmx-indicator {
@extend .is-loading
}
.htmx-request.button.htmx-indicator {
@extend .is-loading
}

View File

@@ -137,54 +137,58 @@
[:button.modal-close.is-large {"_" (hiccup/raw "on click remove <#modal-holder div/>")}]])
(defn table [{:keys [identity session]} & {:keys [flash-id]}]
[:table#vendor-table.table.grid.compact.is-fullwidth {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-table
:request-method :get)
:hx-trigger "clientSelected from:body"
:hx-swap "outerHTML"}
[:thead
[:tr
[:th {:style {:width "5em"}}"Client"]
[:th "Vendor Name"]
[:th "Name"]
[:th {:style {:width "9em"}} "1099 Type"]
[:th {:style {:width "8em"}} "TIN"]
[:th "Address"]
[:th "Amount Paid"]
[:th {:style {:width "10em"}}]
]]
[:tbody
(for [[client vendor amount] (get-1099-companies identity session)]
[:tr (when (= flash-id
(:db/id vendor))
{:class "live-added"})
[:td (:client/code client)]
[:td (:vendor/name vendor)]
[:td (or (-> vendor :vendor/legal-entity-name not-empty)
(str (-> vendor :vendor/legal-entity-first-name) " "
(-> vendor :vendor/legal-entity-middle-name) " "
(-> vendor :vendor/legal-entity-last-name)))]
[:td (some-> vendor :vendor/legal-entity-1099-type :db/ident name)] " "
[:td
(some-> vendor :vendor/legal-entity-tin-type :db/ident name) " "
(-> vendor :vendor/legal-entity-tin)]
[:td
(-> vendor :vendor/address :address/street1) " "
(-> vendor :vendor/address :address/street2) " "
(-> vendor :vendor/address :address/city) " "
(-> vendor :vendor/address :address/state) " "
(-> vendor :vendor/address :address/zip)
[:td "$" (Math/round amount)]
[:div#vendor-table {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-table
:request-method :get)
:hx-trigger "clientSelected from:body"
"_" (hiccup/raw "on htmx:beforeRequest remove <table/> in me")
:hx-swap "outerHTML swap:300ms"}
[:table.table.grid.compact.is-fullwidth
[:thead
[:tr
[:th {:style {:width "5em"}}"Client"]
[:th "Vendor Name"]
[:th "Name"]
[:th {:style {:width "9em"}} "1099 Type"]
[:th {:style {:width "8em"}} "TIN"]
[:th "Address"]
[:th "Amount Paid"]
[:th {:style {:width "10em"}}]
]]
[:tbody
(for [[client vendor amount] (get-1099-companies identity session)]
[:tr (when (= flash-id
(:db/id vendor))
{:class "live-added"})
[:td (:client/code client)]
[:td (:vendor/name vendor)]
[:td (or (-> vendor :vendor/legal-entity-name not-empty)
(str (-> vendor :vendor/legal-entity-first-name) " "
(-> vendor :vendor/legal-entity-middle-name) " "
(-> vendor :vendor/legal-entity-last-name)))]
[:td (some-> vendor :vendor/legal-entity-1099-type :db/ident name)] " "
[:td
(if (cannot-overwrite? vendor)
[:a {:href "mailto:ben@integreatconsult.com"} "Contact Integreat"]
[:button.button {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-dialog
:vendor-id (:db/id vendor))
:hx-target "#modal-holder"
:hx-swap "innerHTML"}
[:span.icon [:i.fa.fa-pencil ]]])]]])]])
(some-> vendor :vendor/legal-entity-tin-type :db/ident name) " "
(-> vendor :vendor/legal-entity-tin)]
[:td
(-> vendor :vendor/address :address/street1) " "
(-> vendor :vendor/address :address/street2) " "
(-> vendor :vendor/address :address/city) " "
(-> vendor :vendor/address :address/state) " "
(-> vendor :vendor/address :address/zip)
[:td "$" (Math/round amount)]
[:td
(if (cannot-overwrite? vendor)
[:a {:href "mailto:ben@integreatconsult.com"} "Contact Integreat"]
[:button.button {:hx-get (bidi/path-for ssr-routes/only-routes
:company-1099-vendor-dialog
:vendor-id (:db/id vendor))
:hx-target "#modal-holder"
:hx-swap "innerHTML"}
[:span.icon [:i.fa.fa-pencil ]]])]]])]]
[:div.container.htmx-indicator
[:div.column.is-4.is-offset-4.has-text-centered
[:div.loader.is-loading.is-active.big.is-centered]]]])
(defn form-data->map [form-data]
(reduce-kv
@@ -341,9 +345,7 @@
[:option {:value "none" :selected (= (-> vendor :vendor/legal-entity-1099-type :db/ident) :legal-entity-1099-type/none)} "None"]
[:option {:value "misc" :selected (= (-> vendor :vendor/legal-entity-1099-type :db/ident) :legal-entity-1099-type/misc)} "Misc"]
[:option {:value "landlord" :selected (= (-> vendor :vendor/legal-entity-1099-type :db/ident) :legal-entity-1099-type/landlord)} "Landlord"]]]]]]]]]
[:button.button.is-primary "Save"])])))
[:button.button.is-primary.htmx-indicator "Save"])])))
(defn vendor-table [request]
(html-response (table request)))
@@ -356,8 +358,8 @@
:company-1099-vendor-table
:request-method :get)
:hx-trigger "load, clientSelected from:body"
:hx-swap "outerHTML"}
[:div.container
:hx-swap "outerHTML swap:400ms"}
[:div.container.htmx-indicator
[:div.column.is-4.is-offset-4.has-text-centered
[:div.loader.is-loading.is-active.big.is-centered]]]]]
[:div