a lot of progress towards unification.
This commit is contained in:
@@ -84,7 +84,8 @@
|
|||||||
:jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
|
:jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
|
||||||
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
|
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
|
||||||
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
|
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
|
||||||
[reagent "0.7.0"]
|
[reagent "0.7.0" ]
|
||||||
|
[cljsjs/react-transition-group "2.4.0-0"]
|
||||||
[re-frame "0.10.2"]
|
[re-frame "0.10.2"]
|
||||||
[com.andrewmcveigh/cljs-time "0.5.2"]]}}
|
[com.andrewmcveigh/cljs-time "0.5.2"]]}}
|
||||||
|
|
||||||
|
|||||||
@@ -602,7 +602,11 @@
|
|||||||
([id q v]
|
([id q v]
|
||||||
(println "executing graphql query" id q v)
|
(println "executing graphql query" id q v)
|
||||||
(try
|
(try
|
||||||
(time (simplify (execute schema q v {:id id})))
|
(let [result (time (simplify (execute schema q v {:id id})))]
|
||||||
|
(when (seq (:errors result))
|
||||||
|
(throw (ex-info "GraphQL error" {:result result})))
|
||||||
|
result)
|
||||||
|
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(if-let [v (:validation-error (ex-data e))]
|
(if-let [v (:validation-error (ex-data e))]
|
||||||
(println "validation error" v)
|
(println "validation error" v)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
:in ['$ '?code]
|
:in ['$ '?code]
|
||||||
:where ['[?id :client/code ?code]]}
|
:where ['[?id :client/code ?code]]}
|
||||||
:args [(d/db (d/connect uri)) code]}))
|
:args [(d/db (d/connect uri)) code]}))
|
||||||
(throw (ex-info "Client is not unique" {:validation-error "Client is not unique"}))))
|
(throw (ex-info "Client is not unique" {:validation-error (str "Client code '" code "' is not unique.")}))))
|
||||||
|
|
||||||
(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))
|
||||||
|
|||||||
@@ -21,7 +21,15 @@
|
|||||||
:body (pr-str (ql/query (:identity r) (query-params "query") variables ))
|
:body (pr-str (ql/query (:identity r) (query-params "query") variables ))
|
||||||
:headers {"Content-Type" "application/edn"}})
|
:headers {"Content-Type" "application/edn"}})
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
{:status 400
|
(if-let [result (:result (ex-data e))]
|
||||||
:body (pr-str {:data (merge {:message (.getMessage e)} (ex-data e))})
|
{:status 400
|
||||||
:headers {"Content-Type" "application/edn"}}))))
|
:body (pr-str result)
|
||||||
|
:headers {"Content-Type" "application/edn"}}
|
||||||
|
(if-let [message (:validation-error (ex-data e) )]
|
||||||
|
{:status 400
|
||||||
|
:body (pr-str {:errors [(merge {:message message} (ex-data e))]})
|
||||||
|
:headers {"Content-Type" "application/edn"}}
|
||||||
|
{:status 500
|
||||||
|
:body (pr-str {:errors [(merge {:message (.getMessage e)} (ex-data e))]})
|
||||||
|
:headers {"Content-Type" "application/edn"}}))))))
|
||||||
wrap-secure))
|
wrap-secure))
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
(when on-error
|
(when on-error
|
||||||
(->> response
|
(->> response
|
||||||
:body
|
:body
|
||||||
:data
|
:errors
|
||||||
(dates->date-times)
|
(dates->date-times)
|
||||||
(conj on-error)
|
(conj on-error)
|
||||||
(re-frame/dispatch)))
|
(re-frame/dispatch)))
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
(ns auto-ap.views.components.layouts
|
(ns auto-ap.views.components.layouts
|
||||||
(:require
|
(:require
|
||||||
|
[cljsjs.react-transition-group]
|
||||||
|
[reagent.core :as reagent]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
@@ -8,7 +10,8 @@
|
|||||||
[auto-ap.views.utils :refer [active-when active-when= login-url dispatch-event]]
|
[auto-ap.views.utils :refer [active-when active-when= login-url dispatch-event]]
|
||||||
|
|
||||||
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]))
|
[auto-ap.views.components.vendor-dialog :refer [vendor-dialog]]))
|
||||||
|
(def css-transition-group
|
||||||
|
(reagent/adapt-react-class js/ReactTransitionGroup.CSSTransition))
|
||||||
(defn login-dropdown []
|
(defn login-dropdown []
|
||||||
(let [user (re-frame/subscribe [::subs/user])
|
(let [user (re-frame/subscribe [::subs/user])
|
||||||
menu (re-frame/subscribe [::subs/menu])]
|
menu (re-frame/subscribe [::subs/menu])]
|
||||||
@@ -82,7 +85,16 @@
|
|||||||
[:a {:class "icon", :href "https://github.com/dansup/bulma-templates"}
|
[:a {:class "icon", :href "https://github.com/dansup/bulma-templates"}
|
||||||
[:i {:class "fa fa-github"}]]]]]])
|
[:i {:class "fa fa-github"}]]]]]])
|
||||||
|
|
||||||
(defn side-bar-layout [{:keys [side-bar main ap bottom right-side-bar]}]
|
(defn appearing-side-bar [{:keys [visible?]} & children ]
|
||||||
|
(let [final-state (reagent/atom visible?)]
|
||||||
|
(fn [{:keys [visible?]} & children]
|
||||||
|
[css-transition-group {:in visible? :class-names {:exitDone "bounce animated" :exit "fadeOutRight animated" :enter "fadeInRight animated"} :timeout 300 :onEnter (fn [] (reset! final-state true )) :onExited (fn [] (reset! final-state false))}
|
||||||
|
(if (or @final-state visible?)
|
||||||
|
[:div.aside
|
||||||
|
[:div.sub-main children]]
|
||||||
|
[:div])])))
|
||||||
|
|
||||||
|
(defn side-bar-layout [{:keys [side-bar main ap bottom right-side-bar right-side-bar-visible?]}]
|
||||||
(let [ap @(re-frame/subscribe [::subs/active-page])
|
(let [ap @(re-frame/subscribe [::subs/active-page])
|
||||||
client @(re-frame/subscribe [::subs/client])]
|
client @(re-frame/subscribe [::subs/client])]
|
||||||
[:div
|
[:div
|
||||||
@@ -94,10 +106,7 @@
|
|||||||
[:div {:class "column messages hero is-fullheight", :id "message-feed"}
|
[:div {:class "column messages hero is-fullheight", :id "message-feed"}
|
||||||
^{:key (str "active-page-" (:name client))}
|
^{:key (str "active-page-" (:name client))}
|
||||||
[:div.inbox-messages main]]
|
[:div.inbox-messages main]]
|
||||||
(when right-side-bar
|
[appearing-side-bar {:visible? right-side-bar-visible?} right-side-bar]]
|
||||||
[:aside.fadeInRight.animated {:class "column aside is-narrow menu hero is-fullheight" :style {:animation-duration "0.75s"}}
|
|
||||||
[:div.sub-main
|
|
||||||
right-side-bar]])]
|
|
||||||
[footer]
|
[footer]
|
||||||
bottom
|
bottom
|
||||||
[:div#dz-hidden]]))
|
[:div#dz-hidden]]))
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require-macros [cljs.core.async.macros :refer [go]]
|
(:require-macros [cljs.core.async.macros :refer [go]]
|
||||||
[clojure.string :as str])
|
[clojure.string :as str])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
|
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
@@ -17,6 +18,15 @@
|
|||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
[bidi.bidi :as bidi]))
|
[bidi.bidi :as bidi]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::loading-class
|
||||||
|
(fn [db [_ x]]
|
||||||
|
(if (get-in db [::loading x])
|
||||||
|
"is-loading"
|
||||||
|
"")))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::new
|
::new
|
||||||
(fn [{:keys [db]} [_ client-id]]
|
(fn [{:keys [db]} [_ client-id]]
|
||||||
@@ -35,7 +45,9 @@
|
|||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [edited-client (-> (:client @(re-frame/subscribe [::subs/admin]))
|
(let [edited-client (-> (:client @(re-frame/subscribe [::subs/admin]))
|
||||||
(dissoc :location))]
|
(dissoc :location))]
|
||||||
{:db (assoc-in db [:admin :client :saving?] true)
|
{:db (-> db
|
||||||
|
(assoc-in [::loading ::save-client] true)
|
||||||
|
(assoc-in [:admin :client :error] nil))
|
||||||
:graphql
|
:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
@@ -56,22 +68,27 @@
|
|||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [new-client (-> (:new-client @(re-frame/subscribe [::subs/admin]))
|
(let [new-client (-> (:new-client @(re-frame/subscribe [::subs/admin]))
|
||||||
(dissoc :location))]
|
(dissoc :location))]
|
||||||
{:db (assoc-in db [:admin :client :saving?] true)
|
(if (s/valid? ::entity/client new-client)
|
||||||
:graphql
|
|
||||||
{:token (-> db :user)
|
{:db (-> db (assoc-in [::loading ::save-client] true)
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
(assoc-in [:admin :client :error] nil))
|
||||||
:operation/name "EditClient"}
|
:graphql
|
||||||
:venia/queries [{:query/data [:edit-client
|
{:token (-> db :user)
|
||||||
{:edit-client
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
;; TODO - hard code fields we want
|
:operation/name "EditClient"}
|
||||||
(-> new-client
|
:venia/queries [{:query/data [:edit-client
|
||||||
(update :bank-accounts #(seq (into % (map (fn [ba] (dissoc ba :is-new?)) (:new-bank-accounts new-client)))))
|
{:edit-client
|
||||||
(dissoc :new-bank-accounts))
|
;; TODO - hard code fields we want
|
||||||
}
|
(-> new-client
|
||||||
[:id :name :code :email [:address [:street1 :street2 :city :state :zip]] [:bank-accounts [:id :number :check-number :name :code :bank-code :bank-name :routing]]]
|
(update :bank-accounts #(seq (into % (map (fn [ba] (dissoc ba :is-new?)) (:new-bank-accounts new-client)))))
|
||||||
]}]}
|
(dissoc :new-account)
|
||||||
:on-success [::save-complete]
|
(dissoc :new-bank-accounts))
|
||||||
:on-error [::save-error]}})))
|
}
|
||||||
|
[: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]}}
|
||||||
|
{:db db}))))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::save-complete
|
::save-complete
|
||||||
@@ -81,6 +98,7 @@
|
|||||||
{:dispatch [::events/modal-completed :auto-ap.views.pages.admin.clients/edit]
|
{:dispatch [::events/modal-completed :auto-ap.views.pages.admin.clients/edit]
|
||||||
:db (-> db
|
:db (-> db
|
||||||
(assoc-in [:admin :adding-client?] false)
|
(assoc-in [:admin :adding-client?] false)
|
||||||
|
(assoc-in [::loading ::save-client] nil)
|
||||||
(update :admin dissoc :new-client)
|
(update :admin dissoc :new-client)
|
||||||
|
|
||||||
|
|
||||||
@@ -89,10 +107,10 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::save-error
|
::save-error
|
||||||
(fn [db [_ client]]
|
(fn [db [_ result]]
|
||||||
(-> db
|
(-> db
|
||||||
(assoc-in [:admin :client :saving?] false)
|
(assoc-in [::loading ::save-client] false)
|
||||||
(assoc-in [:admin :client :error] true))))
|
(assoc-in [:admin :client :error] (:message (first result))))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::change
|
::change
|
||||||
@@ -352,179 +370,187 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn new-client-form []
|
(defn new-client-form []
|
||||||
(let [new-client (:new-client @(re-frame/subscribe [::subs/admin]))]
|
(let [new-client (:new-client @(re-frame/subscribe [::subs/admin]))
|
||||||
[:div
|
error (:error (:client @(re-frame/subscribe [::subs/admin])))]
|
||||||
[:form
|
[:div
|
||||||
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
[:form
|
||||||
[:h1.title "Add client"]
|
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
||||||
[:div.field
|
[:h1.title "Add client"]
|
||||||
[:label.label "Name"]
|
[:div.field
|
||||||
[:div.control
|
[:label.label "Name"]
|
||||||
[bind-field
|
[:div.control
|
||||||
[:input.input {:type "text"
|
[bind-field
|
||||||
:field :name
|
[:input.input {:type "text"
|
||||||
:spec ::entity/name
|
:field :name
|
||||||
:event ::change-new
|
:spec ::entity/name
|
||||||
:subscription new-client}]]]]
|
:event ::change-new
|
||||||
|
:subscription new-client}]]]]
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:label.label "Client code"]
|
[:label.label "Client code"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[bind-field
|
[bind-field
|
||||||
[:input.input {:type "code"
|
[:input.input {:type "code"
|
||||||
:field :code
|
:field :code
|
||||||
:spec ::entity/code
|
:spec ::entity/code
|
||||||
:event ::change-new
|
:event ::change-new
|
||||||
:subscription new-client}]]]]
|
:subscription new-client}]]]]
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:label.label "Email"]
|
[:label.label "Email"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[bind-field
|
[bind-field
|
||||||
[:input.input {:type "email"
|
[:input.input {:type "email"
|
||||||
:field :email
|
:field :email
|
||||||
:spec ::entity/email
|
:spec ::entity/email
|
||||||
:event ::change-new
|
:event ::change-new
|
||||||
:subscription new-client}]]]]
|
:subscription new-client}]]]]
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:label.label "Locations"]
|
[:label.label "Locations"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
[:p.control
|
[:p.control
|
||||||
[bind-field
|
[bind-field
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
:field :location
|
:field :location
|
||||||
:event ::change-new
|
:event ::change-new
|
||||||
:subscription new-client}]]]
|
:subscription new-client}]]]
|
||||||
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location])} "Add"]]]
|
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location])} "Add"]]]
|
||||||
[:ul
|
[:ul
|
||||||
(for [location (:locations new-client)]
|
(for [location (:locations new-client)]
|
||||||
^{:key location} [:li location ])]]]
|
^{:key location} [:li location ])]]]
|
||||||
]
|
]
|
||||||
|
|
||||||
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
||||||
[:h2.subtitle "Address"]
|
[:h2.subtitle "Address"]
|
||||||
[address-field {:field [:address]
|
[address-field {:field [:address]
|
||||||
:event ::change-new
|
|
||||||
:subscription new-client}]]
|
|
||||||
|
|
||||||
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em" :background "hsl(0, 0%, 96%)"}}
|
|
||||||
[:h2.subtitle "Add bank account"]
|
|
||||||
[:label.label "General"]
|
|
||||||
[horizontal-field
|
|
||||||
nil
|
|
||||||
[:div.control
|
|
||||||
[:p.help "Account Code"]
|
|
||||||
[:div.field.has-addons.is-extended
|
|
||||||
[:p.control [:a.button.is-static (:code new-client) "-" ]]
|
|
||||||
[:p.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:type "code"
|
|
||||||
:field [:new-account :code]
|
|
||||||
:spec ::entity/code
|
|
||||||
:event ::change-new
|
|
||||||
:subscription new-client}]]]]]
|
|
||||||
|
|
||||||
[:div.control
|
|
||||||
[:p.help "Nickname"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "BOA Checking #1"
|
|
||||||
:type "text"
|
|
||||||
:field [:new-account :name]
|
|
||||||
:event ::change-new
|
:event ::change-new
|
||||||
:subscription new-client}]]]]
|
:subscription new-client}]]
|
||||||
|
|
||||||
[:label.label "Bank"]
|
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em" :background "hsl(0, 0%, 96%)"}}
|
||||||
[horizontal-field
|
[:h2.subtitle "Add bank account"]
|
||||||
nil
|
[:label.label "General"]
|
||||||
[:div.control
|
[horizontal-field
|
||||||
[:p.help "Bank Name"]
|
nil
|
||||||
[bind-field
|
[:div.control
|
||||||
[:input.input {:placeholder "Bank of America"
|
[:p.help "Account Code"]
|
||||||
:type "text"
|
[:div.field.has-addons.is-extended
|
||||||
:field [:new-account :bank-name]
|
[:p.control [:a.button.is-static (:code new-client) "-" ]]
|
||||||
:event ::change-new
|
[:p.control
|
||||||
:subscription new-client}]]]
|
[bind-field
|
||||||
[:div.control
|
[:input.input {:type "code"
|
||||||
[:p.help "Routing #"]
|
:field [:new-account :code]
|
||||||
[bind-field
|
:spec ::entity/code
|
||||||
[:input.input {:placeholder "104819123"
|
:event ::change-new
|
||||||
:type "text"
|
:subscription new-client}]]]]]
|
||||||
:field [:new-account :routing]
|
|
||||||
:event ::change-new
|
|
||||||
:subscription new-client}]]]
|
|
||||||
[:div.control
|
|
||||||
[:p.help "Bank code"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "12/10123"
|
|
||||||
:type "text"
|
|
||||||
:field [:new-account :bank-code]
|
|
||||||
:event ::change-new
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
[:label.label "Checking account"]
|
[:div.control
|
||||||
[horizontal-field
|
[:p.help "Nickname"]
|
||||||
nil
|
[bind-field
|
||||||
[:div.control
|
[:input.input {:placeholder "BOA Checking #1"
|
||||||
[:p.help "Account #"]
|
:type "text"
|
||||||
[bind-field
|
:field [:new-account :name]
|
||||||
[:input.input {:placeholder "123456789"
|
:event ::change-new
|
||||||
:type "text"
|
:subscription new-client}]]]]
|
||||||
:field [:new-account :number]
|
|
||||||
:event ::change-new
|
|
||||||
:subscription new-client}]]]
|
|
||||||
[:div.control
|
|
||||||
[:p.help "Check Number"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "10000"
|
|
||||||
:type "text"
|
|
||||||
:field [:new-account :check-number]
|
|
||||||
:event ::change-new
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
[:div.field
|
[:label.label "Bank"]
|
||||||
[:label.label "Yodlee Account"]
|
[horizontal-field
|
||||||
[:div.control
|
nil
|
||||||
[bind-field
|
[:div.control
|
||||||
[:input.input {:placeholder "Yodlee Account #"
|
[:p.help "Bank Name"]
|
||||||
:type "text"
|
[bind-field
|
||||||
:field [:new-account :yodlee-account-id]
|
[:input.input {:placeholder "Bank of America"
|
||||||
:event ::change-new
|
:type "text"
|
||||||
:subscription new-client}]]]
|
:field [:new-account :bank-name]
|
||||||
]
|
:event ::change-new
|
||||||
[:div.field
|
:subscription new-client}]]]
|
||||||
[:div.control
|
[:div.control
|
||||||
(println (s/explain-data ::entity/bank-account (:new-account new-client)))
|
[:p.help "Routing #"]
|
||||||
[:button.button.is-primary {:disabled (if (and (doto (s/valid? ::entity/bank-account (:new-account new-client)) println)
|
[bind-field
|
||||||
(not ((set (map :code (:new-bank-accounts new-client)))
|
[:input.input {:placeholder "104819123"
|
||||||
(str (:code new-client) "-" (-> new-client :new-account :code)))))
|
:type "text"
|
||||||
""
|
:field [:new-account :routing]
|
||||||
"disabled")
|
:event ::change-new
|
||||||
:on-click (dispatch-event [::add-new-new-bank-account])} "Add"]]]]
|
:subscription new-client}]]]
|
||||||
|
[:div.control
|
||||||
|
[:p.help "Bank code"]
|
||||||
|
[bind-field
|
||||||
|
[:input.input {:placeholder "12/10123"
|
||||||
|
:type "text"
|
||||||
|
:field [:new-account :bank-code]
|
||||||
|
:event ::change-new
|
||||||
|
:subscription new-client}]]]]
|
||||||
|
|
||||||
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
[:label.label "Checking account"]
|
||||||
[:h2.subtitle "Bank Accounts"]
|
[horizontal-field
|
||||||
[:div.field
|
nil
|
||||||
nil
|
[:div.control
|
||||||
[:div.control
|
[:p.help "Account #"]
|
||||||
[:ul
|
[bind-field
|
||||||
|
[:input.input {:placeholder "123456789"
|
||||||
(for [{:keys [code name number check-number id]} (:bank-accounts new-client)]
|
:type "text"
|
||||||
^{:key id} [:li code ": " name])
|
:field [:new-account :number]
|
||||||
(for [[index {:keys [name code number check-number]}] (map vector (range) (:new-bank-accounts new-client))]
|
:event ::change-new
|
||||||
^{:key index} [:li [:strong "* " code ": " name] [:button.button {:on-click (dispatch-event [::remove-new-bank-account index])} [:span.icon [:i.fa.fa-times]]]])]]]]
|
:subscription new-client}]]]
|
||||||
|
[:div.control
|
||||||
#_(when (:saving? new-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])
|
[:p.help "Check Number"]
|
||||||
(println (s/explain-data ::entity/client new-client))
|
[bind-field
|
||||||
[:submit.button.is-large.is-primary {:disabled (if (s/valid? ::entity/client new-client)
|
[:input.input {:placeholder "10000"
|
||||||
""
|
:type "text"
|
||||||
"disabled")
|
:field [:new-account :check-number]
|
||||||
:on-click (dispatch-event [::save-new-client])} "Save"]]]))
|
:event ::change-new
|
||||||
|
:subscription new-client}]]]]
|
||||||
|
|
||||||
|
[:div.field
|
||||||
|
[:label.label "Yodlee Account"]
|
||||||
|
[:div.control
|
||||||
|
[bind-field
|
||||||
|
[:input.input {:placeholder "Yodlee Account #"
|
||||||
|
:type "text"
|
||||||
|
:field [:new-account :yodlee-account-id]
|
||||||
|
:event ::change-new
|
||||||
|
:subscription new-client}]]]
|
||||||
|
]
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
#_(println (s/explain-data ::entity/bank-account (:new-account new-client)))
|
||||||
|
[:button.button.is-primary {:disabled (if (and (doto (s/valid? ::entity/bank-account (:new-account new-client)) println)
|
||||||
|
(not ((set (map :code (:new-bank-accounts new-client)))
|
||||||
|
(str (:code new-client) "-" (-> new-client :new-account :code)))))
|
||||||
|
""
|
||||||
|
"disabled")
|
||||||
|
:on-click (dispatch-event [::add-new-new-bank-account])} "Add"]]]]
|
||||||
|
|
||||||
|
[:section.section {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
||||||
|
[:h2.subtitle "Bank Accounts"]
|
||||||
|
[:div.field
|
||||||
|
nil
|
||||||
|
[:div.control
|
||||||
|
[:ul
|
||||||
|
|
||||||
|
(for [{:keys [code name number check-number id]} (:bank-accounts new-client)]
|
||||||
|
^{:key id} [:li code ": " name])
|
||||||
|
(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]]]])]]]]
|
||||||
|
|
||||||
|
#_(when (:saving? new-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])
|
||||||
|
#_(println (s/explain-data ::entity/client new-client))
|
||||||
|
|
||||||
|
(when error
|
||||||
|
[:div.notification.is-warning.animated.fadeInUp
|
||||||
|
error]
|
||||||
|
)
|
||||||
|
|
||||||
|
[:submit.button.is-large.is-primary {:disabled (if (s/valid? ::entity/client new-client)
|
||||||
|
""
|
||||||
|
"disabled")
|
||||||
|
:on-click (dispatch-event [::save-new-client])
|
||||||
|
:class (str @(re-frame/subscribe [::loading-class ::save-client]) (when error " animated shake"))} "Save"]]]))
|
||||||
|
|
||||||
(defn admin-clients-page []
|
(defn admin-clients-page []
|
||||||
(let [{:keys [adding-client?]} @(re-frame/subscribe [::subs/admin])]
|
(let [{:keys [adding-client?]} @(re-frame/subscribe [::subs/admin])]
|
||||||
[side-bar-layout {:side-bar [admin-side-bar {}]
|
[side-bar-layout {:side-bar [admin-side-bar {}]
|
||||||
:main [admin-clients-content]
|
:main [admin-clients-content]
|
||||||
:right-side-bar (when adding-client?
|
:right-side-bar-visible? adding-client?
|
||||||
[new-client-form])}]))
|
:right-side-bar [new-client-form]}]))
|
||||||
|
|||||||
Reference in New Issue
Block a user