more specs.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
[auto-ap.events.admin.vendors :as events]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change dispatch-event]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change dispatch-event bind-field horizontal-field]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
[bidi.bidi :as bidi]))
|
||||
@@ -33,10 +33,6 @@
|
||||
[:td (::entity/primary-email v)]
|
||||
[:td (::entity/invoice-reminder-schedule v)]])]]))
|
||||
|
||||
(defmulti do-bind (fn [_ {:keys [type]}]
|
||||
|
||||
type))
|
||||
|
||||
(defn danger-for [[dom {:keys [field subscription class] :as keys} & rest]]
|
||||
(let [keys (assoc keys :class (str class
|
||||
(when (not (s/valid? field (field subscription)))
|
||||
@@ -45,39 +41,6 @@
|
||||
(vec (concat [dom keys] rest))))
|
||||
|
||||
|
||||
(defmethod do-bind "radio" [dom {:keys [field subscription class value] :as keys} & rest]
|
||||
(let [keys (assoc keys
|
||||
:on-change (dispatch-value-change [::events/change [field]])
|
||||
:checked (= (field subscription) value)
|
||||
:class (str class
|
||||
(when (not (s/valid? field (field subscription)))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription)]
|
||||
(vec (concat [dom keys] rest))))
|
||||
|
||||
|
||||
(defmethod do-bind :default [dom {:keys [field subscription class] :as keys} & rest]
|
||||
(let [keys (assoc keys
|
||||
:on-change (dispatch-value-change [::events/change [field]])
|
||||
:value (field subscription)
|
||||
:class (str class
|
||||
(when (not (s/valid? field (field subscription)))
|
||||
" is-danger")))
|
||||
keys (dissoc keys :field :subscription)]
|
||||
(vec (concat [dom keys] rest))))
|
||||
|
||||
(defn bind-field [all]
|
||||
(apply do-bind all))
|
||||
|
||||
(defn horizontal-field [label & controls]
|
||||
[:div.field.is-horizontal
|
||||
[:div.field-label
|
||||
label
|
||||
]
|
||||
(into
|
||||
[:div.field-body
|
||||
]
|
||||
(map (fn [c] [:div.field c]) controls))])
|
||||
|
||||
(defn edit-dialog []
|
||||
(let [editing-vendor (:vendor @(re-frame/subscribe [::subs/admin]))]
|
||||
@@ -101,6 +64,7 @@
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field ::entity/name
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
[horizontal-field
|
||||
@@ -110,6 +74,7 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field ::entity/code
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:p.help "The vendor code is used for invoice parsing. Only one vendor at a time can use a code"]]]
|
||||
|
||||
@@ -122,6 +87,7 @@
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "1700 Pennsylvania Ave"
|
||||
:field ::entity/address1
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
[horizontal-field
|
||||
@@ -131,6 +97,7 @@
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "Suite 400"
|
||||
:field ::entity/address2
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
[horizontal-field
|
||||
@@ -141,6 +108,7 @@
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "Cupertino"
|
||||
:field ::entity/city
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
[:div.control
|
||||
[:p.help "State"]
|
||||
@@ -148,12 +116,14 @@
|
||||
[:input.input {:type "text"
|
||||
:placeholder "CA"
|
||||
:field ::entity/state
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
[:div.control
|
||||
[:p.help "Zip"]
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field ::entity/zip
|
||||
:event ::events/change
|
||||
:subscription editing-vendor
|
||||
:placeholder "95014"}]]]]
|
||||
|
||||
@@ -164,6 +134,7 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field ::entity/primary-contact
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-user]]]
|
||||
@@ -174,12 +145,14 @@
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field ::entity/primary-email
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field ::entity/primary-phone
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-phone]]]]
|
||||
@@ -190,6 +163,7 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field ::entity/secondary-contact
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-user]]]
|
||||
@@ -199,11 +173,13 @@
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field ::entity/secondary-email
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field ::entity/secondary-phone
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-phone]]]]
|
||||
@@ -217,6 +193,7 @@
|
||||
:name "schedule"
|
||||
:value "Weekly"
|
||||
:field ::entity/invoice-reminder-schedule
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
" Send weekly"]
|
||||
|
||||
@@ -226,6 +203,7 @@
|
||||
:name "schedule"
|
||||
:value "Never"
|
||||
:field ::entity/invoice-reminder-schedule
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
" Never"]]]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user