This commit is contained in:
Bryce Covert
2019-12-21 14:57:48 -08:00
14 changed files with 332 additions and 50 deletions

View File

@@ -25,11 +25,17 @@
id (or (:db/id client) "new-client")
_ (println id)
_ (println edit_client)
_ (when client
@(d/transact (d/connect uri)
(into
(mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client))
(mapv (fn [m] [:db/retract (:db/id client) :client/matches m]) (:client/matches client)))))
transactions [(remove-nils {:db/id id
:client/code (if (str/blank? (:client/code client))
(:code edit_client)
(:client/code client))
:client/name (:name edit_client)
:client/matches (:matches edit_client)
:client/email (:email edit_client)
:client/locations (filter identity (:locations edit_client))
:client/location-matches (->> (:location_matches edit_client)
@@ -65,7 +71,16 @@
})]
result @(d/transact (d/connect uri) transactions)]
(println result "ID" id)
(-> result :tempids (get id) (or id) d-clients/get-by-id ->graphql)))
(-> result :tempids (get id) (or id) d-clients/get-by-id
(update :client/location-matches
(fn [lms]
(mapcat (fn [lm]
(map (fn [m]
{:location-match/match m
:location-match/location (:location-match/location lm)})
(:location-match/matches lm)))
lms)))
->graphql)))
(defn get-client [context args value]