partial.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field]]
|
||||
[auto-ap.views.components.modal :refer [modal]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
[bidi.bidi :as bidi]))
|
||||
@@ -34,58 +35,46 @@
|
||||
[:h1.title "Companies"]
|
||||
[companies-table]
|
||||
|
||||
|
||||
|
||||
(when editing-company
|
||||
[:div.modal.is-active
|
||||
[:div.modal-background {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]
|
||||
|
||||
[:div.modal-card
|
||||
[:header.modal-card-head
|
||||
[:p.modal-card-title
|
||||
(str "Edit " (:name editing-company))]
|
||||
[:button.delete {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]]
|
||||
[:section.modal-card-body
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Name"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :name
|
||||
:spec ::entity/name
|
||||
:event ::events/change
|
||||
:subscription editing-company}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Email"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field :email
|
||||
:spec ::entity/name
|
||||
:event ::events/change
|
||||
:subscription editing-company}]]]]
|
||||
|
||||
[:h2.subtitle "Address"]
|
||||
|
||||
[address-field {:field [:address]
|
||||
[modal {:title (str "Edit " (:name editing-company))
|
||||
:foot [:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save]))}
|
||||
[:span "Save"]
|
||||
(when (:saving? editing-company)
|
||||
[: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-company}]
|
||||
:subscription editing-company}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Bank Accounts"]
|
||||
[:div.control
|
||||
[:ul
|
||||
(for [{:keys [number check-number id]} (:bank-accounts editing-company)]
|
||||
^{:key id} [:li number " - " check-number])]]]
|
||||
|
||||
|
||||
(when (:saving? editing-company) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]
|
||||
|
||||
[:footer.modal-card-foot
|
||||
[:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save]))}
|
||||
[:span "Save"]
|
||||
(when (:saving? editing-company)
|
||||
[:span.icon
|
||||
[:i.fa.fa-spin.fa-spinner]])]]]])])])
|
||||
[horizontal-field
|
||||
[:label.label "Email"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "email"
|
||||
:field :email
|
||||
:spec ::entity/name
|
||||
:event ::events/change
|
||||
:subscription editing-company}]]]]
|
||||
|
||||
[:h2.subtitle "Address"]
|
||||
|
||||
[address-field {:field [:address]
|
||||
:event ::events/change
|
||||
:subscription editing-company}]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Bank Accounts"]
|
||||
[:div.control
|
||||
[:ul
|
||||
(for [{:keys [number check-number id]} (:bank-accounts editing-company)]
|
||||
^{:key id} [:li number " - " check-number])]]]
|
||||
|
||||
|
||||
(when (:saving? editing-company) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])])])])
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
[auto-ap.events.admin.vendors :as events]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.components.modal :refer [modal]]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change dispatch-event bind-field horizontal-field]]
|
||||
[cljs.reader :as edn]
|
||||
@@ -55,188 +56,179 @@
|
||||
(let [editing-vendor (:vendor @(re-frame/subscribe [::subs/admin]))
|
||||
companies-by-id @(re-frame/subscribe [::subs/companies-by-id])]
|
||||
|
||||
[:div.modal.is-active
|
||||
[:div.modal-background {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]
|
||||
[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]}
|
||||
|
||||
[:div.modal-card
|
||||
[:header.modal-card-head
|
||||
[:p.modal-card-title
|
||||
(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]])
|
||||
[:button.delete {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]]
|
||||
[:section.modal-card-body
|
||||
[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]
|
||||
[horizontal-field
|
||||
[:label.label "Name"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :name
|
||||
:spec ::entity/name
|
||||
: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]]]
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
[horizontal-field
|
||||
[:label.label "Code"]
|
||||
[:div.control
|
||||
|
||||
[: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}]]]
|
||||
[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"]]]
|
||||
|
||||
[: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 "Clients"]
|
||||
|
||||
[horizontal-field
|
||||
nil
|
||||
[:div.control
|
||||
[:div.select.is-expanded
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field :new-relationship-company
|
||||
[:h2.subtitle "Address"]
|
||||
[address-field {:field [:address]
|
||||
: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)"}}])]
|
||||
|
||||
[:footer.modal-card-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]])]]]]))
|
||||
: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 "Clients"]
|
||||
|
||||
[horizontal-field
|
||||
nil
|
||||
[:div.control
|
||||
[: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
|
||||
|
||||
Reference in New Issue
Block a user