Issues flow in app now working again (now with real data)

This commit is contained in:
Simon Brooke 2018-07-16 11:42:02 +01:00
parent ab568365ef
commit a610eca59d
4 changed files with 27 additions and 19 deletions

View file

@ -75,9 +75,6 @@
(defn issue-page [] (defn issue-page []
(issue/panel)) (issue/panel))
(defn issue-experts-page []
(expert/panel))
(defn map-page [] (defn map-page []
(maps/panel)) (maps/panel))

View file

@ -1,12 +1,13 @@
(ns ^{:doc "Canvasser app event handlers." (ns ^{:doc "Canvasser app event handlers."
:author "Simon Brooke"} :author "Simon Brooke"}
youyesyet.canvasser-app.handlers youyesyet.canvasser-app.handlers
(:require [cljs.reader :refer [read-string]] (:require [ajax.core :refer [GET]]
[ajax.json :refer [json-request-format json-response-format]]
[cemerick.url :refer (url url-encode)] [cemerick.url :refer (url url-encode)]
[cljs.reader :refer [read-string]]
[clojure.walk :refer [keywordize-keys]]
[day8.re-frame.http-fx] [day8.re-frame.http-fx]
[re-frame.core :refer [dispatch reg-event-db reg-event-fx subscribe]] [re-frame.core :refer [dispatch reg-event-db reg-event-fx subscribe]]
[ajax.core :refer [GET]]
[ajax.json :refer [json-request-format json-response-format]]
[youyesyet.canvasser-app.gis :refer [refresh-map-pins get-current-location]] [youyesyet.canvasser-app.gis :refer [refresh-map-pins get-current-location]]
[youyesyet.canvasser-app.state :as db] [youyesyet.canvasser-app.state :as db]
)) ))
@ -206,10 +207,11 @@
:process-options :process-options
(fn (fn
[db [_ response]] [db [_ response]]
(js/console.log "Updating options") (let [options (js->clj response)]
(js/console.log (str "Updating options: " options))
(assoc (assoc
(remove-from-feedback db :fetch-options) (remove-from-feedback db :fetch-options)
:options (js->clj response)))) :options options))))
(reg-event-db (reg-event-db
@ -239,10 +241,15 @@
:process-issues :process-issues
(fn (fn
[db [_ response]] [db [_ response]]
(js/console.log "Updating issues") (let [issues (reduce
merge {}
(map
#(hash-map (keyword (:id %)) %)
(js->clj response)))]
(js/console.log (str "Updating issues: " issues))
(assoc (assoc
(remove-from-feedback db :fetch-issues) (remove-from-feedback db :fetch-issues)
:issues (js->clj response)))) :issues issues))))
(reg-event-db (reg-event-db
@ -380,8 +387,8 @@
(reg-event-db (reg-event-db
:set-and-go-to-issue :set-and-go-to-issue
(fn [db [_ issue]] (fn [db [_ issue]]
(js/console.log (str "Setting page to :issue, issue to " issue)) (js/console.log (str "Setting page to :issue, issue to " issue ", issues are " (:issues db)))
(assoc (assoc (clear-messages db) :issue issue) :page :issue))) (assoc (assoc (clear-messages db) :issue (keyword issue)) :page :issue)))
(reg-event-db (reg-event-db
@ -406,7 +413,7 @@
:set-issue :set-issue
(fn [db [_ issue]] (fn [db [_ issue]]
(js/console.log (str "Setting issue to " issue)) (js/console.log (str "Setting issue to " issue))
(assoc (clear-messages db) :issue issue))) (assoc (clear-messages db) :issue (keyword issue))))
(reg-event-db (reg-event-db

View file

@ -38,7 +38,10 @@
(defn panel (defn panel
"Generate the issue panel." "Generate the issue panel."
[] []
(let [issue @(subscribe [:issue])] (let [id @(subscribe [:issue])
issues @(subscribe [:issues])
issue (id issues)]
(js/console.log (str "Id: " id "; issue: " issue))
[:div [:div
[:h1 (:id issue)] [:h1 (:id issue)]
[:div.container {:id "main-container"} [:div.container {:id "main-container"}

View file

@ -40,11 +40,12 @@
"Generate the issues panel." "Generate the issues panel."
[] []
(let [issues @(subscribe [:issues])] (let [issues @(subscribe [:issues])]
(js/console.log (str "Issues: " issues))
(if issues (if issues
[:div [:div
[:h1 "Issues"] [:h1 "Issues"]
[:div.container {:id "main-container"} [:div.container {:id "main-container"}
(ui/back-link) (ui/back-link)
[:div {:id "issue-list"} [:div {:id "issue-list"}
(map (fn [i] (ui/big-link (:id i) :target (str "#issue/" (:id i)))) issues)]]] (map (fn [i] (ui/big-link (:id i) :target (str "#issue/" (:id i)))) (vals issues))]]]
(ui/error-panel "No issues loaded")))) (ui/error-panel "No issues loaded"))))