improvements to UI.
This commit is contained in:
@@ -13,14 +13,15 @@
|
|||||||
(s/def ::address (s/nilable ::address/address))
|
(s/def ::address (s/nilable ::address/address))
|
||||||
|
|
||||||
(s/def ::bank-name ::shared/required-identifier)
|
(s/def ::bank-name ::shared/required-identifier)
|
||||||
(s/def ::bank-code ::shared/required-identifier)
|
(s/def ::bank-code (s/nilable string?))
|
||||||
(s/def ::routing ::shared/required-identifier)
|
(s/def ::routing (s/nilable string?))
|
||||||
(s/def ::number ::shared/required-identifier)
|
(s/def ::number ::shared/required-identifier)
|
||||||
(s/def ::type keyword?)
|
(s/def ::type keyword?)
|
||||||
(s/def ::number string?)
|
(s/def ::number string?)
|
||||||
(s/def ::yodlee-account-id string?)
|
(s/def ::yodlee-account-id string?)
|
||||||
|
|
||||||
(s/def ::checking-bank-account (s/and (s/keys :req-un [::code ::name ::bank-name ::bank-code ::routing ::number ::type])
|
(s/def ::checking-bank-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
|
||||||
|
:opt-un [::bank-code ::routing])
|
||||||
#(= (:type %) :check)))
|
#(= (:type %) :check)))
|
||||||
(s/def ::cash-account (s/and (s/keys :req-un [::type ::code ::name])
|
(s/def ::cash-account (s/and (s/keys :req-un [::type ::code ::name])
|
||||||
#(= (:type %) :cash)))
|
#(= (:type %) :cash)))
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
(defn start-form [db form data]
|
(defn start-form [db form data]
|
||||||
(assoc-in db [::forms form] {:error nil
|
(assoc-in db [::forms form] {:error nil
|
||||||
:active? true
|
:active? true
|
||||||
|
:id (random-uuid)
|
||||||
:status nil
|
:status nil
|
||||||
:data data}))
|
:data data}))
|
||||||
(defn stop-form [db form]
|
(defn stop-form [db form]
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
::clients
|
::clients
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(when (:user db)
|
(when (:user db)
|
||||||
(vals (:clients db)))))
|
(sort-by :name (vals (:clients db))))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::bank-accounts
|
::bank-accounts
|
||||||
|
|||||||
@@ -394,6 +394,8 @@
|
|||||||
(when error
|
(when error
|
||||||
[:div.notification.is-warning.animated.fadeInUp
|
[:div.notification.is-warning.animated.fadeInUp
|
||||||
error])
|
error])
|
||||||
|
|
||||||
|
|
||||||
[:submit.button.is-large.is-primary {:disabled (if (s/valid? ::entity/client @(re-frame/subscribe [::new-client-request]))
|
[:submit.button.is-large.is-primary {:disabled (if (s/valid? ::entity/client @(re-frame/subscribe [::new-client-request]))
|
||||||
""
|
""
|
||||||
"disabled")
|
"disabled")
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
(forms/stop-form ::new-invoice)
|
(forms/stop-form ::new-invoice)
|
||||||
(update-in [::invoice-page :print-checks-shown?] #(not %) )
|
(update-in [::invoice-page :print-checks-shown?] #(not %) )
|
||||||
(assoc-in [::advanced-print-checks] {:shown? true
|
(assoc-in [::advanced-print-checks] {:shown? true
|
||||||
:bank-account-id (:id (first (:bank-accounts @(re-frame/subscribe [::subs/clients]))))
|
:bank-account-id (:id (first @(re-frame/subscribe [::subs/bank-accounts])))
|
||||||
:invoices (->> checked
|
:invoices (->> checked
|
||||||
vals
|
vals
|
||||||
(map #(assoc % :amount (:outstanding-balance %))))} )))))
|
(map #(assoc % :amount (:outstanding-balance %))))} )))))
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
:db (-> db
|
:db (-> db
|
||||||
(forms/stop-form ::new-invoice)
|
(forms/stop-form ::new-invoice)
|
||||||
(update-in [::invoice-page :print-checks-shown?] #(not %) )
|
(update-in [::invoice-page :print-checks-shown?] #(not %) )
|
||||||
(assoc-in [::handwrite-checks] {:bank-account-id (:id (first (:bank-accounts @(re-frame/subscribe [::subs/client]))))
|
(assoc-in [::handwrite-checks] {:bank-account-id (:id (first @(re-frame/subscribe [::subs/bank-accounts])))
|
||||||
:amount (:outstanding-balance invoice)
|
:amount (:outstanding-balance invoice)
|
||||||
:invoice invoice } ))})))
|
:invoice invoice } ))})))
|
||||||
|
|
||||||
@@ -289,7 +289,10 @@
|
|||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(when @(re-frame/subscribe [::can-submit-edit-invoice])
|
(when @(re-frame/subscribe [::can-submit-edit-invoice])
|
||||||
(let [{:keys [data]} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
(let [{:keys [data]} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
||||||
{:graphql
|
{:db (-> db
|
||||||
|
(assoc-in [::forms/forms ::new-invoice :status] :loading)
|
||||||
|
(assoc-in [::forms/forms ::new-invoice :error] nil))
|
||||||
|
:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:operation/name "AddInvoice"}
|
:operation/name "AddInvoice"}
|
||||||
@@ -313,7 +316,10 @@
|
|||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(when @(re-frame/subscribe [::can-submit-edit-invoice])
|
(when @(re-frame/subscribe [::can-submit-edit-invoice])
|
||||||
(let [{{:keys [date total invoice-number id expense-accounts]} :data} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
(let [{{:keys [date total invoice-number id expense-accounts]} :data} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
||||||
{:graphql
|
{:db (-> db
|
||||||
|
(assoc-in [::forms/forms ::new-invoice :status] :loading)
|
||||||
|
(assoc-in [::forms/forms ::new-invoice :error] nil))
|
||||||
|
:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:operation/name "EditInvoice"}
|
:operation/name "EditInvoice"}
|
||||||
@@ -392,6 +398,10 @@
|
|||||||
(fn [{:keys [db]} [_ {:keys [add-invoice]}]]
|
(fn [{:keys [db]} [_ {:keys [add-invoice]}]]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(forms/stop-form ::new-invoice)
|
(forms/stop-form ::new-invoice)
|
||||||
|
(forms/start-form ::new-invoice {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||||
|
:status :unpaid
|
||||||
|
:date (date->str (c/now) standard)
|
||||||
|
:location (first (:locations @(re-frame/subscribe [::subs/client])))})
|
||||||
(update-in [::invoice-page :invoices]
|
(update-in [::invoice-page :invoices]
|
||||||
(fn [is]
|
(fn [is]
|
||||||
(into [(assoc add-invoice :class "live-added")]
|
(into [(assoc add-invoice :class "live-added")]
|
||||||
@@ -580,7 +590,7 @@
|
|||||||
|
|
||||||
(defn edit-invoice-form [{:keys [can-change-amount?]}]
|
(defn edit-invoice-form [{:keys [can-change-amount?]}]
|
||||||
[forms/side-bar-form {:form ::new-invoice }
|
[forms/side-bar-form {:form ::new-invoice }
|
||||||
(let [{:keys [data active? error]} @(re-frame/subscribe [::forms/form ::new-invoice])
|
(let [{:keys [data active? error id]} @(re-frame/subscribe [::forms/form ::new-invoice])
|
||||||
exists? (:id data)
|
exists? (:id data)
|
||||||
can-change-amount? (#{:unpaid ":unpaid"} (:status data))
|
can-change-amount? (#{:unpaid ":unpaid"} (:status data))
|
||||||
change-event [::forms/change ::new-invoice]
|
change-event [::forms/change ::new-invoice]
|
||||||
@@ -593,8 +603,15 @@
|
|||||||
should-select-location? (and locations
|
should-select-location? (and locations
|
||||||
(> (count locations) 1))
|
(> (count locations) 1))
|
||||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])]
|
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])]
|
||||||
^{:key (or (:id data) "new")}
|
^{:key id}
|
||||||
[:form
|
[:form { :on-submit (fn [e]
|
||||||
|
(println "x")
|
||||||
|
(when (.-stopPropagation e)
|
||||||
|
(.stopPropagation e)
|
||||||
|
(.preventDefault e))
|
||||||
|
(if exists?
|
||||||
|
(re-frame/dispatch-sync [::edit-invoice-saving])
|
||||||
|
(re-frame/dispatch-sync [::create-invoice])))}
|
||||||
[:h1.title.is-2 "New Invoice"]
|
[:h1.title.is-2 "New Invoice"]
|
||||||
(when-not @(re-frame/subscribe [::subs/client])
|
(when-not @(re-frame/subscribe [::subs/client])
|
||||||
[:div.field
|
[:div.field
|
||||||
@@ -603,6 +620,7 @@
|
|||||||
[bind-field
|
[bind-field
|
||||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/clients]))
|
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/clients]))
|
||||||
:type "typeahead"
|
:type "typeahead"
|
||||||
|
:auto-focus (if @(re-frame/subscribe [::subs/client]) false true)
|
||||||
:field [:client-id]
|
:field [:client-id]
|
||||||
:disabled exists?
|
:disabled exists?
|
||||||
:event [::change-new-invoice-client [::new-invoice]]
|
:event [::change-new-invoice-client [::new-invoice]]
|
||||||
@@ -628,7 +646,7 @@
|
|||||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors]))
|
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) @(re-frame/subscribe [::subs/vendors]))
|
||||||
:type "typeahead"
|
:type "typeahead"
|
||||||
:disabled exists?
|
:disabled exists?
|
||||||
:auto-focus true
|
:auto-focus (if @(re-frame/subscribe [::subs/client]) true false)
|
||||||
:field [:vendor-id]
|
:field [:vendor-id]
|
||||||
:text-field [:vendor-name]
|
:text-field [:vendor-name]
|
||||||
:event change-event
|
:event change-event
|
||||||
@@ -699,21 +717,14 @@
|
|||||||
:step "0.01"}]]]]]]])])
|
:step "0.01"}]]]]]]])])
|
||||||
|
|
||||||
(when error
|
(when error
|
||||||
[:div.notification.is-warning.animated.fadeInUp
|
^{:key error} [:div.notification.is-warning.animated.fadeInUp
|
||||||
error])
|
error])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[:submit.button.is-large.is-primary {:disabled (if (doto @(re-frame/subscribe [::can-submit-edit-invoice]) println)
|
[:button.button.is-large.is-primary {:disabled (if (doto @(re-frame/subscribe [::can-submit-edit-invoice]) println)
|
||||||
""
|
""
|
||||||
"disabled")
|
"disabled")
|
||||||
:on-click (fn [e]
|
|
||||||
#_(when (.-stopPropagation e)
|
|
||||||
(.stopPropagation e)
|
|
||||||
(.preventDefault e))
|
|
||||||
(if exists?
|
|
||||||
(re-frame/dispatch-sync [::edit-invoice-saving])
|
|
||||||
(re-frame/dispatch-sync [::create-invoice])))
|
|
||||||
:class (str @(re-frame/subscribe [::forms/loading-class ::new-invoice])
|
:class (str @(re-frame/subscribe [::forms/loading-class ::new-invoice])
|
||||||
(when error " animated shake"))} "Save"]])]
|
(when error " animated shake"))} "Save"]])]
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user