preventing submits.
This commit is contained in:
@@ -100,6 +100,35 @@
|
|||||||
.modal {
|
.modal {
|
||||||
animation: appear .7s ease both;
|
animation: appear .7s ease both;
|
||||||
}
|
}
|
||||||
|
@keyframes grow-width {
|
||||||
|
from {
|
||||||
|
width: 0px;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes shrink-width {
|
||||||
|
to {
|
||||||
|
width: 0px;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-in-right {
|
||||||
|
animation: grow-width 0.5s ease both;
|
||||||
|
}
|
||||||
|
.slide-in-right div {
|
||||||
|
width: 1000px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slide-out-right {
|
||||||
|
animation: shrink-width 0.5s ease both;
|
||||||
|
}
|
||||||
|
.slide-out-right div {
|
||||||
|
width: 1000px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.inbox-messages {
|
.inbox-messages {
|
||||||
animation: scaleUp .3s ease both;
|
animation: scaleUp .3s ease both;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,11 @@
|
|||||||
:invoice/client (:db/id (:invoice/client invoice))})
|
:invoice/client (:db/id (:invoice/client invoice))})
|
||||||
println))
|
println))
|
||||||
(throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
|
(throw (ex-info (str "Invoice '" invoice_number "' already exists.") {:invoice-number invoice_number})))
|
||||||
|
|
||||||
|
expense-account-total (reduce + 0 (map (fn [x] (Double/parseDouble (:amount x))) expense_accounts))
|
||||||
|
_ (when (not= total expense-account-total)
|
||||||
|
(let [error (str "Expense account total (" expense-account-total ") does not equal invoice total (" total ")")]
|
||||||
|
(throw (ex-info error {:validation-error error}))))
|
||||||
paid-amount (- (:invoice/total invoice) (:invoice/outstanding-balance invoice))
|
paid-amount (- (:invoice/total invoice) (:invoice/outstanding-balance invoice))
|
||||||
_ (assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))
|
_ (assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))
|
||||||
updated-invoice (d-invoices/update {:db/id id
|
updated-invoice (d-invoices/update {:db/id id
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
(defn appearing-side-bar [{:keys [visible?]} & children ]
|
(defn appearing-side-bar [{:keys [visible?]} & children ]
|
||||||
(let [final-state (reagent/atom visible?)]
|
(let [final-state (reagent/atom visible?)]
|
||||||
(fn [{:keys [visible?]} & children]
|
(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))}
|
[css-transition-group {:in visible? :class-names {:exitDone "bounce animated" :exit "slide-out-right" :enter "slide-in-right"} :timeout 500 :onEnter (fn [] (reset! final-state true )) :onExited (fn [] (reset! final-state false))}
|
||||||
(if (or @final-state visible?)
|
(if (or @final-state visible?)
|
||||||
[:aside {:class "column is-3 aside menu" :style {:height "calc(100vh - 46px)" :overflow "auto"}}
|
[:aside {:class "column is-3 aside menu" :style {:height "calc(100vh - 46px)" :overflow "auto"}}
|
||||||
[:div.sub-main {} children ]]
|
[:div.sub-main {} children ]]
|
||||||
|
|||||||
@@ -285,43 +285,45 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::create-invoice
|
::create-invoice
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [{:keys [data]} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
(when @(re-frame/subscribe [::can-submit-edit-invoice])
|
||||||
{:graphql
|
(let [{:keys [data]} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
||||||
{:token (-> db :user)
|
{:graphql
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
{:token (-> db :user)
|
||||||
:operation/name "AddInvoice"}
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
|
:operation/name "AddInvoice"}
|
||||||
:venia/queries [{:query/data [:add-invoice
|
|
||||||
{:invoice {:date (:date data)
|
:venia/queries [{:query/data [:add-invoice
|
||||||
:vendor-id (:vendor-id data)
|
{:invoice {:date (:date data)
|
||||||
:client-id (:client-id data)
|
:vendor-id (:vendor-id data)
|
||||||
:invoice-number (:invoice-number data)
|
:client-id (:client-id data)
|
||||||
:location (:location data)
|
:invoice-number (:invoice-number data)
|
||||||
:total (:total data)
|
:location (:location data)
|
||||||
}}
|
:total (:total data)
|
||||||
invoice-read]}]}
|
}}
|
||||||
:on-success [::invoice-created]
|
invoice-read]}]}
|
||||||
:on-error [::forms/save-error ::new-invoice]}})))
|
:on-success [::invoice-created]
|
||||||
|
:on-error [::forms/save-error ::new-invoice]}}))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::edit-invoice-saving
|
::edit-invoice-saving
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [{{:keys [date total invoice-number id expense-accounts]} :data} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
(when @(re-frame/subscribe [::can-submit-edit-invoice])
|
||||||
{:graphql
|
(let [{{:keys [date total invoice-number id expense-accounts]} :data} @(re-frame/subscribe [::forms/form ::new-invoice])]
|
||||||
{:token (-> db :user)
|
{:graphql
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
{:token (-> db :user)
|
||||||
:operation/name "EditInvoice"}
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
|
:operation/name "EditInvoice"}
|
||||||
:venia/queries [{:query/data [:edit-invoice
|
|
||||||
{:invoice {:id id :invoice-number invoice-number :date date :total total :expense-accounts (map (fn [ea]
|
:venia/queries [{:query/data [:edit-invoice
|
||||||
{:id (:id ea)
|
{:invoice {:id id :invoice-number invoice-number :date date :total total :expense-accounts (map (fn [ea]
|
||||||
:amount (:amount ea)})
|
{:id (:id ea)
|
||||||
expense-accounts)}}
|
:amount (:amount ea)})
|
||||||
invoice-read]}]}
|
expense-accounts)}}
|
||||||
:on-success [::invoice-edited]
|
invoice-read]}]}
|
||||||
:on-error [::forms/save-error ::new-invoice]}})))
|
:on-success [::invoice-edited]
|
||||||
|
:on-error [::forms/save-error ::new-invoice]}}))))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::unvoid-invoice
|
::unvoid-invoice
|
||||||
@@ -499,6 +501,18 @@
|
|||||||
:max outstanding-balance
|
:max outstanding-balance
|
||||||
:step "0.01"}]]]]]])]]])))
|
:step "0.01"}]]]]]])]]])))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::can-submit-edit-invoice
|
||||||
|
:<- [::forms/form ::new-invoice]
|
||||||
|
(fn [{:keys [data]} _]
|
||||||
|
(let [min-total (if (= (:total (:original data)) (:outstanding-balance (:original data)))
|
||||||
|
nil
|
||||||
|
(- (:total (:original data)) (:outstanding-balance (:original data))))]
|
||||||
|
(and (s/valid? ::invoice/invoice data)
|
||||||
|
(or (not min-total) (>= (:total data) min-total))
|
||||||
|
(or (not (:id data))
|
||||||
|
(< (.abs js/Math (- (js/parseFloat (:total data)) (reduce + 0 (map (fn [ea] (js/parseFloat (:amount ea))) (:expense-accounts data))))) 0.001))))))
|
||||||
|
|
||||||
(defn handwrite-checks-modal []
|
(defn handwrite-checks-modal []
|
||||||
(let [{:keys [checked]} @(re-frame/subscribe [::invoice-page])
|
(let [{:keys [checked]} @(re-frame/subscribe [::invoice-page])
|
||||||
{:keys [invoice] :as handwrite-checks} @(re-frame/subscribe [::handwrite-checks])
|
{:keys [invoice] :as handwrite-checks} @(re-frame/subscribe [::handwrite-checks])
|
||||||
@@ -688,10 +702,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
[:submit.button.is-large.is-primary {:disabled (if (and (s/valid? ::invoice/invoice data)
|
[:submit.button.is-large.is-primary {:disabled (if (doto @(re-frame/subscribe [::can-submit-edit-invoice]) println)
|
||||||
(or (not min-total) (>= (:total data) min-total))
|
|
||||||
(or (not exists?)
|
|
||||||
(< (.abs js/Math (- (js/parseFloat (:total data)) (reduce + 0 (map (fn [ea] (js/parseFloat (:amount ea))) (:expense-accounts data))))) 0.001)))
|
|
||||||
""
|
""
|
||||||
"disabled")
|
"disabled")
|
||||||
:on-click (fn [e]
|
:on-click (fn [e]
|
||||||
|
|||||||
Reference in New Issue
Block a user