side panel work.
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
(def integreat-schema
|
(def integreat-schema
|
||||||
{
|
{
|
||||||
:scalars {:id {
|
:scalars {:id {
|
||||||
:parse (schema/as-conformer #(Long/parseLong %))
|
:parse (schema/as-conformer #(when % (Long/parseLong %)))
|
||||||
:serialize (schema/as-conformer #(.toString %))}
|
:serialize (schema/as-conformer #(.toString %))}
|
||||||
:ident {:parse (schema/as-conformer (fn [x] {:db/ident x}))
|
:ident {:parse (schema/as-conformer (fn [x] {:db/ident x}))
|
||||||
:serialize (schema/as-conformer #(or (:ident %) (:db/ident %) %))}}
|
:serialize (schema/as-conformer #(or (:ident %) (:db/ident %) %))}}
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
{:fields {:id {:type :id }
|
{:fields {:id {:type :id }
|
||||||
:type {:type :bank_account_type}
|
:type {:type :bank_account_type}
|
||||||
:number {:type 'String}
|
:number {:type 'String}
|
||||||
|
:routing {:type 'String}
|
||||||
:code {:type 'String}
|
:code {:type 'String}
|
||||||
:check_number {:type 'Int}
|
:check_number {:type 'Int}
|
||||||
:name {:type 'String}
|
:name {:type 'String}
|
||||||
|
|||||||
@@ -12,15 +12,9 @@
|
|||||||
(defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value]
|
(defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
|
|
||||||
(let [client (d-clients/get-by-id (:id edit_client))
|
(let [client (when (:id edit_client) (d-clients/get-by-id (:id edit_client)))
|
||||||
#_#_new-clients (set (map #(Long/parseLong %) (:clients edit_user)))
|
id (or (:db/id client) "new-client")
|
||||||
#_#_clients-to-remove (->> (:user/clients user)
|
transactions [(remove-nils {:db/id id
|
||||||
(map :db/id)
|
|
||||||
(filter #(not (new-clients %)) ))]
|
|
||||||
|
|
||||||
@(d/transact (d/connect uri)
|
|
||||||
|
|
||||||
(doto (-> [(remove-nils {:db/id (:db/id client)
|
|
||||||
:client/code (if (str/blank? (:client/code client))
|
:client/code (if (str/blank? (:client/code client))
|
||||||
(:code edit_client)
|
(:code edit_client)
|
||||||
(:client/code client))
|
(:client/code client))
|
||||||
@@ -51,12 +45,8 @@
|
|||||||
) (:bank_accounts edit_client))
|
) (:bank_accounts edit_client))
|
||||||
|
|
||||||
})]
|
})]
|
||||||
#_(into (map (fn [c] [:db/retract (:db/id user) :user/clients c]) clients-to-remove)))
|
result @(d/transact (d/connect uri) transactions)]
|
||||||
clojure.pprint/pprint))
|
(-> result :tempids (get id) d-clients/get-by-id ->graphql)))
|
||||||
|
|
||||||
(doto (->graphql
|
|
||||||
(d-clients/get-by-id (:id edit_client)))
|
|
||||||
println)))
|
|
||||||
|
|
||||||
|
|
||||||
(defn get-client [context args value]
|
(defn get-client [context args value]
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
:is-empty #(= % "")))))
|
:is-empty #(= % "")))))
|
||||||
|
|
||||||
|
|
||||||
(s/def ::client (s/keys :req-un [::name]
|
(s/def ::client (s/keys :req-un [::name ::code]
|
||||||
:opt-un [::email
|
:opt-un [::email
|
||||||
::address
|
::address
|
||||||
::locations
|
::locations
|
||||||
|
|||||||
@@ -43,7 +43,28 @@
|
|||||||
{:edit-client
|
{:edit-client
|
||||||
;; TODO - hard code fields we want
|
;; TODO - hard code fields we want
|
||||||
(-> edited-client
|
(-> edited-client
|
||||||
(update :bank-accounts #(into % (map (fn [ba] (dissoc ba :is-new?)) (:new-bank-accounts edited-client))))
|
(update :bank-accounts #(seq (into % (map (fn [ba] (dissoc ba :is-new?)) (:new-bank-accounts edited-client)))))
|
||||||
|
(dissoc :new-bank-accounts)
|
||||||
|
)}
|
||||||
|
[:id :name :code :email [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing]]]]}]}
|
||||||
|
:on-success [::save-complete]
|
||||||
|
:on-error [::save-error]}})))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::save-new-client
|
||||||
|
(fn [{:keys [db]} _]
|
||||||
|
(let [new-client (-> (:new-client @(re-frame/subscribe [::subs/admin]))
|
||||||
|
(dissoc :location))]
|
||||||
|
{:db (assoc-in db [:admin :client :saving?] true)
|
||||||
|
:graphql
|
||||||
|
{:token (-> db :user)
|
||||||
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
|
:operation/name "EditClient"}
|
||||||
|
:venia/queries [{:query/data [:edit-client
|
||||||
|
{:edit-client
|
||||||
|
;; TODO - hard code fields we want
|
||||||
|
(-> new-client
|
||||||
|
(update :bank-accounts #(seq (into % (map (fn [ba] (dissoc ba :is-new?)) (:new-bank-accounts new-client)))))
|
||||||
(dissoc :new-bank-accounts))
|
(dissoc :new-bank-accounts))
|
||||||
}
|
}
|
||||||
[:id :name :code :email [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing]]]
|
[:id :name :code :email [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing]]]
|
||||||
@@ -480,7 +501,11 @@
|
|||||||
(for [[index {:keys [name code number check-number]}] (map vector (range) (:new-bank-accounts new-client))]
|
(for [[index {:keys [name code number check-number]}] (map vector (range) (:new-bank-accounts new-client))]
|
||||||
^{:key index} [:li [:strong "* " code ": " name] [:button.button {:on-click (dispatch-event [::remove-new-bank-account index])} [:span.icon [:i.fa.fa-times]]]])]]]]
|
^{:key index} [:li [:strong "* " code ": " name] [:button.button {:on-click (dispatch-event [::remove-new-bank-account index])} [:span.icon [:i.fa.fa-times]]]])]]]]
|
||||||
|
|
||||||
(when (:saving? new-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]]))
|
#_(when (:saving? new-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])
|
||||||
|
[:submit.button.is-large.is-primary {:disabled (if (s/valid? ::entity/client new-client)
|
||||||
|
""
|
||||||
|
"disabled")
|
||||||
|
:on-click (dispatch-event [::save-new-client])} "Save"]]]))
|
||||||
|
|
||||||
(defn admin-clients-page []
|
(defn admin-clients-page []
|
||||||
(let [adding-client? @(re-frame/subscribe [::subs/admin])]
|
(let [adding-client? @(re-frame/subscribe [::subs/admin])]
|
||||||
|
|||||||
Reference in New Issue
Block a user