allows editing all vendors.

This commit is contained in:
Bryce
2023-05-25 09:44:30 -07:00
parent c5838e5e3a
commit ab4db8c9ff

View File

@@ -12,10 +12,7 @@
[datomic.api :as dc] [datomic.api :as dc]
[hiccup2.core :as hiccup])) [hiccup2.core :as hiccup]))
(defn cannot-overwrite? [vendor]
(some? (or (:vendor/legal-entity-1099-type vendor)
(:vendor/legal-entity-tin vendor)
(:vendor/legal-entity-tin-type vendor))))
(defn get-1099-companies [user session] (defn get-1099-companies [user session]
(let [clients (->> (dc/q '[:find ?c (let [clients (->> (dc/q '[:find ?c
@@ -179,14 +176,12 @@
(-> vendor :vendor/address :address/zip) (-> vendor :vendor/address :address/zip)
[:td "$" (Math/round amount)] [:td "$" (Math/round amount)]
[:td [:td
(if (cannot-overwrite? vendor) [:button.button {:hx-get (bidi/path-for ssr-routes/only-routes
[:a {:href "mailto:ben@integreatconsult.com"} "Contact Integreat"] :company-1099-vendor-dialog
[:button.button {:hx-get (bidi/path-for ssr-routes/only-routes :vendor-id (:db/id vendor))
:company-1099-vendor-dialog :hx-target "#modal-holder"
:vendor-id (:db/id vendor)) :hx-swap "innerHTML"}
:hx-target "#modal-holder" [:span.icon [:i.fa.fa-pencil ]]]]]])]]
:hx-swap "innerHTML"}
[:span.icon [:i.fa.fa-pencil ]]])]]])]]
[:div.container.htmx-indicator [:div.container.htmx-indicator
[:div.column.is-4.is-offset-4.has-text-centered [:div.column.is-4.is-offset-4.has-text-centered
[:div.loader.is-loading.is-active.big.is-centered]]]]) [:div.loader.is-loading.is-active.big.is-centered]]]])
@@ -214,12 +209,11 @@
:else k)) :else k))
(defn vendor-save [{:keys [form-params identity route-params] :as request}] (defn vendor-save [{:keys [form-params identity route-params] :as request}]
(when-not (cannot-overwrite? (dc/pull (dc/db conn) '[*] (Long/parseLong (:vendor-id route-params)))) @(dc/transact conn [(remove-nils
@(dc/transact conn [(remove-nils (-> (form-data->map form-params)
(-> (form-data->map form-params) (assoc :db/id (Long/parseLong (:vendor-id route-params)))
(assoc :db/id (Long/parseLong (:vendor-id route-params))) (update :vendor/legal-entity-1099-type #(some->> % not-empty (keyword "legal-entity-1099-type")))
(update :vendor/legal-entity-1099-type #(some->> % not-empty (keyword "legal-entity-1099-type"))) (update :vendor/legal-entity-tin-type #(some->> % not-empty (keyword "legal-entity-tin-type")))))])
(update :vendor/legal-entity-tin-type #(some->> % not-empty (keyword "legal-entity-tin-type")))))]))
(html-response (html-response
(table request :flash-id (Long/parseLong (:vendor-id route-params))))) (table request :flash-id (Long/parseLong (:vendor-id route-params)))))