renamed company to client.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
[clojure.string :as str]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events :as events]
|
||||
[auto-ap.entities.companies :as entity]
|
||||
[auto-ap.entities.clients :as entity]
|
||||
[auto-ap.views.components.address :refer [address-field]]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event]]
|
||||
[auto-ap.views.components.modal :refer [modal action-modal]]
|
||||
@@ -55,14 +55,14 @@
|
||||
(dissoc db ::editing))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::add-company
|
||||
::add-client
|
||||
(fn [db [_ d]]
|
||||
(let [company (get @(re-frame/subscribe [::subs/companies-by-id])
|
||||
(get-in db [::editing :adding-company]))]
|
||||
(update-in db [::editing :user :clients] conj company))))
|
||||
(let [client (get @(re-frame/subscribe [::subs/clients-by-id])
|
||||
(get-in db [::editing :adding-client]))]
|
||||
(update-in db [::editing :user :clients] conj client))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-company
|
||||
::remove-client
|
||||
(fn [db [_ d]]
|
||||
(update-in db [::editing :user :clients] #(filter (fn [c] (not= (:id c) d)) %))))
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
(with-meta
|
||||
(fn []
|
||||
[:div
|
||||
(let [companies (re-frame/subscribe [::users])
|
||||
(let [clients (re-frame/subscribe [::users])
|
||||
editing @(re-frame/subscribe [::editing])]
|
||||
[:div
|
||||
[:h1.title "Users"]
|
||||
@@ -160,20 +160,20 @@
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field [:adding-company]
|
||||
:field [:adding-client]
|
||||
:event ::change
|
||||
:subscription editing}
|
||||
[:option]
|
||||
(let [used-companies (set (map :id (:clients (:user editing))))]
|
||||
(for [{:keys [id name]} @(re-frame/subscribe [::subs/companies])
|
||||
:when (not (used-companies id))]
|
||||
(let [used-clients (set (map :id (:clients (:user editing))))]
|
||||
(for [{:keys [id name]} @(re-frame/subscribe [::subs/clients])
|
||||
:when (not (used-clients id))]
|
||||
^{:key id} [:option {:value id} name]))]]]]
|
||||
[:p.control
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::add-company])} "Add"]]]
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::add-client])} "Add"]]]
|
||||
|
||||
[:ul
|
||||
(for [{:keys [id name]} (:clients (:user editing))]
|
||||
^{:key id} [:li name [:a.icon {:on-click (dispatch-event [::remove-company id])} [:i.fa.fa-times ]]])]]])]])])
|
||||
^{:key id} [:li name [:a.icon {:on-click (dispatch-event [::remove-client id])} [:i.fa.fa-times ]]])]]])]])])
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::users-mounted {}]) }))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user