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