Allows VS to edit all vendors.

This commit is contained in:
Bryce
2023-05-25 08:54:26 -07:00
parent d6d8a25624
commit 0c8bcc55b6

View File

@@ -12,11 +12,6 @@
[datomic.api :as dc]
[iol-ion.query :refer [can-see-client?]]))
(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]
(let [clients (->> (dc/q '[:find ?c
:in $ ?user
@@ -171,14 +166,12 @@
"Paid $" (Math/round amount)))
(com/data-grid-right-stack-cell
{}
(if (cannot-overwrite? vendor)
[:div (com/link {:href "mailto:ben@integreatconsult.com"} "Contact Integreat")]
(com/icon-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 "outerHTML"}
svg/pencil)))))
(com/icon-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 "outerHTML"}
svg/pencil))))
(defn table* [{:keys [identity session query-params hx-query-params]} & {:keys [flash-id]}]
(let [start (or (some-> (or (get query-params "start") (get hx-query-params "start")) not-empty (Long/parseLong ))
0)
@@ -216,12 +209,11 @@
(com/data-grid-header {})]})))
(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
(-> (form-data->map form-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-tin-type #(some->> % not-empty (keyword "legal-entity-tin-type")))))]))
@(dc/transact conn [(remove-nils
(-> (form-data->map form-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-tin-type #(some->> % not-empty (keyword "legal-entity-tin-type")))))])
(html-response
(table* request :flash-id (Long/parseLong (:vendor-id route-params)))
:headers {"hx-trigger" "closeModal"}))