#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%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.25em 0;
|
padding: 0.25em 0;
|
||||||
bottom:0;
|
bottom: 0;
|
||||||
position:fixed;
|
position: fixed;
|
||||||
vertical-align: top;
|
|
||||||
z-index:150;
|
z-index:150;
|
||||||
_position:absolute;
|
|
||||||
_top:expression(eval(document.documentElement.scrollTop+
|
|
||||||
(document.documentElement.clientHeight-this.offsetHeight)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
footer div {
|
footer div {
|
||||||
|
@ -373,10 +369,6 @@ th {
|
||||||
border-radius: 0.5em;
|
border-radius: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
footer {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
/* I wouldn't normally use a px value, but the menu icon is 49px wide */
|
/* I wouldn't normally use a px value, but the menu icon is 49px wide */
|
||||||
padding: 0.25em 5%;
|
padding: 0.25em 5%;
|
||||||
|
|
|
@ -72,20 +72,26 @@
|
||||||
:map #'map-page
|
:map #'map-page
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
(defn page
|
(defn page
|
||||||
"Render the single page of the app, taking the current panel from
|
"Render the single page of the app, taking the current panel from
|
||||||
the :page key in the state map."
|
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
|
[:div
|
||||||
[:header
|
[:header
|
||||||
[ui/navbar]]
|
[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]
|
(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
|
;; Routes
|
||||||
|
|
|
@ -54,6 +54,34 @@
|
||||||
db/default-db))
|
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
|
(reg-event-db
|
||||||
:send-request
|
:send-request
|
||||||
(fn [db [_ _]]
|
(fn [db [_ _]]
|
||||||
|
@ -109,34 +137,6 @@
|
||||||
(assoc (clear-messages db) :elector elector))))
|
(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
|
(reg-event-db
|
||||||
:set-issue
|
:set-issue
|
||||||
(fn [db [_ issue]]
|
(fn [db [_ issue]]
|
||||||
|
@ -148,4 +148,4 @@
|
||||||
:set-telephone
|
:set-telephone
|
||||||
(fn [db [_ telephone]]
|
(fn [db [_ telephone]]
|
||||||
(js/console.log (str "Setting telephone to " 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
|
:options
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(:options db)))
|
(:options db)))
|
||||||
|
|
||||||
|
(reg-sub
|
||||||
|
:outqueue
|
||||||
|
(fn [db _]
|
||||||
|
(:outqueue db)))
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
{:src image
|
{:src image
|
||||||
:alt optname
|
:alt optname
|
||||||
:on-click #(dispatch
|
:on-click #(dispatch
|
||||||
[:set-intention {:elector-id (:id elector)
|
[:send-intention {:elector-id (:id elector)
|
||||||
:intention optid}])}]]))
|
:intention optid}])}]]))
|
||||||
;; TODO: impose an ordering on electors - by name or by id
|
;; TODO: impose an ordering on electors - by name or by id
|
||||||
electors)]))
|
electors)]))
|
||||||
|
|
Loading…
Reference in a new issue