diff --git a/project.clj b/project.clj index f3fdcbf..7e9a72e 100644 --- a/project.clj +++ b/project.clj @@ -85,20 +85,14 @@ :profiles {:uberjar {:omit-source true - :prep-tasks ["compile" "bower" ["cljsbuild" "once" "min"]] + :prep-tasks ["compile" ["bower" "install"] ["cljsbuild" "once" "min"]] :cljsbuild {:builds {:min {:source-paths ["src/cljc" "src/cljs" "env/prod/cljs"] :compiler - {:output-to "target/cljsbuild/public/js/app.js" - :externs ["react/externs/react.js" "externs.js"] - :optimizations :advanced - :pretty-print false - :closure-warnings - {:externs-validation :off :non-standard-jsdoc :off}}}}} - - + {:optimizations :advanced + :pretty-print false}}}} :aot :all :uberjar-name "youyesyet.jar" :source-paths ["env/prod/clj"] diff --git a/resources/public/img/gender/female.png b/resources/public/img/gender/female.png index 24b74a7..9a407ff 100644 Binary files a/resources/public/img/gender/female.png and b/resources/public/img/gender/female.png differ diff --git a/resources/public/img/gender/female.xcf b/resources/public/img/gender/female.xcf index 284a803..2163917 100644 Binary files a/resources/public/img/gender/female.xcf and b/resources/public/img/gender/female.xcf differ diff --git a/resources/public/img/gender/fluid.png b/resources/public/img/gender/fluid.png new file mode 100644 index 0000000..e756611 Binary files /dev/null and b/resources/public/img/gender/fluid.png differ diff --git a/resources/public/img/gender/fluid.xcf b/resources/public/img/gender/fluid.xcf new file mode 100644 index 0000000..c26a343 Binary files /dev/null and b/resources/public/img/gender/fluid.xcf differ diff --git a/resources/public/img/gender/male.png b/resources/public/img/gender/male.png index 4427edc..bfca00f 100644 Binary files a/resources/public/img/gender/male.png and b/resources/public/img/gender/male.png differ diff --git a/resources/public/img/gender/male.xcf b/resources/public/img/gender/male.xcf new file mode 100644 index 0000000..421fac7 Binary files /dev/null and b/resources/public/img/gender/male.xcf differ diff --git a/resources/public/img/gender/unknown.png b/resources/public/img/gender/unknown.png new file mode 100644 index 0000000..5b803d4 Binary files /dev/null and b/resources/public/img/gender/unknown.png differ diff --git a/resources/public/img/gender/unknown.xcf b/resources/public/img/gender/unknown.xcf new file mode 100644 index 0000000..91beda2 Binary files /dev/null and b/resources/public/img/gender/unknown.xcf differ diff --git a/resources/templates/login.html b/resources/templates/login.html index 4f17ee9..f3e8731 100644 --- a/resources/templates/login.html +++ b/resources/templates/login.html @@ -16,7 +16,7 @@

- +

diff --git a/src/cljs/youyesyet/core.cljs b/src/cljs/youyesyet/core.cljs index 9522673..fb5c009 100644 --- a/src/cljs/youyesyet/core.cljs +++ b/src/cljs/youyesyet/core.cljs @@ -105,6 +105,9 @@ (secretary/defroute "/map" [] (rf/dispatch [:set-active-page :map])) +(secretary/defroute "/set-intention/:elector/:intention" {elector-id :elector intention :intention} + (rf/dispatch [:set-intention {:elector-id elector-id :intention intention}])) + ;; ------------------------- ;; History ;; must be called after routes have been defined diff --git a/src/cljs/youyesyet/db.cljs b/src/cljs/youyesyet/db.cljs index 820dcae..754ec45 100644 --- a/src/cljs/youyesyet/db.cljs +++ b/src/cljs/youyesyet/db.cljs @@ -32,10 +32,10 @@ (def default-db {;;; the currently selected address, if any. :address {:id 1 :address "13 Imaginary Terrace, IM1 3TE" :latitude 55.8253043 :longitude -4.2590944 - :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}]} + :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 @@ -44,7 +44,10 @@ {:id 3 :name "Alex Anderson" :gender :fluid :intention :yes} {:id 4 :name "Andy Anderson" :intention :yes}]}] ;;; electors at the currently selected address - :elector {:id 1 :name "Alan Anderson" :gender :male :intention :no} + :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}] ;;; the issue from among the issues which is currently selected. :issue "Currency" ;;; the issues selected for the issues page on this day. diff --git a/src/cljs/youyesyet/handlers.cljs b/src/cljs/youyesyet/handlers.cljs index b7dbc03..ee31a59 100644 --- a/src/cljs/youyesyet/handlers.cljs +++ b/src/cljs/youyesyet/handlers.cljs @@ -62,10 +62,30 @@ (assoc (assoc db :elector elector) :page page)))) +(reg-event-db + :set-intention + (fn [db [_ args]] + (let [intention (:intention args) + elector-id (read-string (:elector-id args)) + elector + (first + (remove nil? + (map + #(if (= elector-id (:id %)) %) + (:electors (:address db))))) + old-address (:address db) + new-address (assoc old-address :electors (cons (assoc elector :intention intention) (remove #(= % elector) (:electors old-address))))] + (cond + (nil? elector)(do (js/console.log "No elector found; not setting intention") db) + (= intention (:intention elector)) (do (js/console.log "Elector's intention hasn't changed; not setting intention") db) + true + (do + (js/console.log (str "Setting intention of elector " elector " to " intention)) + (assoc db :addresses (cons new-address (remove old-address (:addresses db))))))))) + + (reg-event-db :set-issue (fn [db [_ issue]] (js/console.log (str "Setting page to :issue, issue to " issue)) (assoc (assoc db :issue issue) :page :issue))) - - diff --git a/src/cljs/youyesyet/views/about.cljs b/src/cljs/youyesyet/views/about.cljs index 5b46783..186c95c 100644 --- a/src/cljs/youyesyet/views/about.cljs +++ b/src/cljs/youyesyet/views/about.cljs @@ -61,4 +61,5 @@ [:img {:src "img/gnu.small.png" :alt "Free Software Foundation" :height "24" :width "24"}] " Licensed under the " [:a {:href "http://www.gnu.org/licenses/gpl-2.0.html"} - "GNU General Public License v2.0"]]]])) + "GNU General Public License v2.0"]] + (ui/back-link)]])) diff --git a/src/cljs/youyesyet/views/electors.cljs b/src/cljs/youyesyet/views/electors.cljs index 5c02e53..01a37a7 100644 --- a/src/cljs/youyesyet/views/electors.cljs +++ b/src/cljs/youyesyet/views/electors.cljs @@ -45,7 +45,7 @@ [elector] (let [gender (:gender elector) image (if gender (name gender) "unknown")] - [:td {:key (:id elector)} (if gender [:img {:src (str "img/gender/" image ".png") :alt image}])])) + [:td {:key (:id elector)} [:img {:src (str "img/gender/" image ".png") :alt image}]])) (defn genders-row [electors] @@ -84,6 +84,7 @@ [:a {:href (str "#/issues/" (:id elector))} [:img {:src "/img/issues.png" :alt "Issues"}]]]) + (defn issues-row [electors] [:tr @@ -95,6 +96,7 @@ "Generate the electors panel." [] (let [address @(subscribe [:address]) + addresses @(subscribe [:addresses]) electors (:electors address) options @(subscribe [:options])] (if address diff --git a/src/cljs/youyesyet/views/followup.cljs b/src/cljs/youyesyet/views/followup.cljs index 0810aac..f76fb42 100644 --- a/src/cljs/youyesyet/views/followup.cljs +++ b/src/cljs/youyesyet/views/followup.cljs @@ -71,3 +71,4 @@ [:input {:id "submit" :name "submit" :type "submit" :value "Send this!"}]] ] (ui/back-link)]]))) + diff --git a/src/cljs/youyesyet/views/map.cljs b/src/cljs/youyesyet/views/map.cljs index 2a2c4bf..4f63e9d 100644 --- a/src/cljs/youyesyet/views/map.cljs +++ b/src/cljs/youyesyet/views/map.cljs @@ -64,6 +64,7 @@ (defn click-handler [id] + (js/console.log (str "Click handler for address #" id)) (dispatch [:set-address id])) @@ -71,7 +72,7 @@ "Add a map-pin at this address in this map view" [address view] (let [lat (:latitude address) - lon (:longitude address) + lng (:longitude address) pin (.icon js/L (clj->js {:iconUrl (str "img/map-pins/" (pin-image address) ".png") @@ -81,7 +82,7 @@ :iconAnchor [16 41] :shadowAnchor [16 23]})) marker (.marker js/L - (.latLng js/L 55.82 -4.25) + (.latLng js/L lat lng) (clj->js {:icon pin :title (:address address)})) ] (.on marker "click" #(fn [] (click-handler (:id address)))) @@ -92,7 +93,7 @@ (defn map-did-mount-mapbox "Did-mount function loading map tile data from MapBox (proprietary)." [] - (let [view (.setView (.map js/L "map" (clj->js {:zoomControl "false"})) #js [55.82 -4.25] 13)] + (let [view (.setView (.map js/L "map" (clj->js {:zoomControl "false"})) #js [55.82 -4.25] 40)] ;; NEED TO REPLACE FIXME with your mapID! (.addTo (.tileLayer js/L "http://{s}.tiles.mapbox.com/v3/FIXME/{z}/{x}/{y}.png" (clj->js {:attribution "Map data © [...]"