aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-10-17 16:07:04 +0100
committerDave Arter <davea@mysociety.org>2016-10-19 14:22:16 +0100
commitdde69590a168f0ff2678adaa5a7f50ed10263146 (patch)
tree8a72c0f88093a8b5352f5e95d147b4dee110e293
parent7e4d4793c3af6a54667db90565f11e59e401693e (diff)
Factor Open311 fields into own template for devolved contacts
-rw-r--r--templates/web/base/admin/body-form.html110
-rw-r--r--templates/web/base/admin/contact-form.html24
-rw-r--r--templates/web/base/admin/open311-form-fields.html112
-rw-r--r--web/js/fixmystreet-admin.js17
4 files changed, 146 insertions, 117 deletions
diff --git a/templates/web/base/admin/body-form.html b/templates/web/base/admin/body-form.html
index 6dd8a9547..b1f4bce2c 100644
--- a/templates/web/base/admin/body-form.html
+++ b/templates/web/base/admin/body-form.html
@@ -113,115 +113,7 @@
</select>
</p>
- <div class="admin-open311-only">
- <p class="fms-admin-info">
- [% loc(
- "These settings are for bodies that use Open311 (or other back-end integration) to receive problem reports.<br>
- <strong>You don't need to set them if the Send Method is email.</strong>.
- For more information on Open311, see
- <a href='https://www.mysociety.org/2013/01/17/open311-explained/' class='admin-offsite-link'>this article</a>.
- "
- ) %]
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "The <strong>endpoint</strong> is the URL of the service that FixMyStreet will connect to
- when sending reports to this body."
- ) %]
- </p>
- </div>
- <p>
- <label for="endpoint">[% loc('Endpoint') %]</label>
- <input type="text" class="form-control" name="endpoint" id="endpoint" value="[% body.endpoint | html %]" size="50">
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "The <strong>jurisdiction</strong> is only needed if the endpoint is serving more
- than one. If the body is running its own endpoint, you can usually leave this blank."
- ) %]
- </p>
- </div>
- <p>
- <label for="jurisdiction">Open311 Jurisdiction</label>
- <input type="text" class="form-control" name="jurisdiction" id="jurisdiction" value="[% body.jurisdiction | html %]" size="50">
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "Some endpoints require an <strong>API key</strong> to indicate that the reports are being
- sent from your FixMyStreet installation."
- ) %]
- </p>
- </div>
- <p>
- <label for="api_key">Open311 API Key</label>
- <input type="text" class="form-control" name="api_key" id="api_key" value="[% body.api_key | html %]" size="25">
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "Enable <strong>Open311 update-sending</strong> if the endpoint will send and receive
- updates to existing reports. If you're not sure, it probably does not, so leave this unchecked.
- For more information, see
- <a href='https://www.mysociety.org/2013/02/20/open311-extended/' class='admin-offsite-link'>this article</a>."
- ) %]
- </p>
- </div>
- <p>
- <input type="checkbox" id="send_comments" name="send_comments"[% ' checked' IF body.send_comments %]>
- <label for="send_comments" class="inline">Use Open311 update-sending extension</label>
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "If you've enabled Open311 update-sending above, you must identify which
- FixMyStreet <strong>user</strong> will be attributed as the creator of those updates
- when they are shown on the site. Enter the ID (number) of that user."
- ) %]
- </p>
- </div>
- <p>
- <label for"comment_user_id">User ID to attribute fetched comments to</label>
- <input type="text" class="form-control" name="comment_user_id" value="[% body.comment_user_id %]">
- [% IF body.comment_user_id %]
- <a href="[% c.uri_for('user_edit', body.comment_user_id) %]">[% loc('edit user') %]</a>
- [% END %]
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "If you've enabled Open311 update-sending above, enable <strong>suppression of alerts</strong>
- if you do <strong>not</strong> want that user to be notified whenever these updates are created."
- ) %]
- </p>
- </div>
- <p>
- <input type="checkbox" id="suppress_alerts" name="suppress_alerts"[% ' checked' IF body.suppress_alerts %]>
- <label for="suppress_alerts" class="inline">Do not send email alerts on fetched comments to problem creator</label>
- </p>
-
- <div class="admin-hint">
- <p>
- [% loc(
- "If you've enabled Open311 update-sending above, Open311 usually only accepts OPEN or CLOSED status in
- its updates. Enable <strong>extended Open311 stauses</strong> if you want to allow extra states to be passed.
- Check that your cobrand supports this feature before switching it on."
- ) %]
- </p>
- </div>
- <p>
- <input type="checkbox" id="send_extended_statuses" name="send_extended_statuses"[% ' checked' IF body.send_extended_statuses %]>
- <label for="send_extended_statuses" class="inline">Send extended Open311 statuses with service request updates</label>
- </p>
- </div>
+ [% INCLUDE 'admin/open311-form-fields.html', object = body, show_body_fields = 1 %]
<div class="admin-hint">
<p>
diff --git a/templates/web/base/admin/contact-form.html b/templates/web/base/admin/contact-form.html
index 20f56c2d6..83f634188 100644
--- a/templates/web/base/admin/contact-form.html
+++ b/templates/web/base/admin/contact-form.html
@@ -84,7 +84,7 @@
<label for="inspection_required" class="inline">[% loc('Inspection required') %]</label>
</p>
- <div class="admin-hint">
+ <div class="admin-hint [% 'hidden' UNLESS contact.get_extra_metadata('inspection_required') %]">
<p>
[% loc("Reports will automatically be sent without needing to be inspected if the user's <strong>reputation</strong> is at or above this value. Set to <strong>0</strong> if all reports must be inspected regardless.") %]
</p>
@@ -97,6 +97,28 @@
</label>
</p>
+ [% IF body.can_be_devolved %]
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "The <strong>send method</strong> determines how problem reports will be sent to the body.
+ If you leave this blank, <strong>send method defaults to email</strong>."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <label for="send_method">Send Method</label>
+ <select class="form-control" name="send_method" id="send_method">
+ <option value=""> -- Select a method -- </option>
+ [% FOR method IN send_methods %]
+ <option value="[% method %]"[% ' selected' IF contact.send_method == method %]>[% method %]</option>
+ [% END %]
+ </select>
+ </p>
+
+ [% INCLUDE 'admin/open311-form-fields.html', object = contact%]
+ [% END %]
+
<div class="admin-hint">
<p>
[% loc("Use this field to record details that are only displayed in the admin. Input is not shown publicly, and is not sent to the body.") %]
diff --git a/templates/web/base/admin/open311-form-fields.html b/templates/web/base/admin/open311-form-fields.html
new file mode 100644
index 000000000..008853b0b
--- /dev/null
+++ b/templates/web/base/admin/open311-form-fields.html
@@ -0,0 +1,112 @@
+<div class="admin-open311-only">
+ <p class="fms-admin-info">
+ [% loc(
+ "These settings are for bodies that use Open311 (or other back-end integration) to receive problem reports.<br>
+ <strong>You don't need to set them if the Send Method is email.</strong>.
+ For more information on Open311, see
+ <a href='https://www.mysociety.org/2013/01/17/open311-explained/' class='admin-offsite-link'>this article</a>.
+ "
+ ) %]
+ </p>
+
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "The <strong>endpoint</strong> is the URL of the service that FixMyStreet will connect to
+ when sending reports to this body."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <label for="endpoint">[% loc('Endpoint') %]</label>
+ <input type="text" class="form-control" name="endpoint" id="endpoint" value="[% object.endpoint | html %]" size="50">
+ </p>
+
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "The <strong>jurisdiction</strong> is only needed if the endpoint is serving more
+ than one. If the body is running its own endpoint, you can usually leave this blank."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <label for="jurisdiction">Open311 Jurisdiction</label>
+ <input type="text" class="form-control" name="jurisdiction" id="jurisdiction" value="[% object.jurisdiction | html %]" size="50">
+ </p>
+
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "Some endpoints require an <strong>API key</strong> to indicate that the reports are being
+ sent from your FixMyStreet installation."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <label for="api_key">Open311 API Key</label>
+ <input type="text" class="form-control" name="api_key" id="api_key" value="[% object.api_key | html %]" size="25">
+ </p>
+
+ [% IF show_body_fields %]
+ [%# These fields aren't shown for contacts %]
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "Enable <strong>Open311 update-sending</strong> if the endpoint will send and receive
+ updates to existing reports. If you're not sure, it probably does not, so leave this unchecked.
+ For more information, see
+ <a href='https://www.mysociety.org/2013/02/20/open311-extended/' class='admin-offsite-link'>this article</a>."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <input type="checkbox" id="send_comments" name="send_comments"[% ' checked' IF object.send_comments %]>
+ <label for="send_comments" class="inline">Use Open311 update-sending extension</label>
+ </p>
+
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "If you've enabled Open311 update-sending above, you must identify which
+ FixMyStreet <strong>user</strong> will be attributed as the creator of those updates
+ when they are shown on the site. Enter the ID (number) of that user."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <label for"comment_user_id">User ID to attribute fetched comments to</label>
+ <input type="text" class="form-control" name="comment_user_id" value="[% object.comment_user_id %]">
+ [% IF object.comment_user_id %]
+ <a href="[% c.uri_for('user_edit', object.comment_user_id) %]">[% loc('edit user') %]</a>
+ [% END %]
+ </p>
+
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "If you've enabled Open311 update-sending above, enable <strong>suppression of alerts</strong>
+ if you do <strong>not</strong> want that user to be notified whenever these updates are created."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <input type="checkbox" id="suppress_alerts" name="suppress_alerts"[% ' checked' IF object.suppress_alerts %]>
+ <label for="suppress_alerts" class="inline">Do not send email alerts on fetched comments to problem creator</label>
+ </p>
+
+ <div class="admin-hint">
+ <p>
+ [% loc(
+ "If you've enabled Open311 update-sending above, Open311 usually only accepts OPEN or CLOSED status in
+ its updates. Enable <strong>extended Open311 stauses</strong> if you want to allow extra states to be passed.
+ Check that your cobrand supports this feature before switching it on."
+ ) %]
+ </p>
+ </div>
+ <p>
+ <input type="checkbox" id="send_extended_statuses" name="send_extended_statuses"[% ' checked' IF object.send_extended_statuses %]>
+ <label for="send_extended_statuses" class="inline">Send extended Open311 statuses with service request updates</label>
+ </p>
+ [% END %]
+</div>
diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js
index e0605b443..8191fc254 100644
--- a/web/js/fixmystreet-admin.js
+++ b/web/js/fixmystreet-admin.js
@@ -2,12 +2,13 @@ $(function(){
// available for admin pages
// hide the open311_only section and reveal it only when send_method is relevant
- var $open311_only = $('.admin-open311-only');
+ function hide_or_show_open311(e, hide_fast) {
+ var $form = $(this).closest("form");
+ var $open311_only = $form.find('.admin-open311-only');
- function hide_or_show_open311(hide_fast) {
- var send_method = $('#send_method').val();
+ var send_method = $(this).val();
var show_open311 = false;
- if ($('#endpoint').val()) {
+ if ($form.find('[name=endpoint]').val()) {
show_open311 = true; // always show the form if there is an endpoint value
} else if (send_method && !send_method.match(/^(email|noop|refused)$/i)) {
show_open311 = true;
@@ -23,9 +24,11 @@ $(function(){
}
}
- if ($open311_only) {
- $('#send_method').on('change', hide_or_show_open311);
- hide_or_show_open311(true);
+ if ($('.admin-open311-only').length) {
+ // Add handler to send_method dropdowns and set initial visibility
+ $('[name=send_method]').on('change', hide_or_show_open311).each(function() {
+ hide_or_show_open311.call(this, null, true);
+ });
}