#30: Still not quite complete
This commit is contained in:
parent
7621040c8f
commit
560938e6ae
12
project.clj
12
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"]
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 942 B After Width: | Height: | Size: 1 KiB |
Binary file not shown.
BIN
resources/public/img/gender/fluid.png
Normal file
BIN
resources/public/img/gender/fluid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 511 B |
BIN
resources/public/img/gender/fluid.xcf
Normal file
BIN
resources/public/img/gender/fluid.xcf
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 983 B |
BIN
resources/public/img/gender/male.xcf
Normal file
BIN
resources/public/img/gender/male.xcf
Normal file
Binary file not shown.
BIN
resources/public/img/gender/unknown.png
Normal file
BIN
resources/public/img/gender/unknown.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
resources/public/img/gender/unknown.xcf
Normal file
BIN
resources/public/img/gender/unknown.xcf
Normal file
Binary file not shown.
|
@ -16,7 +16,7 @@
|
|||
<input type="text" id="username" name="username"/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
<label for="password">Your post-code</label>
|
||||
<label for="password">Your password</label>
|
||||
<input type="password" id="password" name="password"/>
|
||||
</p>
|
||||
<p class="widget">
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)))
|
||||
|
||||
|
||||
|
|
|
@ -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)]]))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -71,3 +71,4 @@
|
|||
[:input {:id "submit" :name "submit" :type "submit" :value "Send this!"}]]
|
||||
]
|
||||
(ui/back-link)]])))
|
||||
|
||||
|
|
|
@ -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 © [...]"
|
||||
|
|
Loading…
Reference in a new issue