diff --git a/src/cljs/auto_ap/views/pages/admin/clients.cljs b/src/cljs/auto_ap/views/pages/admin/clients.cljs index 3f3fda64..e46f32c6 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients.cljs @@ -111,6 +111,14 @@ (update-in [:admin :client :locations] conj (:location client)) (update-in [:admin :client] dissoc :location))}))) +(re-frame/reg-event-fx + ::add-new-location + (fn [{:keys [db]} _] + (let [client (:new-client @(re-frame/subscribe [::subs/admin]))] + {:db (-> db + (update-in [:admin :new-client :locations] conj (:location client)) + (update-in [:admin :new-client] dissoc :location))}))) + (re-frame/reg-event-fx ::add-new-bank-account (fn [{:keys [db]} _] @@ -145,7 +153,7 @@ (re-frame/reg-event-db ::remove-new-bank-account (fn [db [_ index]] - (update-in db [:admin :client :new-bank-accounts] + (update-in db [:admin :new-client :new-bank-accounts] (fn [bas] (vec (concat (take index bas) (drop (inc index) bas))))))) @@ -384,7 +392,7 @@ :field :location :event ::change-new :subscription new-client}]]] - [:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-location])} "Add"]]] + [:p.control [:button.button.is-primary {:on-click (dispatch-event [::add-new-location])} "Add"]]] [:ul (for [location (:locations new-client)] ^{:key location} [:li location ])]]] diff --git a/src/java/main/auto_ap/Sortable.java b/src/java/main/auto_ap/Sortable.java new file mode 100644 index 00000000..a9f4f95b --- /dev/null +++ b/src/java/main/auto_ap/Sortable.java @@ -0,0 +1,15 @@ +package auto_ap; + +public class Sortable implements Comparable { + public String a; + public Object b; + + public Sortable(String a, Object b) { + this.a = a; + this.b = b; + } + + public int compareTo(Sortable other) { + return a.compareTo(other.a); + } +}