reimplemented import
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
|
||||
[:id :name :code :email :locations [:bank-accounts [:id :number :check-number :name :type] ]
|
||||
[:id :name :code :email :locations [:bank-accounts [:id :code :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]]]}
|
||||
@@ -64,7 +64,7 @@
|
||||
(fn [{:keys [db]} [_ token user]]
|
||||
{:graphql {:token token
|
||||
:query-obj {:venia/queries [[:client
|
||||
[:id :name :code [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :type]]]]
|
||||
[:id :name :code [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :code :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]]]}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
[clojure.string :as str])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[clojure.spec.alpha :as s]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]
|
||||
@@ -40,7 +41,7 @@
|
||||
(update :bank-accounts #(into % (map (fn [ba] (dissoc ba :is-new?)) (:new-bank-accounts edited-client))))
|
||||
(dissoc :new-bank-accounts))
|
||||
}
|
||||
[:id :name :code [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name]]]
|
||||
[: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]}})))
|
||||
@@ -81,8 +82,10 @@
|
||||
::add-new-bank-account
|
||||
(fn [{:keys [db]} _]
|
||||
(let [client (:client @(re-frame/subscribe [::subs/admin]))
|
||||
_ (println (s/explain-data ::entity/bank-account (:new-account client)))
|
||||
new-bank-account (:new-account client)
|
||||
new-bank-account (-> new-bank-account
|
||||
(update :code #(str (:code client) "-" %))
|
||||
(update :check-number #(if (seq %) (js/parseInt %) nil))
|
||||
(update :yodlee-account-id #(if (seq %) (js/parseInt %) nil))
|
||||
(assoc :is-new? true))]
|
||||
@@ -180,6 +183,18 @@
|
||||
:event ::change
|
||||
:subscription editing-client}]
|
||||
[:h2.subtitle "Add account"]
|
||||
[horizontal-field
|
||||
[:label.label "Acct code"]
|
||||
[:div.control
|
||||
[:div.field.has-addons.is-extended
|
||||
[:p.control [:a.button.is-static (:code editing-client) "-" ]]
|
||||
[:p.control
|
||||
[bind-field
|
||||
[:input.input {:type "code"
|
||||
:field [:new-account :code]
|
||||
:spec ::entity/code
|
||||
:event ::change
|
||||
:subscription editing-client}]]]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Bank"]
|
||||
@@ -240,7 +255,12 @@
|
||||
:event ::change
|
||||
:subscription editing-client}]]]
|
||||
[:div.control
|
||||
[:button.button.is-primary.is-pulled-right {:on-click (dispatch-event [::add-new-bank-account])} "Add"]]]
|
||||
[:button.button.is-primary.is-pulled-right {:on-click (dispatch-event [::add-new-bank-account])
|
||||
:disabled (if (and (s/valid? ::entity/bank-account (:new-account editing-client))
|
||||
(not ((set (map :code (:bank-accounts editing-client)))
|
||||
(str (:code editing-client) "-" (-> editing-client :new-account :code)))))
|
||||
""
|
||||
"disabled")} "Add"]]]
|
||||
|
||||
|
||||
|
||||
@@ -250,10 +270,10 @@
|
||||
[:div.control
|
||||
[:ul
|
||||
|
||||
(for [{:keys [name number check-number id]} (:bank-accounts editing-client)]
|
||||
^{:key id} [:li name])
|
||||
(for [[index {:keys [name number check-number]}] (map vector (range) (:new-bank-accounts editing-client))]
|
||||
^{:key index} [:li [:strong "* " name] [:button.button {:on-click (dispatch-event [::remove-new-bank-account index])} [:span.icon [:i.fa.fa-times]]]])]]]
|
||||
(for [{:keys [code name number check-number id]} (:bank-accounts editing-client)]
|
||||
^{:key id} [:li code ": " name])
|
||||
(for [[index {:keys [name code number check-number]}] (map vector (range) (:new-bank-accounts editing-client))]
|
||||
^{: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? editing-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])])))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user