editing clients has started.
This commit is contained in:
@@ -117,6 +117,10 @@
|
||||
:db/valueType :db.type/string
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "A client's human-friendly name"}
|
||||
{:db/ident :client/email
|
||||
:db/valueType :db.type/string
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "hello@example.com"}
|
||||
{:db/ident :client/code
|
||||
:db/valueType :db.type/string
|
||||
:db/unique :db.unique/identity
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
(defn get-all []
|
||||
|
||||
(->> (d/q '[:find (pull ?e [*])
|
||||
(->> (d/q '[:find (pull ?e [* {:client/address [*]}])
|
||||
:where [?e :client/name]]
|
||||
(d/db (d/connect uri)))
|
||||
(map first)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.graphql.users :as gq-users]
|
||||
[auto-ap.graphql.clients :as gq-clients]
|
||||
[auto-ap.graphql.vendors :as gq-vendors]
|
||||
[auto-ap.graphql.checks :as gq-checks]
|
||||
[auto-ap.graphql.expense-accounts :as expense-accounts]
|
||||
@@ -245,6 +246,21 @@
|
||||
:invoice_payment_amount {:fields {:invoice_id {:type :id}
|
||||
:amount {:type 'Float}}}
|
||||
|
||||
:edit_client {:fields {:id {:type :id}
|
||||
:name {:type 'String}
|
||||
:email {:type 'String}
|
||||
:address {:type :add_address}
|
||||
:locations {:type '(list String)}
|
||||
:bank_accounts {:type '(list :edit_bank_account)}}}
|
||||
:edit_bank_account
|
||||
{:fields {:id {:type :id }
|
||||
:type {:type :bank_account_type}
|
||||
:number {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:name {:type 'String}
|
||||
:bank_code {:type 'String}
|
||||
:bank_name {:type 'String}
|
||||
:yodlee_account_id {:type 'Int}}}
|
||||
:edit_user
|
||||
{:fields {:id {:type :id}
|
||||
:name {:type 'String}
|
||||
@@ -322,6 +338,10 @@
|
||||
:args {:edit_user {:type :edit_user}}
|
||||
:resolve :mutation/edit-user}
|
||||
|
||||
:edit_client {:type :client
|
||||
:args {:edit_client {:type :edit_client}}
|
||||
:resolve :mutation/edit-client}
|
||||
|
||||
:upsert_vendor {:type :vendor
|
||||
:args {:vendor {:type :add_vendor}}
|
||||
:resolve :mutation/upsert-vendor}
|
||||
@@ -392,10 +412,7 @@
|
||||
:limit Integer/MAX_VALUE))))
|
||||
|
||||
|
||||
(defn get-client [context args value]
|
||||
(->graphql
|
||||
(filter #(can-see-client? (:id context) %)
|
||||
(d-clients/get-all))))
|
||||
|
||||
|
||||
(defn get-user [context args value]
|
||||
(assert-admin (:id context))
|
||||
@@ -429,13 +446,14 @@
|
||||
:get-payment-page gq-checks/get-payment-page
|
||||
:get-transaction-page gq-transactions/get-transaction-page
|
||||
|
||||
:get-client get-client
|
||||
:get-client gq-clients/get-client
|
||||
:get-user get-user
|
||||
:mutation/add-handwritten-check gq-checks/add-handwritten-check
|
||||
:mutation/print-checks print-checks
|
||||
:mutation/edit-user gq-users/edit-user
|
||||
:mutation/add-invoice gq-invoices/add-invoice
|
||||
:mutation/edit-invoice gq-invoices/edit-invoice
|
||||
:mutation/edit-client gq-clients/edit-client
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/void-invoice gq-invoices/void-invoice
|
||||
:mutation/void-payment gq-checks/void-check
|
||||
|
||||
@@ -320,8 +320,6 @@
|
||||
base-payment (base-payment [invoice] (:invoice/vendor invoice)
|
||||
(:invoice/client invoice)
|
||||
bank-account :payment-type/check 0 {(:invoice_id args) (:amount args)})]
|
||||
|
||||
|
||||
@(d/transact (d/connect uri)
|
||||
(into [(assoc base-payment
|
||||
:payment/type :payment-type/check
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
|
||||
[:id :name :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||
[:id :name :email :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||
[:address [:street1 :street2 :city :state :zip]]]]
|
||||
[:vendor
|
||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||
@@ -60,7 +60,7 @@
|
||||
(fn [{:keys [db]} [_ token user]]
|
||||
{:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
[:id :name [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||
[:id :name [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||
[:vendor
|
||||
[:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
(re-frame/reg-event-fx
|
||||
::edit
|
||||
(fn [{:keys [db]} [_ client-id]]
|
||||
(println "EDITING")
|
||||
{:dispatch [::events/modal-status :auto-ap.views.pages.admin.clients/edit {:visible? true}]
|
||||
:db (assoc-in db [:admin :client]
|
||||
(get (:clients db) client-id))}))
|
||||
@@ -17,17 +18,20 @@
|
||||
(re-frame/reg-event-fx
|
||||
::save
|
||||
(fn [{:keys [db]} _]
|
||||
(println "saving")
|
||||
(let [edited-client (-> (get-in db [:admin :clients])
|
||||
(dissoc :location))]
|
||||
|
||||
{:db (assoc-in db [:admin :client :saving?] true)
|
||||
:http {:method :put
|
||||
:token (:user db)
|
||||
:body (pr-str edited-client)
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/clients/" (:id edited-client))
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
:graphql
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "EditClient"}
|
||||
:venia/queries [{:query/data [:upsert-client
|
||||
{:client edited-client}
|
||||
[:id :name]
|
||||
]}]}
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save-complete
|
||||
|
||||
@@ -23,17 +23,18 @@
|
||||
::save
|
||||
(fn [{:keys [db]} _]
|
||||
(let [edited-client (-> (get-in db [:admin :client])
|
||||
(dissoc :location)
|
||||
(dissoc :new-account))]
|
||||
|
||||
(dissoc :location))]
|
||||
{:db (assoc-in db [:admin :client :saving?] true)
|
||||
:http {:method :put
|
||||
:token (:user db)
|
||||
:body (pr-str edited-client)
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/clients/" (:id edited-client))
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
:graphql
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "EditClient"}
|
||||
:venia/queries [{:query/data [:edit-client
|
||||
{:edit-client edited-client}
|
||||
[:id :name]
|
||||
]}]}
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save-complete
|
||||
@@ -151,6 +152,7 @@
|
||||
^{:key location} [:li location ])]]]
|
||||
[:h2.subtitle "Address"]
|
||||
|
||||
|
||||
[address-field {:field [:address]
|
||||
:event ::change
|
||||
:subscription editing-client}]
|
||||
|
||||
Reference in New Issue
Block a user