more viewing from UI.

This commit is contained in:
Bryce Covert
2018-08-10 22:52:53 -07:00
parent cbbabb2219
commit b5ab860315
6 changed files with 39 additions and 24 deletions

View File

@@ -3,6 +3,7 @@
[auto-ap.datomic :refer [uri]])) [auto-ap.datomic :refer [uri]]))
(defn get-all [] (defn get-all []
(->> (d/q '[:find (pull ?e [*]) (->> (d/q '[:find (pull ?e [*])
:where [?e :client/name]] :where [?e :client/name]]
(d/db (d/connect uri))) (d/db (d/connect uri)))

View File

@@ -0,0 +1,16 @@
(ns auto-ap.datomic.vendors
(:require [datomic.api :as d]
[auto-ap.datomic :refer [uri]]))
(defn get-all []
(->> (d/q '[:find (pull ?e [*])
:where [?e :vendor/name]]
(d/db (d/connect uri)))
(map first)
#_(map (fn [c]
(update c :client/bank-accounts
(fn [bas]
(map (fn [ba]
(update ba :bank-account/type :db/ident ))
bas)))))))

View File

@@ -12,6 +12,7 @@
[auto-ap.db.vendors :as vendors] [auto-ap.db.vendors :as vendors]
[auto-ap.db.companies :as companies] [auto-ap.db.companies :as companies]
[auto-ap.datomic.clients :as d-clients] [auto-ap.datomic.clients :as d-clients]
[auto-ap.datomic.vendors :as d-vendors]
[auto-ap.db.users :as users] [auto-ap.db.users :as users]
[auto-ap.db.checks :as checks] [auto-ap.db.checks :as checks]
[auto-ap.routes.checks :as rchecks] [auto-ap.routes.checks :as rchecks]
@@ -40,6 +41,11 @@
:address {:type :address} :address {:type :address}
:locations {:type '(list String)} :locations {:type '(list String)}
:bank_accounts {:type '(list :bank_account)}}} :bank_accounts {:type '(list :bank_account)}}}
:contact
{:fields {:id {:type 'String}
:name {:type 'String}
:email {:type 'String}
:phone {:type 'String}}}
:bank_account :bank_account
{:fields {:id {:type 'String} {:fields {:id {:type 'String}
@@ -56,20 +62,14 @@
:state {:type 'String} :state {:type 'String}
:zip {:type 'String}}} :zip {:type 'String}}}
:vendor :vendor
{:fields {:id {:type 'Int} {:fields {:id {:type 'String}
:name {:type 'String} :name {:type 'String}
:code {:type 'String} :code {:type 'String}
:print_as {:type 'String} :print_as {:type 'String}
:primary_contact {:type 'String} :primary_contact {:type :contact}
:secondary_contact {:type :contact}
:address {:type :address} :address {:type :address}
:primary_email {:type 'String}
:primary_phone {:type 'String}
:secondary_contact {:type 'String}
:secondary_email {:type 'String}
:secondary_phone {:type 'String}
:default_expense_account {:type 'Int} :default_expense_account {:type 'Int}
:invoice_reminder_schedule {:type 'String}}} :invoice_reminder_schedule {:type 'String}}}
@@ -453,10 +453,9 @@
(defn get-company [context args value] (defn get-company [context args value]
(println "GETTING COMPANY" (:id context)) (println "GETTING COMPANY" (:id context))
(doto (->graphql (->graphql
(filter #(can-see-company? (:id context) %) (filter #(can-see-company? (:id context) %)
(d-clients/get-all))) (d-clients/get-all))))
println))
(defn join-companies [users] (defn join-companies [users]
(let [companies (by :id (companies/get-all))] (let [companies (by :id (companies/get-all))]
@@ -478,7 +477,7 @@
(defn get-vendor [context args value] (defn get-vendor [context args value]
(->graphql (->graphql
(vendors/get-all))) (d-vendors/get-all)))
(defn print-checks [context args value] (defn print-checks [context args value]
@@ -555,4 +554,4 @@
(query id q nil )) (query id q nil ))
([id q v] ([id q v]
(println "executing graphql query" id q v) (println "executing graphql query" id q v)
(simplify (execute schema q v {:id id})))) (time (simplify (execute schema q v {:id id})))))

View File

@@ -40,7 +40,7 @@
[:id :name :locations [:bank-accounts [:id :number :check-number :name :type] ] [:id :name :locations [:bank-accounts [:id :number :check-number :name :type] ]
[:address [:street1 :street2 :city :state :zip]]]] [:address [:street1 :street2 :city :state :zip]]]]
[:vendor [:vendor
[:id :name :default-expense-account :primary-contact :primary-email :primary-phone :secondary-contact :secondary-email :secondary-phone :print-as :invoice-reminder-schedule :code]]]} [:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
:on-success [::received-initial]}})))) :on-success [::received-initial]}}))))
@@ -56,7 +56,7 @@
:query-obj {:venia/queries [[:company :query-obj {:venia/queries [[:company
[:id :name [:bank-accounts [:id :number :check-number :name :type]]]] [:id :name [:bank-accounts [:id :number :check-number :name :type]]]]
[:vendor [:vendor
[:id :name :default-expense-account]]]} [:id :name :default-expense-account [:primary-contact [:name :phone :email :id]] [:secondary-contact [:id :name :phone :email]] :print-as :invoice-reminder-schedule :code]]]}
:on-success [::received-initial]} :on-success [::received-initial]}
:db (assoc db :user (assoc user :token token))})) :db (assoc db :user (assoc user :token token))}))

View File

@@ -80,7 +80,7 @@
[:div.control.has-icons-left [:div.control.has-icons-left
[bind-field [bind-field
[:input.input.is-expanded {:type "text" [:input.input.is-expanded {:type "text"
:field :primary-contact :field [:primary-contact :name]
:spec ::entity/primary-contact :spec ::entity/primary-contact
:event change-event :event change-event
:subscription vendor}]] :subscription vendor}]]
@@ -92,7 +92,7 @@
[:i.fa.fa-envelope]] [:i.fa.fa-envelope]]
[bind-field [bind-field
[:input.input {:type "email" [:input.input {:type "email"
:field :primary-email :field [:primary-contact :email]
:spec ::entity/primary-email :spec ::entity/primary-email
:event change-event :event change-event
:subscription vendor}]]] :subscription vendor}]]]
@@ -100,7 +100,7 @@
[:div.control.has-icons-left [:div.control.has-icons-left
[bind-field [bind-field
[:input.input {:type "phone" [:input.input {:type "phone"
:field :primary-phone :field [:primary-contact :phone]
:spec ::entity/primary-phone :spec ::entity/primary-phone
:event change-event :event change-event
:subscription vendor}]] :subscription vendor}]]
@@ -112,7 +112,7 @@
[:div.control.has-icons-left [:div.control.has-icons-left
[bind-field [bind-field
[:input.input.is-expanded {:type "text" [:input.input.is-expanded {:type "text"
:field :secondary-contact :field [:secondary-contact :name]
:spec ::entity/secondary-contact :spec ::entity/secondary-contact
:event change-event :event change-event
:subscription vendor}]] :subscription vendor}]]
@@ -123,14 +123,14 @@
[:i.fa.fa-envelope]] [:i.fa.fa-envelope]]
[bind-field [bind-field
[:input.input {:type "email" [:input.input {:type "email"
:field :secondary-email :field [:secondary-contact :email]
:spec ::entity/secondary-email :spec ::entity/secondary-email
:event change-event :event change-event
:subscription vendor}]]] :subscription vendor}]]]
[:div.control.has-icons-left [:div.control.has-icons-left
[bind-field [bind-field
[:input.input {:type "phone" [:input.input {:type "phone"
:field :secondary-phone :field [:secondary-contact :phone]
:spec ::entity/secondary-phone :spec ::entity/secondary-phone
:event change-event :event change-event
:subscription vendor}]] :subscription vendor}]]

View File

@@ -55,7 +55,6 @@
(vec (concat [dom keys] rest)))) (vec (concat [dom keys] rest))))
#_(defn edit-dialog [] #_(defn edit-dialog []
(let [editing-vendor (:vendor @(re-frame/subscribe [::subs/admin])) (let [editing-vendor (:vendor @(re-frame/subscribe [::subs/admin]))
companies-by-id @(re-frame/subscribe [::subs/companies-by-id])] companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]