Made it so customers can create vendors.
This commit is contained in:
159
src/cljs/auto_ap/views/components/vendor_dialog.cljs
Normal file
159
src/cljs/auto_ap/views/components/vendor_dialog.cljs
Normal file
@@ -0,0 +1,159 @@
|
||||
(ns auto-ap.views.components.vendor-dialog
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[auto-ap.views.utils :refer [dispatch-event horizontal-field bind-field]]
|
||||
[auto-ap.views.components.modal :refer [action-modal]]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
|
||||
[auto-ap.expense-accounts :refer [expense-accounts]]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[auto-ap.subs :as subs]))
|
||||
|
||||
|
||||
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
|
||||
(let [companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
||||
|
||||
[action-modal {:id id
|
||||
:title [:span (if (:id vendor)
|
||||
(str "Edit " (or name "<vendor>"))
|
||||
(str "Add " (or name "<new vendor>")))
|
||||
(when (:error vendor)
|
||||
[:span.icon.has-text-danger
|
||||
[:i.fa.fa-exclamation-triangle]])]
|
||||
:action-text "Save"
|
||||
:save-event save-event}
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Name"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :name
|
||||
:spec ::entity/name
|
||||
:event change-event
|
||||
:subscription vendor}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Code"]
|
||||
[:div.control
|
||||
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field :code
|
||||
:spec ::entity/code
|
||||
:event change-event
|
||||
:subscription 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 change-event
|
||||
:subscription 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 change-event
|
||||
:subscription 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 change-event
|
||||
:subscription vendor}]]]
|
||||
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field :primary-phone
|
||||
:spec ::entity/primary-phone
|
||||
:event change-event
|
||||
:subscription 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 change-event
|
||||
:subscription 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 change-event
|
||||
:subscription vendor}]]]
|
||||
[:div.control.has-icons-left
|
||||
[bind-field
|
||||
[:input.input {:type "phone"
|
||||
:field :secondary-phone
|
||||
:spec ::entity/secondary-phone
|
||||
:event change-event
|
||||
:subscription 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 change-event
|
||||
:subscription vendor}]]
|
||||
" Send weekly"]
|
||||
|
||||
[:label.radio
|
||||
[bind-field
|
||||
[:input {:type "radio"
|
||||
:name "schedule"
|
||||
:value "Never"
|
||||
:field :invoice-reminder-schedule
|
||||
:spec ::entity/invoice-reminder-schedule
|
||||
:event change-event
|
||||
:subscription 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 change-event
|
||||
:subscription vendor}]]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(when (:saving? vendor) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]))
|
||||
Reference in New Issue
Block a user