Merge branch 'feature/33' into develop
This commit is contained in:
commit
7d4bf2a2c2
BIN
resources/public/img/map-pins/unknown-pin.png
Normal file
BIN
resources/public/img/map-pins/unknown-pin.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
resources/public/img/map-pins/unknown-pin.xcf
Normal file
BIN
resources/public/img/map-pins/unknown-pin.xcf
Normal file
Binary file not shown.
|
@ -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]))
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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)))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue