Minor UI fixes
This commit is contained in:
parent
3a18cacf0f
commit
89745e3a83
|
@ -57,32 +57,56 @@
|
||||||
|
|
||||||
|
|
||||||
(reg-event-db
|
(reg-event-db
|
||||||
:send-intention
|
:send-intention
|
||||||
(fn [db [_ args]]
|
(fn [db [_ args]]
|
||||||
(let [intention (:intention args)
|
(let [intention (:intention args)
|
||||||
elector-id (:elector-id args)
|
elector-id (:elector-id args)
|
||||||
elector
|
old-elector (first
|
||||||
(first
|
(remove nil?
|
||||||
(remove nil?
|
(map
|
||||||
(map
|
#(if (= elector-id (:id %)) %)
|
||||||
#(if (= elector-id (:id %)) %)
|
(:electors (:dwelling db)))))
|
||||||
(:electors (:address db)))))
|
new-elector (assoc old-elector :intention intention)
|
||||||
old-address (:address db)
|
old-dwelling (:dwelling db)
|
||||||
new-address (assoc old-address :electors (cons (assoc elector :intention intention) (remove #(= % elector) (:electors old-address))))]
|
new-dwelling (assoc
|
||||||
(cond
|
old-dwelling
|
||||||
(nil? elector)
|
:electors
|
||||||
(assoc db :error "No elector found; not setting intention")
|
(cons
|
||||||
(= intention (:intention elector)) (do (js/console.log "Elector's intention hasn't changed; not setting intention") db)
|
new-elector
|
||||||
true
|
(remove
|
||||||
(do
|
#(= % old-elector)
|
||||||
(js/console.log (str "Setting intention of elector " elector " to " intention))
|
(:electors old-dwelling))))
|
||||||
(merge
|
old-address (:address db)
|
||||||
(clear-messages db)
|
new-address (assoc
|
||||||
{:addresses
|
old-address
|
||||||
(cons new-address (remove old-address (:addresses db)))
|
:dwellings
|
||||||
:address new-address
|
(cons
|
||||||
:elector elector
|
new-dwelling
|
||||||
:outqueue (cons (assoc args :action :set-intention) (:outqueue db))}))))))
|
(remove
|
||||||
|
#(= % old-dwelling)
|
||||||
|
(:dwellings old-address))))]
|
||||||
|
(cond
|
||||||
|
(nil? old-elector)
|
||||||
|
(assoc db :error "No elector found; not setting intention")
|
||||||
|
(= intention (:intention old-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 " old-elector " to " intention))
|
||||||
|
(merge
|
||||||
|
(clear-messages db)
|
||||||
|
{:addresses
|
||||||
|
(cons
|
||||||
|
new-address
|
||||||
|
(remove #(= % old-address) (:addresses db)))
|
||||||
|
:address new-address
|
||||||
|
:dwelling new-dwelling
|
||||||
|
:elector new-elector
|
||||||
|
:outqueue (cons
|
||||||
|
(assoc args :action :set-intention)
|
||||||
|
(:outqueue db))}))))))
|
||||||
|
|
||||||
|
|
||||||
(reg-event-db
|
(reg-event-db
|
||||||
|
|
|
@ -49,4 +49,6 @@
|
||||||
(ui/big-link
|
(ui/big-link
|
||||||
(:sub-address dwelling)
|
(:sub-address dwelling)
|
||||||
(str "#/electors/" (:id dwelling))) )
|
(str "#/electors/" (:id dwelling))) )
|
||||||
(:dwellings address))]]]))
|
(sort
|
||||||
|
#(< (:sub-address %1) (:sub-address %2))
|
||||||
|
(:dwellings address)))]]]))
|
||||||
|
|
|
@ -62,9 +62,9 @@
|
||||||
(remove
|
(remove
|
||||||
nil?
|
nil?
|
||||||
(map
|
(map
|
||||||
#(:intention %)
|
:intention
|
||||||
(map :electors
|
(mapcat :electors
|
||||||
(:dwellings address)))))]
|
(:dwellings address)))))]
|
||||||
(case (count intentions)
|
(case (count intentions)
|
||||||
0 "unknown-pin"
|
0 "unknown-pin"
|
||||||
1 (str (name (first intentions)) "-pin")
|
1 (str (name (first intentions)) "-pin")
|
||||||
|
|
Loading…
Reference in a new issue