Some improvement to the followuprequest form
Allowing handling of 'other', to capture electors concerns other than the ones we've selected.
This commit is contained in:
parent
863a7e3c0e
commit
cb9e38cdc8
|
@ -42,3 +42,4 @@ WHERE followupactions.request_id = followuprequests.id
|
|||
AND visits.address_id = addresses.id
|
||||
AND followupactions.actor = canvassers.id
|
||||
;
|
||||
GRANT SELECT ON lv_followupactions TO canvassers, issueexperts;
|
||||
|
|
|
@ -193,6 +193,7 @@
|
|||
(rf/dispatch [:fetch-locality])
|
||||
(rf/dispatch [:fetch-options])
|
||||
(rf/dispatch [:fetch-issues])
|
||||
(rf/dispatch [:fetch-followupmethods])
|
||||
(rf/dispatch [:dispatch-later [{:ms 60000 :dispatch [:process-queue]}]])
|
||||
(load-interceptors!)
|
||||
(hook-browser-navigation!)
|
||||
|
|
|
@ -236,6 +236,41 @@
|
|||
:error (:response response))))
|
||||
|
||||
|
||||
(reg-event-fx
|
||||
:fetch-followupmethods
|
||||
(fn [{db :db} _]
|
||||
(js/console.log "Fetching options")
|
||||
;; we return a map of (side) effects
|
||||
{:http-xhrio {:method :get
|
||||
:uri (str source-host "json/auto/list-followupmethods")
|
||||
:format (json-request-format)
|
||||
:response-format (json-response-format {:keywords? true})
|
||||
:on-success [:process-followupmethods]
|
||||
:on-failure [:bad-followupmethods]}
|
||||
:db (add-to-feedback db :fetch-followupmethods)}))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:process-followupmethods
|
||||
(fn
|
||||
[db [_ response]]
|
||||
(let [followupmethods (js->clj response)]
|
||||
(js/console.log (str "Updating followupmethods: " followupmethods))
|
||||
(assoc
|
||||
(remove-from-feedback db :fetch-followupmethods)
|
||||
:followupmethods followupmethods))))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:bad-followupmethods
|
||||
(fn [db [_ response]]
|
||||
(js/console.log "Failed to fetch followupmethods")
|
||||
(dispatch [:dispatch-later [{:ms 60000 :dispatch [:fetch-followupmethods]}]])
|
||||
(assoc
|
||||
db
|
||||
:error (:response response))))
|
||||
|
||||
|
||||
(reg-event-fx
|
||||
:fetch-issues
|
||||
(fn [{db :db} _]
|
||||
|
@ -419,6 +454,13 @@
|
|||
(assoc (clear-messages db) :elector elector))))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:set-followupmethod
|
||||
(fn [db [_ method-id]]
|
||||
(js/console.log (str "Setting followupmethod to " method-id))
|
||||
(assoc db :followupmethod method-id)))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:set-issue
|
||||
(fn [db [_ issue]]
|
||||
|
|
|
@ -66,6 +66,16 @@
|
|||
(fn [db _]
|
||||
(:feedback db)))
|
||||
|
||||
(reg-sub
|
||||
:followupmethod
|
||||
(fn [db _]
|
||||
(:followupmethod db)))
|
||||
|
||||
(reg-sub
|
||||
:followupmethods
|
||||
(fn [db _]
|
||||
(:followupmethods db)))
|
||||
|
||||
(reg-sub
|
||||
:issue
|
||||
(fn [db _]
|
||||
|
|
|
@ -41,8 +41,9 @@
|
|||
(let [issue @(subscribe [:issue])
|
||||
issues @(subscribe [:issues])
|
||||
elector @(subscribe [:elector])
|
||||
dwelling @(subscribe [:dwelling])]
|
||||
(js/console.log (str "Issue is " issue "; elector is " elector))
|
||||
dwelling @(subscribe [:dwelling])
|
||||
method @(subscribe [:followupmethod])]
|
||||
(js/console.log (str "followup/panel; Issue is " issue "; elector is " elector "; method is " method))
|
||||
(cond
|
||||
(nil? dwelling)
|
||||
(ui/error-panel "No dwelling selected")
|
||||
|
@ -68,8 +69,19 @@
|
|||
(map
|
||||
#(let []
|
||||
[:option {:key % :value %} %]) (keys issues))]]
|
||||
(if (= issue :Other)
|
||||
[:p.widget
|
||||
[:label {:for "issue_detail"} "Issue detail"]
|
||||
[:input {:type "text" :id "issue_detail" :name "issue_detail"}]])
|
||||
[:p.widget
|
||||
[:label {:for "method_detail"} "Telephone number"]
|
||||
[:label {:for "method"} "Method"]
|
||||
[:select {:id "method" :name "method" :defaultValue "Phone"
|
||||
:on-change #(dispatch [:set-followupmethod (.-value (.-target %))])}
|
||||
(map
|
||||
#(let []
|
||||
[:option {:value (:id %) :key (:id %)} (:id %)]) @(subscribe [:followupmethods]))]]
|
||||
[:p.widget
|
||||
[:label {:for "method_detail"} (if (= @(subscribe [:followupmethod]) "Phone") "Telephone number" "EMail Address")]
|
||||
[:input {:type "text" :id "method_detail" :name "method_detail"
|
||||
:on-change #(dispatch [:set-method-detail (.-value (.-target %))])}]]
|
||||
[:p.widget
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
only against your electoral district, and not link it to you"]]]]
|
||||
[:tr
|
||||
[:td
|
||||
[:canvas {:id "signature-pad" :on-mouse-out #(send-consent elector)}]]]]]]
|
||||
[:canvas {:id "signature-pad"}]]]]]]
|
||||
(ui/back-link "#dwelling")
|
||||
(ui/big-link "I consent"
|
||||
:target (str "#elector")
|
||||
|
|
|
@ -44,7 +44,7 @@ version="0.1.1">
|
|||
<group name="issueexperts" parent="public">
|
||||
<documentation>People expert on particular issues. Able to read
|
||||
followup requests, and the electors to which they relate; able
|
||||
to access (read/write) the issues wiki; able to write followuop
|
||||
to access (read/write) the issues wiki; able to write followup
|
||||
action records.</documentation>
|
||||
</group>
|
||||
<group name="analysts" parent="public">
|
||||
|
@ -694,6 +694,9 @@ version="0.1.1">
|
|||
column="issue_id" entity="issues" farkey="id" distinct="user">
|
||||
<prompt prompt="issue_id" locale="en_GB.UTF-8"/>
|
||||
</property>
|
||||
<property type="string" name="issue_detail">
|
||||
<prompt prompt="Issue detail" locale="en_GB.UTF-8"/>
|
||||
</property>
|
||||
<property required="true" type="entity" name="method_id"
|
||||
column="method_id" entity="followupmethods" farkey="id">
|
||||
<prompt prompt="method_id" locale="en_GB.UTF-8"/>
|
||||
|
|
Loading…
Reference in a new issue