many more fields.
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
-- 1523250939 DOWN add-more-vendor-fields
|
||||||
|
alter table vendors
|
||||||
|
drop column address1;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column address2;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column city;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column state;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column zip;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column primary_contact;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column primary_email;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column primary_phone;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column secondary_contact;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column secondary_email;
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
drop column secondary_phone;
|
||||||
37
migrator/migrations/1523250939-UP-add-more-vendor-fields.sql
Normal file
37
migrator/migrations/1523250939-UP-add-more-vendor-fields.sql
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
-- 1523250939 UP add-more-vendor-fields
|
||||||
|
alter table vendors
|
||||||
|
add column address1 varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column address2 varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column city varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column state varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column zip varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column primary_contact varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column primary_email varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column primary_phone varchar (255);
|
||||||
|
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column secondary_contact varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column secondary_email varchar (255);
|
||||||
|
|
||||||
|
alter table vendors
|
||||||
|
add column secondary_phone varchar (255);
|
||||||
|
|
||||||
|
|
||||||
|
update vendors set primary_email=email;
|
||||||
@@ -21,17 +21,18 @@
|
|||||||
::save
|
::save
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
(let [edited-vendor (get-in db [:admin :vendor])
|
(let [edited-vendor (get-in db [:admin :vendor])
|
||||||
fx {:db (assoc-in db [:admin :vendor :saving?] true)}]
|
fx {:db (assoc-in db [:admin :vendor :saving?] true)}
|
||||||
|
all-fields [:name :email :data :invoice-reminder-schedule :primary-contact :primary-email :primary-phone :secondary-contact :secondary-email :secondary-phone :code :address1 :address2 :city :state :zip]]
|
||||||
(if (:id edited-vendor)
|
(if (:id edited-vendor)
|
||||||
(assoc fx :http {:method :put
|
(assoc fx :http {:method :put
|
||||||
:token (:user db)
|
:token (:user db)
|
||||||
:body (pr-str (select-keys edited-vendor [:name :email :data :invoice-reminder-schedule :code]))
|
:body (pr-str (select-keys edited-vendor all-fields))
|
||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:uri (str "/api/vendors/" (:id edited-vendor))
|
:uri (str "/api/vendors/" (:id edited-vendor))
|
||||||
:on-success [::save-complete]})
|
:on-success [::save-complete]})
|
||||||
(assoc fx :http {:method :post
|
(assoc fx :http {:method :post
|
||||||
:token (:user db)
|
:token (:user db)
|
||||||
:body (pr-str (select-keys edited-vendor [:name :email :data :invoice-reminder-schedule :code]))
|
:body (pr-str (select-keys edited-vendor all-fields))
|
||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:uri (str "/api/vendors")
|
:uri (str "/api/vendors")
|
||||||
:on-success [::save-complete]})))))
|
:on-success [::save-complete]})))))
|
||||||
|
|||||||
@@ -17,16 +17,16 @@
|
|||||||
[:th "Name"]
|
[:th "Name"]
|
||||||
[:th "Email"]
|
[:th "Email"]
|
||||||
[:th "Invoice Reminders"]]]
|
[:th "Invoice Reminders"]]]
|
||||||
[:tbody (for [{:keys [id name email data invoice-reminder-schedule]} @vendors]
|
[:tbody (for [{:keys [id name primary-email data invoice-reminder-schedule]} @vendors]
|
||||||
^{:key (str name "-" id )}
|
^{:key (str name "-" id )}
|
||||||
[:tr {:on-click (fn [] (re-frame/dispatch [::events/edit id]))
|
[:tr {:on-click (fn [] (re-frame/dispatch [::events/edit id]))
|
||||||
:style {"cursor" "pointer"}}
|
:style {"cursor" "pointer"}}
|
||||||
[:td name]
|
[:td name]
|
||||||
[:td email]
|
[:td primary-email]
|
||||||
[:td invoice-reminder-schedule]])]]))
|
[:td invoice-reminder-schedule]])]]))
|
||||||
|
|
||||||
(defn edit-dialog []
|
(defn edit-dialog []
|
||||||
(let [{:keys [name email invoice-reminder-schedule id code] :as editing-vendor} (:vendor @(re-frame/subscribe [::subs/admin]))]
|
(let [{:keys [name city state zip address1 address2 primary-contact primary-email primary-phone secondary-contact secondary-email secondary-phone invoice-reminder-schedule id code] :as editing-vendor} (:vendor @(re-frame/subscribe [::subs/admin]))]
|
||||||
[:div.modal.is-active
|
[:div.modal.is-active
|
||||||
[:div.modal-background {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]
|
[:div.modal-background {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]
|
||||||
|
|
||||||
@@ -38,39 +38,147 @@
|
|||||||
(str "Add " (or name "<new vendor>")))]
|
(str "Add " (or name "<new vendor>")))]
|
||||||
[:button.delete {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]]
|
[:button.delete {:on-click (fn [] (re-frame/dispatch [::events/edit nil]))}]]
|
||||||
[:section.modal-card-body
|
[:section.modal-card-body
|
||||||
[:div.field
|
[:div.field.is-horizontal
|
||||||
[:label.label "Name"]
|
[:div.field-label
|
||||||
[:div.control
|
[:label.label "Name"]]
|
||||||
[:input.input {:type "text" :value name
|
[:div.field-body
|
||||||
:on-change (dispatch-value-change [::events/change [:name]])}]]]
|
[:div.field
|
||||||
[:div.field
|
[:div.control
|
||||||
[:label.label "Code"]
|
[:input.input {:type "text" :value name
|
||||||
[:div.control
|
:on-change (dispatch-value-change [::events/change [:name]])}]]]]]
|
||||||
[:input.input {:type "text" :value code
|
[:div.field.is-horizontal
|
||||||
:on-change (dispatch-value-change [::events/change [:code]])}]]
|
[:div.field-label
|
||||||
[:p.help "The vendor code is used for invoice parsing. Only one vendor at a time can use a code"]]
|
[:label.label "Code"]]
|
||||||
|
[:div.field-body
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
[:input.input.is-expanded {:type "text" :value code
|
||||||
|
:on-change (dispatch-value-change [::events/change [:code]])}]
|
||||||
|
[:p.help "The vendor code is used for invoice parsing. Only one vendor at a time can use a code"]]]]
|
||||||
|
]
|
||||||
|
|
||||||
[:div.field
|
[:h2.subtitle "Address"]
|
||||||
[:label.label "Email"]
|
[:div.field.is-horizontal
|
||||||
[:div.control
|
[:div.field-label]
|
||||||
[:input.input {:type "email"
|
[:div.field-body
|
||||||
:value email
|
[:div.field
|
||||||
:on-change (dispatch-value-change [::events/change [:email]])}]]]
|
[:div.control
|
||||||
|
[:p.help "Address"]
|
||||||
|
[:input.input.is-expanded {:type "text"
|
||||||
|
:placeholder "1700 Pennsylvania Ave"
|
||||||
|
:value address1
|
||||||
|
:on-change (dispatch-value-change [::events/change [:address1]])}]]]]]
|
||||||
|
[:div.field.is-horizontal
|
||||||
|
[:div.field-label]
|
||||||
|
[:div.field-body
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
|
||||||
|
[:input.input.is-expanded {:type "text"
|
||||||
|
:placeholder "Suite 400"
|
||||||
|
:value address2
|
||||||
|
:on-change (dispatch-value-change [::events/change [:address2]])}]]]]]
|
||||||
|
[:div.field.is-horizontal
|
||||||
|
[:div.field-label]
|
||||||
|
[:div.field-body
|
||||||
|
[:div.field
|
||||||
|
[:p.help "City"]
|
||||||
|
[:div.control
|
||||||
|
[:input.input.is-expanded {:type "text"
|
||||||
|
:value city
|
||||||
|
:placeholder "Cupertino"
|
||||||
|
:on-change (dispatch-value-change [::events/change [:city]])}]]]
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
|
||||||
|
[:p.help "State"]
|
||||||
|
[:input.input {:type "email"
|
||||||
|
:value state
|
||||||
|
:placeholder "CA"
|
||||||
|
:on-change (dispatch-value-change [::events/change [:state]])}]
|
||||||
|
]]
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:labal.label "Invoice Reminders"]
|
[:div.control
|
||||||
[:div.control
|
[:p.help "Zip"]
|
||||||
[:label.radio
|
[:input.input {:type "phone"
|
||||||
[:input {:type "radio"
|
:value zip
|
||||||
:name "schedule"
|
:placeholder "95014"
|
||||||
:value "Weekly"
|
:on-change (dispatch-value-change [::events/change [:zip]])}]
|
||||||
:checked (if (= "Weekly" invoice-reminder-schedule)
|
]]]]
|
||||||
"checked"
|
[:h2.subtitle "Contact"]
|
||||||
"")
|
|
||||||
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
|
||||||
" Send weekly"]]
|
[:div.field.is-horizontal
|
||||||
[:div.control
|
[:div.field-label
|
||||||
[:label.radio
|
[:label.label "Primary"]]
|
||||||
|
[:div.field-body
|
||||||
|
[:div.field
|
||||||
|
[:div.control.has-icons-left
|
||||||
|
[:input.input.is-expanded {:type "text"
|
||||||
|
:value primary-contact
|
||||||
|
:on-change (dispatch-value-change [::events/change [:primary-contact]])}]
|
||||||
|
[:span.icon.is-small.is-left
|
||||||
|
[:i.fa.fa-user]]]]
|
||||||
|
[:div.field
|
||||||
|
[:div.control.has-icons-left
|
||||||
|
[:span.icon.is-small.is-left
|
||||||
|
[:i.fa.fa-envelope]]
|
||||||
|
[:input.input {:type "email"
|
||||||
|
:value primary-email
|
||||||
|
:on-change (dispatch-value-change [::events/change [:primary-email]])}]]]
|
||||||
|
|
||||||
|
[:div.field
|
||||||
|
[:div.control.has-icons-left
|
||||||
|
[:input.input {:type "phone"
|
||||||
|
:value primary-phone
|
||||||
|
:on-change (dispatch-value-change [::events/change [:primary-phone]])}]
|
||||||
|
[:span.icon.is-small.is-left
|
||||||
|
[:i.fa.fa-phone]]]]]]
|
||||||
|
[:div.field.is-horizontal
|
||||||
|
[:div.field-label
|
||||||
|
[:label.label "Secondary"]]
|
||||||
|
[:div.field-body
|
||||||
|
[:div.field
|
||||||
|
[:div.control.has-icons-left
|
||||||
|
[:input.input.is-expanded {:type "text"
|
||||||
|
:value secondary-contact
|
||||||
|
:on-change (dispatch-value-change [::events/change [:secondary-contact]])}]
|
||||||
|
[:span.icon.is-small.is-left
|
||||||
|
[:i.fa.fa-user]]]]
|
||||||
|
[:div.field
|
||||||
|
[:div.control.has-icons-left
|
||||||
|
[:span.icon.is-small.is-left
|
||||||
|
[:i.fa.fa-envelope]]
|
||||||
|
[:input.input {:type "email"
|
||||||
|
:value secondary-email
|
||||||
|
:on-change (dispatch-value-change [::events/change [:secondary-email]])}]]]
|
||||||
|
|
||||||
|
[:div.field
|
||||||
|
[:div.control.has-icons-left
|
||||||
|
[:input.input {:type "phone"
|
||||||
|
:value secondary-phone
|
||||||
|
:on-change (dispatch-value-change [::events/change [:secondary-phone]])}]
|
||||||
|
[:span.icon.is-small.is-left
|
||||||
|
[:i.fa.fa-phone]]]]]]
|
||||||
|
|
||||||
|
[:div.field.is-horizontal
|
||||||
|
[:div.field-label
|
||||||
|
[:label.label "Invoice Reminders"]]
|
||||||
|
[:div.field-body
|
||||||
|
[:div.field
|
||||||
|
[:div.control
|
||||||
|
[:label.radio
|
||||||
|
[:input {:type "radio"
|
||||||
|
:name "schedule"
|
||||||
|
:value "Weekly"
|
||||||
|
:checked (if (= "Weekly" invoice-reminder-schedule)
|
||||||
|
"checked"
|
||||||
|
"")
|
||||||
|
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
||||||
|
|
||||||
|
" Send weekly"]
|
||||||
|
[:label.radio
|
||||||
[:input {:type "radio"
|
[:input {:type "radio"
|
||||||
:name "schedule"
|
:name "schedule"
|
||||||
:value "Never"
|
:value "Never"
|
||||||
@@ -78,7 +186,8 @@
|
|||||||
"checked"
|
"checked"
|
||||||
"")
|
"")
|
||||||
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
:on-change (dispatch-value-change [::events/change [:invoice-reminder-schedule]])}]
|
||||||
" Never"]]]
|
" Never"]]]]
|
||||||
|
]
|
||||||
|
|
||||||
(when (:saving? editing-vendor) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]
|
(when (:saving? editing-vendor) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user