simplified client form.
This commit is contained in:
@@ -904,7 +904,7 @@
|
|||||||
|
|
||||||
(defn get-cash-flow [context {:keys [client_id]} value]
|
(defn get-cash-flow [context {:keys [client_id]} value]
|
||||||
(when client_id
|
(when client_id
|
||||||
(let [{:client/keys [weekly-credits weekly-debits ]} (doto (d/pull (d/db (d/connect uri)) '[*] client_id ) println)
|
(let [{:client/keys [weekly-credits weekly-debits ]} (d/pull (d/db (d/connect uri)) '[*] client_id )
|
||||||
total-cash (reduce
|
total-cash (reduce
|
||||||
(fn [total [credit debit]]
|
(fn [total [credit debit]]
|
||||||
(- (+ total credit)
|
(- (+ total credit)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[auto-ap.entities.clients :as entity]
|
[auto-ap.entities.clients :as entity]
|
||||||
[auto-ap.views.components.address :refer [address-field]]
|
[auto-ap.views.components.address :refer [address-field]]
|
||||||
[auto-ap.views.components.layouts :refer [side-bar-layout appearing-side-bar]]
|
[auto-ap.views.components.layouts :refer [side-bar-layout appearing-side-bar side-bar] ]
|
||||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||||
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field]]
|
[auto-ap.views.utils :refer [login-url dispatch-event dispatch-value-change bind-field horizontal-field]]
|
||||||
[auto-ap.views.components.modal :refer [action-modal]]
|
[auto-ap.views.components.modal :refer [action-modal]]
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
::new
|
::new
|
||||||
(fn [db [_ client-id]]
|
(fn [db [_ client-id]]
|
||||||
(-> db
|
(-> db
|
||||||
(forms/start-form ::new-client {:bank-accounts []}))))
|
(forms/start-form ::form {:bank-accounts []}))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -31,12 +31,19 @@
|
|||||||
::edit-client-clicked
|
::edit-client-clicked
|
||||||
(fn [{:keys [db]} [_ client-id]]
|
(fn [{:keys [db]} [_ client-id]]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(forms/stop-form ::new-client)
|
(forms/stop-form ::form)
|
||||||
(forms/start-form ::new-client (get (:clients db) client-id)))}))
|
(forms/start-form ::form (get (:clients db) client-id)))}))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::can-submit
|
||||||
|
:<- [::forms/form ::form]
|
||||||
|
(fn [{:keys [data status]} _]
|
||||||
|
(s/valid? ::entity/client data)))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::new-client-request
|
::new-client-request
|
||||||
:<- [::forms/form ::new-client]
|
:<- [::forms/form ::form]
|
||||||
(fn [{new-client-data :data} _]
|
(fn [{new-client-data :data} _]
|
||||||
{:id (:id new-client-data),
|
{:id (:id new-client-data),
|
||||||
:name (:name new-client-data)
|
:name (:name new-client-data)
|
||||||
@@ -74,7 +81,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::save-new-client
|
::save-new-client
|
||||||
[(forms/in-form ::new-client)]
|
[(forms/in-form ::form)]
|
||||||
(fn [{{new-client-data :data :as new-client-form} :db} _]
|
(fn [{{new-client-data :data :as new-client-form} :db} _]
|
||||||
|
|
||||||
(let [new-client-req @(re-frame/subscribe [::new-client-request])
|
(let [new-client-req @(re-frame/subscribe [::new-client-request])
|
||||||
@@ -104,13 +111,13 @@
|
|||||||
::save-complete
|
::save-complete
|
||||||
(fn [db [_ client]]
|
(fn [db [_ client]]
|
||||||
(-> db
|
(-> db
|
||||||
(forms/stop-form ::new-client)
|
(forms/stop-form ::form)
|
||||||
|
|
||||||
(assoc-in [:clients (:id (:edit-client client))] (update (:edit-client client) :bank-accounts (fn [bas] (->> bas (sort-by :sort-order) vec)))))))
|
(assoc-in [:clients (:id (:edit-client client))] (update (:edit-client client) :bank-accounts (fn [bas] (->> bas (sort-by :sort-order) vec)))))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-new-location
|
::add-new-location
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client _]
|
(fn [client _]
|
||||||
(-> client
|
(-> client
|
||||||
(update :locations conj (:location client))
|
(update :locations conj (:location client))
|
||||||
@@ -118,7 +125,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-location-to-bank-account
|
::add-location-to-bank-account
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client [_ which-account]]
|
(fn [client [_ which-account]]
|
||||||
(println client which-account)
|
(println client which-account)
|
||||||
(-> client
|
(-> client
|
||||||
@@ -127,7 +134,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-new-match
|
::add-new-match
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client _]
|
(fn [client _]
|
||||||
(-> client
|
(-> client
|
||||||
(update :matches conj (:match client))
|
(update :matches conj (:match client))
|
||||||
@@ -136,7 +143,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::remove-match
|
::remove-match
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client [_ which]]
|
(fn [client [_ which]]
|
||||||
(-> client
|
(-> client
|
||||||
(update :matches set)
|
(update :matches set)
|
||||||
@@ -144,7 +151,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-new-location-match
|
::add-new-location-match
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client _]
|
(fn [client _]
|
||||||
(-> client
|
(-> client
|
||||||
(update :location-matches conj (:location-match client))
|
(update :location-matches conj (:location-match client))
|
||||||
@@ -152,7 +159,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::remove-location-match
|
::remove-location-match
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client [_ i]]
|
(fn [client [_ i]]
|
||||||
(-> client
|
(-> client
|
||||||
(update :location-matches (fn [lm]
|
(update :location-matches (fn [lm]
|
||||||
@@ -164,25 +171,25 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::add-new-bank-account
|
::add-new-bank-account
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data])]
|
[(forms/in-form ::form) (re-frame/path [:data])]
|
||||||
(fn [client [_ type]]
|
(fn [client [_ type]]
|
||||||
(update client :bank-accounts conj {:type type :active? true :new? true :visible true :sort-order (count (:bank-accounts client))})))
|
(update client :bank-accounts conj {:type type :active? true :new? true :visible true :sort-order (count (:bank-accounts client))})))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::bank-account-activated
|
::bank-account-activated
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data :bank-accounts])]
|
[(forms/in-form ::form) (re-frame/path [:data :bank-accounts])]
|
||||||
(fn [bank-accounts [_ index]]
|
(fn [bank-accounts [_ index]]
|
||||||
(update (vec (sort-by :sort-order bank-accounts)) index assoc :active? true)))
|
(update (vec (sort-by :sort-order bank-accounts)) index assoc :active? true)))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::bank-account-deactivated
|
::bank-account-deactivated
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data :bank-accounts])]
|
[(forms/in-form ::form) (re-frame/path [:data :bank-accounts])]
|
||||||
(fn [bank-accounts [_ index]]
|
(fn [bank-accounts [_ index]]
|
||||||
(update (vec (sort-by :sort-order bank-accounts)) index assoc :active? false)))
|
(update (vec (sort-by :sort-order bank-accounts)) index assoc :active? false)))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::bank-account-removed
|
::bank-account-removed
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data :bank-accounts])]
|
[(forms/in-form ::form) (re-frame/path [:data :bank-accounts])]
|
||||||
(fn [bank-accounts [_ index]]
|
(fn [bank-accounts [_ index]]
|
||||||
(vec (concat (take index bank-accounts)
|
(vec (concat (take index bank-accounts)
|
||||||
(drop (inc index) bank-accounts)))
|
(drop (inc index) bank-accounts)))
|
||||||
@@ -192,7 +199,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::sort-swapped
|
::sort-swapped
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data :bank-accounts])]
|
[(forms/in-form ::form) (re-frame/path [:data :bank-accounts])]
|
||||||
(fn [bank-accounts [_ source dest]]
|
(fn [bank-accounts [_ source dest]]
|
||||||
(->> (-> bank-accounts
|
(->> (-> bank-accounts
|
||||||
(assoc-in [source :sort-order] (get-in bank-accounts [dest :sort-order]))
|
(assoc-in [source :sort-order] (get-in bank-accounts [dest :sort-order]))
|
||||||
@@ -204,7 +211,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::toggle-visible
|
::toggle-visible
|
||||||
[(forms/in-form ::new-client) (re-frame/path [:data :bank-accounts])]
|
[(forms/in-form ::form) (re-frame/path [:data :bank-accounts])]
|
||||||
(fn [bank-accounts [_ account]]
|
(fn [bank-accounts [_ account]]
|
||||||
(-> (->> bank-accounts
|
(-> (->> bank-accounts
|
||||||
(sort-by :sort-order)
|
(sort-by :sort-order)
|
||||||
@@ -242,9 +249,14 @@
|
|||||||
[:a.button.is-primary.is-large {:on-click (dispatch-event [::new])} "New client"]]
|
[:a.button.is-primary.is-large {:on-click (dispatch-event [::new])} "New client"]]
|
||||||
[clients-table]])])
|
[clients-table]])])
|
||||||
|
|
||||||
|
(def client-form
|
||||||
|
(forms/vertical-form {:can-submit [::can-submit]
|
||||||
|
:change-event [::forms/change ::form]
|
||||||
|
:submit-event [::save-new-client ]
|
||||||
|
:id ::form}))
|
||||||
|
|
||||||
(defn bank-account-card [new-client {:keys [active? new? type visible code name number check-number id sort-order] :as bank-account} first? last?]
|
(defn bank-account-card [new-client {:keys [active? new? type visible code name number check-number id sort-order] :as bank-account} first? last?]
|
||||||
(let [change-event [::forms/change ::new-client]]
|
(let [{:keys [form field raw-field error-notification submit-button ]} client-form]
|
||||||
[:div.card {:style {:margin-bottom "1em"}}
|
[:div.card {:style {:margin-bottom "1em"}}
|
||||||
[:header.card-header
|
[:header.card-header
|
||||||
[:p.card-header-title {:style {:text-overflow "ellipsis"}}
|
[:p.card-header-title {:style {:text-overflow "ellipsis"}}
|
||||||
@@ -287,117 +299,76 @@
|
|||||||
[:div.field.has-addons.is-extended
|
[:div.field.has-addons.is-extended
|
||||||
[:p.control [:a.button.is-static (:code new-client) "-" ]]
|
[:p.control [:a.button.is-static (:code new-client) "-" ]]
|
||||||
[:p.control
|
[:p.control
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input.input {:type "code"
|
[:input.input {:type "code"
|
||||||
:field [:bank-accounts sort-order :code]
|
:field [:bank-accounts sort-order :code]
|
||||||
:spec ::entity/code
|
:spec ::entity/code}]]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
[:div.field [:p.control code]])]
|
[:div.field [:p.control code]])]
|
||||||
|
|
||||||
[:div.control
|
[field "Nickname"
|
||||||
[:p.help "Nickname"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "BOA Checking #1"
|
[:input.input {:placeholder "BOA Checking #1"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :name]
|
:field [:bank-accounts sort-order :name]}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
(when (#{:check ":check"} type )
|
(when (#{:check ":check"} type )
|
||||||
[:div
|
[:div
|
||||||
|
|
||||||
[:label.label "Bank"]
|
[:label.label "Bank"]
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
nil
|
nil
|
||||||
[:div.control
|
[field "Bank Name"
|
||||||
[:p.help "Bank Name"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "Bank of America"
|
[:input.input {:placeholder "Bank of America"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :bank-name]
|
:field [:bank-accounts sort-order :bank-name]}]]
|
||||||
:event change-event
|
[field "Routing #"
|
||||||
:subscription new-client}]]]
|
|
||||||
[:div.control
|
|
||||||
[:p.help "Routing #"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "104819123"
|
[:input.input {:placeholder "104819123"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :routing]
|
:field [:bank-accounts sort-order :routing]}]]
|
||||||
:event change-event
|
[field "Bank code"
|
||||||
:subscription new-client}]]]
|
|
||||||
[:div.control
|
|
||||||
[:p.help "Bank code"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "12/10123"
|
[:input.input {:placeholder "12/10123"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :bank-code]
|
:field [:bank-accounts sort-order :bank-code]}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
[:label.label "Checking account"]
|
[:label.label "Checking account"]
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
nil
|
nil
|
||||||
[:div.control
|
[field "Account #"
|
||||||
[:p.help "Account #"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "123456789"
|
[:input.input {:placeholder "123456789"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :number]
|
:field [:bank-accounts sort-order :number]}]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]
|
[field "Check Number"
|
||||||
[:div.control
|
|
||||||
[:p.help "Check Number"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "10000"
|
[:input.input {:placeholder "10000"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :check-number]
|
:field [:bank-accounts sort-order :check-number]}]]]
|
||||||
:event change-event
|
[field "Yodlee Account"
|
||||||
:subscription new-client}]]]]
|
|
||||||
[:div.field
|
|
||||||
[:label.label "Yodlee Account"]
|
|
||||||
[:div.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "Yodlee Account #"
|
[:input.input {:placeholder "Yodlee Account #"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :yodlee-account-id]
|
:field [:bank-accounts sort-order :yodlee-account-id]}]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
])
|
])
|
||||||
(when (#{:credit ":credit"} type )
|
(when (#{:credit ":credit"} type )
|
||||||
[:div
|
[:div
|
||||||
|
|
||||||
|
|
||||||
[:label.label "Account"]
|
[:label.label "Account"]
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
nil
|
nil
|
||||||
[:div.control
|
[field "Bank Name"
|
||||||
[:p.help "Bank Name"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "Bank of America"
|
[:input.input {:placeholder "Bank of America"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :bank-name]
|
:field [:bank-accounts sort-order :bank-name]}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
nil
|
nil
|
||||||
[:div.control
|
[field "Account #"
|
||||||
[:p.help "Account #"]
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "123456789"
|
[:input.input {:placeholder "123456789"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :number]
|
:field [:bank-accounts sort-order :number]}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
[field "Yodlee Account"
|
||||||
[:div.field
|
|
||||||
[:p.help "Yodlee Account"]
|
|
||||||
[:div.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:placeholder "Yodlee Account #"
|
[:input.input {:placeholder "Yodlee Account #"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :yodlee-account-id]
|
:field [:bank-accounts sort-order :yodlee-account-id]}]]])
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]])
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:label.label "Locations"]
|
[:label.label "Locations"]
|
||||||
[:div.control
|
[:div.control
|
||||||
@@ -405,14 +376,12 @@
|
|||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
[:p.control
|
[:p.control
|
||||||
[:div.select
|
[:div.select
|
||||||
[bind-field
|
[raw-field
|
||||||
[:select {:type "select"
|
[:select {:type "select"
|
||||||
:style {:width "7em"}
|
:style {:width "7em"}
|
||||||
:field [:bank-accounts sort-order :location-select]
|
:field [:bank-accounts sort-order :location-select]
|
||||||
:allow-nil? true
|
:allow-nil? true
|
||||||
:spec (set (get-in new-client [:locations]))
|
:spec (set (get-in new-client [:locations]))}
|
||||||
:event change-event
|
|
||||||
:subscription new-client}
|
|
||||||
(map (fn [l] ^{:key l} [:option {:value l} l]) (get-in new-client [:locations]))]]]]
|
(map (fn [l] ^{:key l} [:option {:value l} l]) (get-in new-client [:locations]))]]]]
|
||||||
[:p.control {:on-click (dispatch-event [::add-location-to-bank-account sort-order]) } [:a.button "Add"]]]]
|
[:p.control {:on-click (dispatch-event [::add-location-to-bank-account sort-order]) } [:a.button "Add"]]]]
|
||||||
|
|
||||||
@@ -423,13 +392,10 @@
|
|||||||
[:i "This account applies to all locations"])]
|
[:i "This account applies to all locations"])]
|
||||||
[:div.field
|
[:div.field
|
||||||
[:label.checkbox
|
[:label.checkbox
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input {:type "checkbox"
|
[:input {:type "checkbox"
|
||||||
:field [:bank-accounts sort-order :include-in-reports]
|
:field [:bank-accounts sort-order :include-in-reports]}]]
|
||||||
:event change-event
|
" Include in reports"]]])
|
||||||
:subscription new-client}]]
|
|
||||||
" Include in reports"]
|
|
||||||
]])
|
|
||||||
|
|
||||||
(when active?
|
(when active?
|
||||||
[:footer.card-footer
|
[:footer.card-footer
|
||||||
@@ -438,56 +404,46 @@
|
|||||||
[:a.card-footer-item.is-warning {:href "#" :on-click (dispatch-event [::bank-account-removed sort-order])} "Remove"])])])
|
[:a.card-footer-item.is-warning {:href "#" :on-click (dispatch-event [::bank-account-removed sort-order])} "Remove"])])])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn new-client-form []
|
(defn new-client-form []
|
||||||
(let [{error :error new-client :data } @(re-frame/subscribe [::forms/form ::new-client])
|
(let [{new-client :data } @(re-frame/subscribe [::forms/form ::form])
|
||||||
change-event [::forms/change ::new-client]]
|
{:keys [form field raw-field error-notification submit-button ]} client-form]
|
||||||
|
|
||||||
[forms/side-bar-form {:form ::new-client}
|
[side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])}
|
||||||
[:form
|
[form {:title "Add client"}
|
||||||
[:h1.title.is-2 "Add client"]
|
[field "Name"
|
||||||
[:div.field
|
|
||||||
[:p.help "Name"]
|
|
||||||
[:div.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
:field :name
|
:field [:name]
|
||||||
:spec ::entity/name
|
:spec ::entity/name
|
||||||
:event change-event
|
}]]
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:p.help "Client code"]
|
[:p.help "Client code"
|
||||||
|
]
|
||||||
(if (:id new-client)
|
(if (:id new-client)
|
||||||
[:div.control
|
[:div.control
|
||||||
(:code new-client)
|
(:code new-client)]
|
||||||
]
|
|
||||||
[:div.control
|
[:div.control
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input.input {:type "code"
|
[:input.input {:type "code"
|
||||||
:field :code
|
:field :code
|
||||||
:spec ::entity/code
|
:spec ::entity/code}]]])]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]])]
|
|
||||||
|
|
||||||
[:div.field
|
|
||||||
[:p.help "Email"]
|
[field "Email"
|
||||||
[:div.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:type "email"
|
[:input.input {:type "email"
|
||||||
:field :email
|
:field :email
|
||||||
:spec ::entity/email
|
:spec ::entity/email}]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:p.help "Matches"]
|
[:p.help "Matches"]
|
||||||
[:div.control
|
[:div.control
|
||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
[:p.control
|
[:p.control
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
:field :match
|
:field :match}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]
|
|
||||||
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-match])} "Add"]]]]
|
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-match])} "Add"]]]]
|
||||||
[:ul
|
[:ul
|
||||||
(for [match (:matches new-client)]
|
(for [match (:matches new-client)]
|
||||||
@@ -500,11 +456,9 @@
|
|||||||
[:div.control
|
[:div.control
|
||||||
[:div.field.has-addons
|
[:div.field.has-addons
|
||||||
[:p.control
|
[:p.control
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
:field :location
|
:field :location}]]]
|
||||||
:event change-event
|
|
||||||
: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)]
|
||||||
@@ -517,19 +471,15 @@
|
|||||||
|
|
||||||
[:p.control
|
[:p.control
|
||||||
|
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
:placeholder "San Jose"
|
:placeholder "San Jose"
|
||||||
:field [:location-match :match]
|
:field [:location-match :match]}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]
|
|
||||||
[:p.control
|
[:p.control
|
||||||
[bind-field
|
[raw-field
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
:placeholder "DT"
|
:placeholder "DT"
|
||||||
:field [:location-match :location]
|
:field [:location-match :location]}]]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]
|
|
||||||
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location-match])} "Add"]]]
|
[:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location-match])} "Add"]]]
|
||||||
|
|
||||||
[:ul
|
[:ul
|
||||||
@@ -540,7 +490,7 @@
|
|||||||
[:div {:style {:padding-bottom "0.75em" :padding-top "0.75em"}}
|
[:div {: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-event
|
:event [::forms/change ::form]
|
||||||
:subscription new-client}]]
|
:subscription new-client}]]
|
||||||
|
|
||||||
[:h2.subtitle "Bank accounts"]
|
[:h2.subtitle "Bank accounts"]
|
||||||
@@ -556,44 +506,23 @@
|
|||||||
[:div.column.is-third
|
[:div.column.is-third
|
||||||
[:a.button.is-primary.is-outlined.is-fullwidth {:on-click (dispatch-event [::add-new-bank-account :cash])} "Add Cash Account"]]]
|
[:a.button.is-primary.is-outlined.is-fullwidth {:on-click (dispatch-event [::add-new-bank-account :cash])} "Add Cash Account"]]]
|
||||||
|
|
||||||
#_[:h2.subtitle "Add bank account"]
|
[field "Weekly credits"
|
||||||
#_(when (:saving? new-client) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])
|
|
||||||
#_(println (s/explain-data ::entity/client new-client))
|
|
||||||
|
|
||||||
[:div.field
|
|
||||||
[:p.help "Weekly credits"]
|
|
||||||
[:div.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:type "number"
|
[:input.input {:type "number"
|
||||||
:placeholder "250.00"
|
:placeholder "250.00"
|
||||||
:field [:weekly-credits]
|
:field [:weekly-credits]
|
||||||
:step "0.01"
|
:step "0.01"}]]
|
||||||
:event change-event
|
[field "Weekly debits"
|
||||||
:subscription new-client}]]]]
|
|
||||||
[:div.field
|
|
||||||
[:p.help "Weekly debits"]
|
|
||||||
[:div.control
|
|
||||||
[bind-field
|
|
||||||
[:input.input {:type "number"
|
[:input.input {:type "number"
|
||||||
:placeholder "250.00"
|
:placeholder "250.00"
|
||||||
:field [:weekly-debits]
|
:field [:weekly-debits]
|
||||||
:step "0.01"
|
:step "0.01"}]]
|
||||||
:event change-event
|
|
||||||
:subscription new-client}]]]]
|
|
||||||
|
|
||||||
(when error
|
|
||||||
[:div.notification.is-warning.animated.fadeInUp
|
|
||||||
error])
|
|
||||||
|
|
||||||
|
|
||||||
[:submit.button.is-large.is-primary {:disabled (if (s/valid? ::entity/client @(re-frame/subscribe [::new-client-request]))
|
[error-notification]
|
||||||
""
|
[submit-button "Save"]]]))
|
||||||
"disabled")
|
|
||||||
:on-click (dispatch-event [::save-new-client])
|
|
||||||
:class (str @(re-frame/subscribe [::forms/loading-class ::new-client]) (when error " animated shake"))} "Save"]]]))
|
|
||||||
|
|
||||||
(defn admin-clients-page []
|
(defn admin-clients-page []
|
||||||
(let [{:keys [active?]} @(re-frame/subscribe [::forms/form ::new-client])]
|
(let [{:keys [active?]} @(re-frame/subscribe [::forms/form ::form])]
|
||||||
[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 [appearing-side-bar {:visible? active?} [new-client-form]] }]))
|
:right-side-bar [appearing-side-bar {:visible? active?} [new-client-form]] }]))
|
||||||
|
|||||||
Reference in New Issue
Block a user