address refactoring.

This commit is contained in:
Bryce Covert
2018-05-17 20:45:56 -07:00
parent 9e63624227
commit 4312c0e2ad
3 changed files with 69 additions and 105 deletions

View File

@@ -0,0 +1,60 @@
(ns auto-ap.views.components.address
(:require [auto-ap.entities.address :as address]
[auto-ap.views.utils :refer [dispatch-value-change dispatch-event bind-field horizontal-field]]))
(defn address-field [{:keys [event field subscription]}]
[:span
[horizontal-field
nil
[:div.control
[:p.help "Address"]
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "1700 Pennsylvania Ave"
:field (conj field :street1)
:spec ::address/street1
:event event
:subscription subscription}]]]]
[horizontal-field
nil
[:div.control
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "Suite 400"
:field (conj field :street2)
:spec ::address/street2
:event event
:subscription subscription}]]]]
[horizontal-field
nil
[:div.control
[:p.help "City"]
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "Cupertino"
:field (conj field :city)
:spec ::address/city
:event event
:subscription subscription}]]]
[:div.control
[:p.help "State"]
[bind-field
[:input.input {:type "text"
:placeholder "CA"
:field (conj field :state)
:spec ::address/state
:size 2
:max-length "2"
:event event
:subscription subscription}]]]
[:div.control
[:p.help "Zip"]
[bind-field
[:input.input {:type "text"
:field (conj field :zip)
:spec ::address/zip
:event event
:subscription subscription
:placeholder "95014"}]]]]])

View File

@@ -5,7 +5,7 @@
[auto-ap.subs :as subs]
[auto-ap.events.admin.companies :as events]
[auto-ap.entities.companies :as entity]
[auto-ap.entities.address :as address]
[auto-ap.views.components.address :refer [address-field]]
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field]]
[cljs.reader :as edn]
[auto-ap.routes :as routes]
@@ -68,59 +68,10 @@
:subscription editing-company}]]]]
[:h2.subtitle "Address"]
[horizontal-field
nil
[:div.control
[:p.help "Address"]
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "1700 Pennsylvania Ave"
:field [:address :street1]
:spec ::address/street1
:event ::events/change
:subscription editing-company}]]]]
[horizontal-field
nil
[:div.control
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "Suite 400"
:field [:address :street2]
:spec ::address/street2
:event ::events/change
:subscription editing-company}]]]]
[horizontal-field
nil
[:div.control
[:p.help "City"]
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "Cupertino"
:field [:address :city]
:spec ::address/city
:event ::events/change
:subscription editing-company}]]]
[:div.control
[:p.help "State"]
[bind-field
[:input.input {:type "text"
:placeholder "CA"
:field [:address :state]
:spec ::address/state
:event ::events/change
:subscription editing-company}]]]
[:div.control
[:p.help "Zip"]
[bind-field
[:input.input {:type "text"
:field [:address :zip]
:spec ::address/zip
:event ::events/change
:subscription editing-company
:placeholder "95014"}]]]]
[address-field {:field [:address]
:event ::events/change
:subscription editing-company}]
[horizontal-field
[:label.label "Bank Accounts"]

View File

@@ -6,7 +6,7 @@
[auto-ap.subs :as subs]
[auto-ap.events.admin.vendors :as events]
[auto-ap.entities.vendors :as entity]
[auto-ap.entities.address :as address]
[auto-ap.views.components.address :refer [address-field]]
[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]
@@ -92,58 +92,11 @@
[:p.help "The vendor code is used for invoice parsing. Only one vendor at a time can use a code"]]]
[:h2.subtitle "Address"]
[horizontal-field
nil
[:div.control
[:p.help "Address"]
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "1700 Pennsylvania Ave"
:field [:address :street1]
:spec ::address/street1
:event ::events/change
:subscription editing-vendor}]]]]
[address-field {:field [:address]
:event ::events/change
:subscription editing-vendor}]
[horizontal-field
nil
[:div.control
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "Suite 400"
:field [:address :street2]
:spec ::address/street2
:event ::events/change
:subscription editing-vendor}]]]]
[horizontal-field
nil
[:div.control
[:p.help "City"]
[bind-field
[:input.input.is-expanded {:type "text"
:placeholder "Cupertino"
:field [:address :city]
:spec ::address/city
:event ::events/change
:subscription editing-vendor}]]]
[:div.control
[:p.help "State"]
[bind-field
[:input.input {:type "text"
:placeholder "CA"
:field [:address :state]
:spec ::address/state
:event ::events/change
:subscription editing-vendor}]]]
[:div.control
[:p.help "Zip"]
[bind-field
[:input.input {:type "text"
:field [:address :zip]
:spec ::address/zip
:event ::events/change
:subscription editing-vendor
:placeholder "95014"}]]]]
[:h2.subtitle "Contact"]
[horizontal-field