vendors can be updated through datomic.
This commit is contained in:
@@ -8,10 +8,11 @@
|
||||
[auto-ap.expense-accounts :refer [chooseable-expense-accounts]]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[auto-ap.entities.contact :as contact]
|
||||
[auto-ap.subs :as subs]))
|
||||
|
||||
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
|
||||
|
||||
(println (s/explain ::entity/vendor vendor) )
|
||||
(let [companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
||||
[action-modal {:id id
|
||||
:title [:span (if (:id vendor)
|
||||
@@ -82,7 +83,7 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field [:primary-contact :name]
|
||||
:spec ::entity/primary-contact
|
||||
:spec ::contact/name
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
@@ -94,7 +95,7 @@
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field [:primary-contact :email]
|
||||
:spec ::entity/primary-email
|
||||
:spec ::contact/email
|
||||
:event change-event
|
||||
:subscription vendor}]]]
|
||||
|
||||
@@ -102,7 +103,7 @@
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field [:primary-contact :phone]
|
||||
:spec ::entity/primary-phone
|
||||
:spec ::contact/phone
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
@@ -114,7 +115,7 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field [:secondary-contact :name]
|
||||
:spec ::entity/secondary-contact
|
||||
:spec ::contact/name
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
@@ -125,14 +126,14 @@
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field [:secondary-contact :email]
|
||||
:spec ::entity/secondary-email
|
||||
:spec ::contact/email
|
||||
:event change-event
|
||||
:subscription vendor}]]]
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field [:secondary-contact :phone]
|
||||
:spec ::entity/secondary-phone
|
||||
:spec ::contact/phone
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
|
||||
@@ -55,197 +55,6 @@
|
||||
(vec (concat [dom keys] rest))))
|
||||
|
||||
|
||||
#_(defn edit-dialog []
|
||||
(let [editing-vendor (:vendor @(re-frame/subscribe [::subs/admin]))
|
||||
companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
||||
|
||||
[modal {:title [:span (if (:id editing-vendor)
|
||||
(str "Edit " (or (:name editing-vendor) "<vendor>"))
|
||||
(str "Add " (or (:name editing-vendor) "<new vendor>")))
|
||||
(when (:error editing-vendor)
|
||||
[:span.icon.has-text-danger
|
||||
[:i.fa.fa-exclamation-triangle]])]
|
||||
:foot [:button.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save]))
|
||||
:disabled (when (not (s/valid? ::entity/vendor editing-vendor ))
|
||||
"disabled")}
|
||||
[:span "Save"]
|
||||
(when (:saving? editing-vendor)
|
||||
[:span.icon
|
||||
[:i.fa.fa-spin.fa-spinner]])]
|
||||
:hide-event [::events/edit nil]}
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Name"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :name
|
||||
:spec ::entity/name
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Code"]
|
||||
[:div.control
|
||||
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field :code
|
||||
:spec ::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"]]]
|
||||
|
||||
[:h2.subtitle "Address"]
|
||||
[address-field {:field [:address]
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]
|
||||
|
||||
|
||||
|
||||
[:h2.subtitle "Contact"]
|
||||
[horizontal-field
|
||||
[:label.label "Primary"]
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field :primary-contact
|
||||
:spec ::entity/primary-contact
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-user]]]
|
||||
|
||||
[:div.control.has-icons-left
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-envelope]]
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field :primary-email
|
||||
:spec ::entity/primary-email
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field :primary-phone
|
||||
:spec ::entity/primary-phone
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-phone]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Secondary"]
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field :secondary-contact
|
||||
:spec ::entity/secondary-contact
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-user]]]
|
||||
[:div.control.has-icons-left
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-envelope]]
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field :secondary-email
|
||||
:spec ::entity/secondary-email
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field :secondary-phone
|
||||
:spec ::entity/secondary-phone
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
[:span.icon.is-small.is-left
|
||||
[:i.fa.fa-phone]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Invoice Reminders"]
|
||||
[:div.control
|
||||
[:label.radio
|
||||
[bind-field
|
||||
[:input {:type "radio"
|
||||
:name "schedule"
|
||||
:value "Weekly"
|
||||
:field :invoice-reminder-schedule
|
||||
:spec ::entity/invoice-reminder-schedule
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
" Send weekly"]
|
||||
|
||||
[:label.radio
|
||||
[bind-field
|
||||
[:input {:type "radio"
|
||||
:name "schedule"
|
||||
:value "Never"
|
||||
:field :invoice-reminder-schedule
|
||||
:spec ::entity/invoice-reminder-schedule
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]
|
||||
" Never"]]]
|
||||
|
||||
[:h2.subtitle "Expense Accounts"]
|
||||
[horizontal-field
|
||||
[:label.label "Default"]
|
||||
[bind-field
|
||||
[typeahead {:matches (map (fn [[k v]] [k (:name v)]) expense-accounts)
|
||||
:type "typeahead"
|
||||
:field [:default-expense-account]
|
||||
:spec ::entity/default-expense-account
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
|
||||
|
||||
|
||||
|
||||
#_[:h2.subtitle "Clients"]
|
||||
|
||||
#_[horizontal-field
|
||||
nil
|
||||
[:div.control@(re-frame/subscribe [::subs/exp])
|
||||
[:div.select.is-expanded
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field :new-relationship-company
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}
|
||||
(for [company @(re-frame/subscribe [::subs/companies])]
|
||||
[:option {:value (:id company)} (:name company)])]]]]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :new-relationship-account-number
|
||||
:subscription editing-vendor
|
||||
:event ::events/change
|
||||
:placeholder "Account number"}]]]
|
||||
[:div.control
|
||||
[:button.button.is-primary
|
||||
{:on-click (dispatch-event [::events/add-relationship])}
|
||||
[:span.icon
|
||||
[:i.fa.fa-plus]]]]]
|
||||
#_[horizontal-field
|
||||
nil
|
||||
[:ul
|
||||
(for [[i r] (map vector (range) (:relationships editing-vendor))]
|
||||
^{:key i}
|
||||
[:li
|
||||
(:name (companies-by-id (js/parseInt (:company-id r)))) ": "
|
||||
(:account-number r)
|
||||
[:a
|
||||
{:on-click (dispatch-event [::events/remove-relationship i])}
|
||||
[:span.icon
|
||||
[:i.fa.fa-times]]]])]]
|
||||
|
||||
|
||||
(when (:saving? editing-vendor) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]))
|
||||
|
||||
(defn admin-vendors-page []
|
||||
[(with-meta
|
||||
(fn []
|
||||
|
||||
Reference in New Issue
Block a user