diff --git a/resources/public/img/map-pins/unknown-pin.png b/resources/public/img/map-pins/unknown-pin.png new file mode 100644 index 0000000..f0b8fbb Binary files /dev/null and b/resources/public/img/map-pins/unknown-pin.png differ diff --git a/resources/public/img/map-pins/unknown-pin.xcf b/resources/public/img/map-pins/unknown-pin.xcf new file mode 100644 index 0000000..b55b9f8 Binary files /dev/null and b/resources/public/img/map-pins/unknown-pin.xcf differ diff --git a/src/cljs/youyesyet/core.cljs b/src/cljs/youyesyet/core.cljs index 69f23aa..0b4cae8 100644 --- a/src/cljs/youyesyet/core.cljs +++ b/src/cljs/youyesyet/core.cljs @@ -95,6 +95,9 @@ (secretary/defroute "/electors" [] (rf/dispatch [:set-active-page :electors])) +(secretary/defroute "/electors/:address" {address-id :address} + (rf/dispatch [:set-address address-id])) + (secretary/defroute "/followup" [] (rf/dispatch [:set-active-page :followup])) diff --git a/src/cljs/youyesyet/db.cljs b/src/cljs/youyesyet/db.cljs index 754ec45..2d1efaf 100644 --- a/src/cljs/youyesyet/db.cljs +++ b/src/cljs/youyesyet/db.cljs @@ -31,18 +31,27 @@ (def default-db {;;; the currently selected address, if any. - :address {:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2590944 + :address {:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2569057 :electors [{:id 1 :name "Alan Anderson" :gender :male :intention :no} {:id 2 :name "Ann Anderson" :gender :female} {:id 3 :name "Alex Anderson" :gender :fluid :intention :yes} {:id 4 :name "Andy Anderson" :intention :yes}]} ;;; a list of the addresses in the current location at which there ;;; are electors registered. - :addresses [{:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2590944 + :addresses [{:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2570944 :electors [{:id 1 :name "Alan Anderson" :gender :male :intention :no} {:id 2 :name "Ann Anderson" :gender :female} {:id 3 :name "Alex Anderson" :gender :fluid :intention :yes} - {:id 4 :name "Andy Anderson" :intention :yes}]}] + {:id 4 :name "Andy Anderson" :intention :yes}]} + {:id 2 :address "15 Imaginary Terrace, IM1 3TE" :latitude 55.8252354 :longitude -4.2572778 + :electors [{:id 1 :name "Beryl Brown" :gender :female} + {:id 2 :name "Betty Black" :gender :female}]} + {:id 3 :address "17 Imaginary Terrace, IM1 3TE" :latitude 55.825166 :longitude -4.257026 + :electors [{:id 1 :name "Catriona Crathie" :gender :female :intention :yes} + {:id 2 :name "Colin Caruthers" :gender :male :intention :yes} + {:id 3 :name "Calum Crathie" :intention :yes}]} + {:id 4 :address "19 Imaginary Terrace, IM1 3TE" :latitude 55.82506950000001 :longitude -4.2570239 + :electors [{:id 1 :name "David Dewar" :gender :male :intention :no}]}] ;;; electors at the currently selected address :electors [{:id 1 :name "Alan Anderson" :gender :male :intention :no} {:id 2 :name "Ann Anderson" :gender :female} diff --git a/src/cljs/youyesyet/views/map.cljs b/src/cljs/youyesyet/views/map.cljs index 4f63e9d..01bae13 100644 --- a/src/cljs/youyesyet/views/map.cljs +++ b/src/cljs/youyesyet/views/map.cljs @@ -62,10 +62,17 @@ "mixed-pin"))) -(defn click-handler +(defn map-pin-click-handler + "On clicking on the pin, navigate to the electors at the address. + This way of doing it adds an antry in the browser location history, + so back links work." [id] (js/console.log (str "Click handler for address #" id)) - (dispatch [:set-address id])) + (set! window.location.href (str "#electors/" id))) +;; This way is probably more idiomatic React, but back links don't work: +;; (defn map-pin-click-handler +;; [id] +;; (dispatch [:set-address id])) (defn add-map-pin @@ -83,9 +90,10 @@ :shadowAnchor [16 23]})) marker (.marker js/L (.latLng js/L lat lng) - (clj->js {:icon pin :title (:address address)})) + (clj->js {:icon pin + :title (:address address)})) ] - (.on marker "click" #(fn [] (click-handler (:id address)))) + (.on marker "click" (fn [_] (map-pin-click-handler (str (:id address))))) (.addTo marker view)))