adding new invoices has validation.
This commit is contained in:
@@ -5,5 +5,5 @@
|
|||||||
(defn edit-user [context args value]
|
(defn edit-user [context args value]
|
||||||
(users/update! (:edit_user args))
|
(users/update! (:edit_user args))
|
||||||
(->graphql
|
(->graphql
|
||||||
(users/get-by-id (:edit_user args))))
|
(users/get-by-id (:id (:edit_user args)))))
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
(s/def ::date ::shared/date)
|
(s/def ::date ::shared/date)
|
||||||
(s/def ::total ::shared/money)
|
(s/def ::total ::shared/money)
|
||||||
|
|
||||||
(s/def ::invoice (s/keys :opt-un [::vendor-id
|
(s/def ::invoice (s/keys :req-un [::vendor-id
|
||||||
::company-id
|
::company-id
|
||||||
::invoice-number
|
::invoice-number
|
||||||
::date
|
::date
|
||||||
|
|||||||
@@ -21,13 +21,21 @@
|
|||||||
[:footer.modal-card-foot
|
[:footer.modal-card-foot
|
||||||
foot])]])
|
foot])]])
|
||||||
|
|
||||||
(defn action-modal [{:keys [title action-text id save-event]} & rest]
|
(defn action-modal [{:keys [title action-text id save-event can-submit?] :or {can-submit? true}} & rest]
|
||||||
(let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])]
|
(let [{:keys [visible? saving?]} @(re-frame/subscribe [::subs/modal-state id])]
|
||||||
(when visible?
|
(when visible?
|
||||||
(-> [modal {:title title
|
(-> [modal {:title title
|
||||||
:foot [:a.button.is-primary {:on-click (fn []
|
:foot [:button.button.is-primary {:on-click (fn []
|
||||||
(re-frame/dispatch [::events/modal-status id {:saving? true}])
|
(re-frame/dispatch [::events/modal-status id {:saving? true}])
|
||||||
(re-frame/dispatch save-event))
|
(re-frame/dispatch save-event))
|
||||||
|
:disabled (cond saving?
|
||||||
|
"disabled"
|
||||||
|
|
||||||
|
(not can-submit?)
|
||||||
|
"disabled"
|
||||||
|
|
||||||
|
:else
|
||||||
|
"")
|
||||||
:class (when saving?
|
:class (when saving?
|
||||||
"is-loading")}
|
"is-loading")}
|
||||||
[:span action-text]]
|
[:span action-text]]
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
[auto-ap.entities.companies :as company]
|
[auto-ap.entities.companies :as company]
|
||||||
[auto-ap.entities.invoice :as invoice]
|
[auto-ap.entities.invoice :as invoice]
|
||||||
[auto-ap.entities.vendors :as vendor]
|
[auto-ap.entities.vendors :as vendor]
|
||||||
@@ -269,11 +270,11 @@
|
|||||||
(defn new-invoice-modal []
|
(defn new-invoice-modal []
|
||||||
(let [data @(re-frame/subscribe [::new-invoice])
|
(let [data @(re-frame/subscribe [::new-invoice])
|
||||||
change-event [::events/change-form [::new-invoice]]]
|
change-event [::events/change-form [::new-invoice]]]
|
||||||
(println data)
|
|
||||||
[action-modal {:id ::new-invoice
|
[action-modal {:id ::new-invoice
|
||||||
:title "New Invoice"
|
:title "New Invoice"
|
||||||
:action-text "Create"
|
:action-text "Create"
|
||||||
:save-event [::create-invoice]}
|
:save-event [::create-invoice]
|
||||||
|
:can-submit? (s/valid? ::invoice/invoice data)}
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
[:label.label "Vendor"]
|
[:label.label "Vendor"]
|
||||||
[bind-field
|
[bind-field
|
||||||
|
|||||||
Reference in New Issue
Block a user