#36 App user interface now fully working for pre-alpha release
... but app.js is still not being deployed.
This commit is contained in:
parent
c75bdb9e5e
commit
c1a120daf2
|
@ -60,13 +60,9 @@ footer {
|
|||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0.25em 0;
|
||||
bottom:0;
|
||||
position:fixed;
|
||||
vertical-align: top;
|
||||
bottom: 0;
|
||||
position: fixed;
|
||||
z-index:150;
|
||||
_position:absolute;
|
||||
_top:expression(eval(document.documentElement.scrollTop+
|
||||
(document.documentElement.clientHeight-this.offsetHeight)));
|
||||
}
|
||||
|
||||
footer div {
|
||||
|
@ -373,10 +369,6 @@ th {
|
|||
border-radius: 0.5em;
|
||||
}
|
||||
|
||||
footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
/* I wouldn't normally use a px value, but the menu icon is 49px wide */
|
||||
padding: 0.25em 5%;
|
||||
|
|
|
@ -72,20 +72,26 @@
|
|||
:map #'map-page
|
||||
})
|
||||
|
||||
|
||||
(defn page
|
||||
"Render the single page of the app, taking the current panel from
|
||||
the :page key in the state map."
|
||||
[]
|
||||
(let [content (pages @(rf/subscribe [:page]))
|
||||
error @(rf/subscribe [:error])
|
||||
feedback @(rf/subscribe [:feedback])
|
||||
outqueue @(rf/subscribe [:outqueue])]
|
||||
[:div
|
||||
[:header
|
||||
[ui/navbar]]
|
||||
(let [content (pages @(rf/subscribe [:page]))
|
||||
error @(rf/subscribe [:error])
|
||||
feedback @(rf/subscribe [:feedback])]
|
||||
[:div.error {:style (str "display: " (if error "block" "none"))} (str error)]
|
||||
[:div.feedback {:style (str "display: " (if feedback "block" "none"))} (str feedback)]
|
||||
(if content [content]
|
||||
[:div.error (str "No content in page " :page)]))])
|
||||
[:div.error (str "No content in page " :page)])
|
||||
[:footer
|
||||
[:div.error {:style [:display (if error "block" "none")]} (str error)]
|
||||
[:div.feedback {:style [:display (if feedback :block :none)]} (str feedback)]
|
||||
[:div.queue (if
|
||||
(nil? outqueue) ""
|
||||
(str (count outqueue) " items queued to send"))]]]))
|
||||
|
||||
;; -------------------------
|
||||
;; Routes
|
||||
|
|
|
@ -54,6 +54,34 @@
|
|||
db/default-db))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:send-intention
|
||||
(fn [db [_ args]]
|
||||
(let [intention (:intention args)
|
||||
elector-id (: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)
|
||||
(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)
|
||||
true
|
||||
(do
|
||||
(js/console.log (str "Setting intention of elector " elector " to " intention))
|
||||
(merge
|
||||
(clear-messages db)
|
||||
{:addresses
|
||||
(cons new-address (remove old-address (:addresses db)))
|
||||
:address new-address
|
||||
:outqueue (cons (assoc args :action :set-intention) (:outqueue db))}))))))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:send-request
|
||||
(fn [db [_ _]]
|
||||
|
@ -109,34 +137,6 @@
|
|||
(assoc (clear-messages db) :elector elector))))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:set-intention
|
||||
(fn [db [_ args]]
|
||||
(let [intention (:intention args)
|
||||
elector-id (: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)
|
||||
(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)
|
||||
true
|
||||
(do
|
||||
(js/console.log (str "Setting intention of elector " elector " to " intention))
|
||||
(merge
|
||||
(clear-messages db)
|
||||
{:addresses
|
||||
(cons new-address (remove old-address (:addresses db)))
|
||||
:address new-address
|
||||
:outqueue (cons (assoc args :action :set-intention) (:outqueue db))}))))))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:set-issue
|
||||
(fn [db [_ issue]]
|
||||
|
@ -148,4 +148,4 @@
|
|||
:set-telephone
|
||||
(fn [db [_ telephone]]
|
||||
(js/console.log (str "Setting telephone to " telephone))
|
||||
(assoc (clear-messages db) :issue telephone)))
|
||||
(assoc (clear-messages db) :telephone telephone)))
|
||||
|
|
|
@ -78,3 +78,9 @@
|
|||
:options
|
||||
(fn [db _]
|
||||
(:options db)))
|
||||
|
||||
(reg-sub
|
||||
:outqueue
|
||||
(fn [db _]
|
||||
(:outqueue db)))
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
{:src image
|
||||
:alt optname
|
||||
:on-click #(dispatch
|
||||
[:set-intention {:elector-id (:id elector)
|
||||
[:send-intention {:elector-id (:id elector)
|
||||
:intention optid}])}]]))
|
||||
;; TODO: impose an ordering on electors - by name or by id
|
||||
electors)]))
|
||||
|
|
Loading…
Reference in a new issue