a lot of prep for editing customers
This commit is contained in:
@@ -11,20 +11,18 @@
|
||||
(defn companies-table []
|
||||
(let [companies (re-frame/subscribe [::subs/companies])
|
||||
admin-companies (re-frame/subscribe [::subs/admin-companies])
|
||||
selected-company (:selected @admin-companies)]
|
||||
editing-company (:editing @admin-companies)]
|
||||
[:table {:class "table", :style {:width "100%"}}
|
||||
[:thead
|
||||
[:tr
|
||||
[:th ""]
|
||||
[:th "Name"]
|
||||
[:th ""]]]
|
||||
[:tbody (for [{:keys [id name data] :as c} @companies]
|
||||
[:th "Email"]]]
|
||||
[:tbody (for [{:keys [id name email data] :as c} @companies]
|
||||
^{:key (str name "-" id )}
|
||||
[:tr {:on-click (fn [] (re-frame/dispatch [::events/select-company id]))
|
||||
[:tr {:on-click (fn [] (re-frame/dispatch [::events/edit-company id]))
|
||||
:style {"cursor" "pointer"}}
|
||||
[:td id]
|
||||
[:td name]
|
||||
[:td [:i.fa.fa-pencil]]])]]))
|
||||
[:td email]])]]))
|
||||
|
||||
(defn admin-companies-page []
|
||||
[:div {:class "inbox-messages"}
|
||||
@@ -33,28 +31,48 @@
|
||||
[:div.container
|
||||
(let [companies (re-frame/subscribe [::subs/companies])
|
||||
admin-companies (re-frame/subscribe [::subs/admin-companies])
|
||||
selected-company (:selected @admin-companies)]
|
||||
(if selected-company
|
||||
[:div
|
||||
[:h1.title "Companies > " (:name selected-company)]
|
||||
|
||||
[:label {:for "company-name"} "Name"]
|
||||
[:input#company-name.input {:type "text" :value (:name selected-company)}]
|
||||
editing-company (:editing @admin-companies)]
|
||||
|
||||
[:div
|
||||
[:h1.title "Companies"]
|
||||
[companies-table]
|
||||
[:a.button.is-primary "New Company"]
|
||||
|
||||
[:label {:for "email"} "Email"]
|
||||
[:input#email.input {:type "email" :value (:email selected-company)}]
|
||||
|
||||
[:label {:for "data"} "Data"]
|
||||
[:input#data.input {:type "text" :value (:data selected-company)}]
|
||||
(when editing-company
|
||||
[:div.modal.is-active
|
||||
[:div.modal-background {:on-click (fn [] (re-frame/dispatch [::events/edit-company 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-company nil]))}]]
|
||||
[:section.modal-card-body
|
||||
[:label {:for "company-name"} "Name"]
|
||||
[:input#company-name.input {:type "text" :value (:name editing-company)
|
||||
:on-change (fn [e]
|
||||
(re-frame/dispatch [::events/change-editing-company [:name]
|
||||
(.. e -target -value)]))}]
|
||||
|
||||
[:label {:for "check"} "Send invoice reminders?"]
|
||||
[:input#check.checkbox {:type "checkbox" :value (:send-reminders selected-company)}]
|
||||
[:div]
|
||||
|
||||
[:a.button {:on-click (fn [] (re-frame/dispatch [::events/select-company nil]))} "Back"]
|
||||
[:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/select-company nil]))} "Save"]]
|
||||
[:div
|
||||
[:h1.title "Companies"]
|
||||
[companies-table]
|
||||
[:a.button.is-primary "New Company"]]))]]]])
|
||||
[:label {:for "email"} "Email"]
|
||||
[:input#email.input {:type "email"
|
||||
:value (:email editing-company)
|
||||
:on-change (fn [e]
|
||||
(re-frame/dispatch [::events/change-editing-company [:email]
|
||||
(.. e -target -value)]))}]
|
||||
[:div.control
|
||||
[:label {:for "check"} "Send invoice reminders?"
|
||||
[:input#check.checkbox {:type "checkbox" :value (:send-reminders editing-company)}]]]
|
||||
|
||||
|
||||
|
||||
(when (:saving? editing-company) [:div.is-overlay {:style {"background-color" "rgba(150,150,150, 0.5)"}}])]
|
||||
|
||||
[:footer.modal-card-foot
|
||||
[:a.button.is-primary {:on-click (fn [] (re-frame/dispatch [::events/save-editing-company]))}
|
||||
[:span "Save"]
|
||||
(when (:saving? editing-company)
|
||||
[:span.icon
|
||||
[:i.fa.fa-spin.fa-spinner]])]]]])])]]]])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user