diff options
author | Dave Arter <davea@mysociety.org> | 2016-10-19 14:22:39 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-10-19 14:22:39 +0100 |
commit | 9756df6ab27f96d4f466ee98722baaf7e751c34f (patch) | |
tree | 8a72c0f88093a8b5352f5e95d147b4dee110e293 | |
parent | c78d8884f86bbd4bf6c5230937ccb6d2b35d15b8 (diff) | |
parent | dde69590a168f0ff2678adaa5a7f50ed10263146 (diff) |
Merge branch 'issues/forcouncils/71-category-form-improvements'
-rw-r--r-- | templates/web/base/admin/body-form.html | 110 | ||||
-rw-r--r-- | templates/web/base/admin/body.html | 110 | ||||
-rw-r--r-- | templates/web/base/admin/category_edit.html | 73 | ||||
-rw-r--r-- | templates/web/base/admin/contact-form.html | 139 | ||||
-rw-r--r-- | templates/web/base/admin/open311-form-fields.html | 112 | ||||
-rw-r--r-- | templates/web/zurich/admin/body.html | 5 | ||||
-rw-r--r-- | templates/web/zurich/admin/contact-form.html | 21 | ||||
-rw-r--r-- | web/js/fixmystreet-admin.js | 24 |
8 files changed, 297 insertions, 297 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/body.html b/templates/web/base/admin/body.html index 52df20c89..0b8d3b18c 100644 --- a/templates/web/base/admin/body.html +++ b/templates/web/base/admin/body.html @@ -120,111 +120,13 @@ <h2>[% loc('Add new category') %]</h2> [% END %] -[% IF errors %] -<div class="fms-admin-warning"> - [% errors.values.join('<br>') %] -</div> -[% END %] + [% IF errors %] + <div class="fms-admin-warning"> + [% errors.values.join('<br>') %] + </div> + [% END %] - <form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> - - <div class="admin-hint"> - <p> - [% loc('Choose a <strong>category</strong> name that makes sense to the public (e.g., "Pothole", "Street lighting") but is helpful - to the body too. These will appear in the drop-down menu on the report-a-problem page.') %] - <br> - [% loc("If two or more bodies serve the same location, FixMyStreet combines identical categories into a single entry in - the menu. Make sure you use the same category name in the bodies if you want this to happen.") %] - </p> - </div> - <p> - <strong>[% loc('Category:') %] </strong><input type="text" class="form-control" name="category" size="30" value="[% contact.category | html %]"> - </p> - - <div class="admin-hint"> - <p> - [% loc("The <strong>email address</strong> is the destination to which reports about this category will be sent. - Other categories for this body may have the same email address.") %] - </p> - [% IF (body.send_method AND body.send_method != 'Email') OR body.can_be_devolved %] - <p> - [% loc("If you're using <strong>a send method that is not email</strong>, enter the service ID (Open311) or equivalent identifier here.") %] - </p> - [% END %] - </div> - - <p> - <strong>[% loc('Email address:') %] </strong><input type="text" class="form-control" name="email" size="30" value="[% contact.email | html %]"> - </p> - - <div class="admin-hint"> - <p> - [% loc("Check <strong>confirmed</strong> to indicate that this contact has been confirmed as correct. - If you are not sure of the origin or validity of the contact, leave this unchecked.") %] - </p> - </div> - <p> - <input type="checkbox" name="confirmed" value="1" id="confirmed"[% ' checked' IF contact.confirmed OR contact.confirmed == "" %]> - <label for="confirmed" class="inline">[% loc('Confirmed') %]</label> - </p> - - <div class="admin-hint"> - <p> - [% loc("Check <strong>deleted</strong> to remove the category from use. - It will not appear as an available category in the drop-down menu on the report-a-problem page.") %] - </p> - </div> - <p> - <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> - <label for="deleted" class="inline">[% loc('Deleted') %]</label> - </p> - - <div class="admin-hint"> - <p> - [% loc("Use the <strong>note</strong> to record details that are only displayed in the admin. Notes are not shown publicly, and are not sent to the body.") %] - </p> - </div> - <p> - <strong>[% loc('Note:') %] </strong> <textarea class="form-control" name="note" rows="3" cols="40"></textarea> - </p> - - <div class="admin-hint"> - <p> - [% loc("Check <strong>private</strong> if reports in this category should <strong>never be displayed on the website</strong>. - <br> - Normally, categories are not private. - <br> - This is suitable for issues that you want to allow users to report to the body, but for which there is no public - interest in displaying the report. In the UK, we've used this for services like requesting an extra rubbish bin - at a specific address.") %] - </p> - </div> - <p> - <input type="checkbox" name="non_public" value="1" id="non_public" [% ' checked' IF contact.non_public %]> - <label for="non_public" class="inline">[% loc('Private') %]</label> - </p> - - <div class="admin-hint"> - <p> - [% loc("Check <strong>inspection required</strong> if reports in this category <strong>must be inspected</strong> before being sent.") %] - </p> - </div> - <p> - <input type="checkbox" name="inspection_required" value="1" id="inspection_required" [% 'checked' IF contact.get_extra_metadata('inspection_required') %]> - <label for="inspection_required" class="inline">[% loc('Inspection required') %]</label> - </p> - - <p> - <input type="hidden" name="posted" value="new" > - <input type="hidden" name="token" value="[% csrf_token %]" > - <input type="submit" class="btn" name="Create category" value="[% errors ? loc('Save changes') : loc('Create category') %]" > - </p> - - <div> - <input type="hidden" name=".cgifields" value="confirmed" > - <input type="hidden" name=".cgifields" value="deleted" > - </div> - </form> + [% INCLUDE 'admin/contact-form.html' %] </div> [% IF NOT errors and c.user.is_superuser %] diff --git a/templates/web/base/admin/category_edit.html b/templates/web/base/admin/category_edit.html index ebaa495db..d1a323819 100644 --- a/templates/web/base/admin/category_edit.html +++ b/templates/web/base/admin/category_edit.html @@ -19,78 +19,7 @@ [% END %] </p> -<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8" id="category_edit"> - <p><strong>[% loc('Category:') %] </strong>[% contact.category | html %] - <input type="hidden" name="category" value="[% contact.category | html %]" > - <input type="hidden" name="token" value="[% csrf_token %]" > - - <p><strong>[% loc('Email:') %] </strong> - <input type="text" class="form-control" name="email" value="[% contact.email | html %]" size="30"> - - <p> - [% IF c.cobrand.moniker != 'zurich' %] - <input type="checkbox" name="confirmed" value="1" id="confirmed"[% ' checked' IF contact.confirmed %]> - <label class="inline" for="confirmed">[% loc('Confirmed' ) %]</label> - [% ELSE %] - <input type="hidden" name="confirmed" value="1"> - [% END %] - <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> - <label class="inline" for="deleted">[% loc('Deleted') %]</label> - [% IF c.cobrand.moniker != 'zurich' %] - <input type="checkbox" name="non_public" value="1" id="non_public"[% ' checked' IF contact.non_public %]> - <label class="inline" for="non_public">[% loc('Private') %]</label> - <input type="checkbox" name="inspection_required" value="1" id="inspection_required"[% ' checked' IF contact.get_extra_metadata('inspection_required') %]> - <label class="inline" for="inspection_required">[% loc('Inspection required') %]</label> - [% ELSE %] - <input type="checkbox" name="photo_required" value="1" id="photo_required"[% ' checked' IF contact.get_extra_metadata('photo_required') %]> - <label class="inline" for="photo_required">[% loc('Photo required') %]</label> - [% END %] - </p> - - [% IF c.cobrand.moniker != 'zurich' %] - <p [% 'class=hidden' UNLESS contact.get_extra_metadata('inspection_required') %]> - <label> - [% loc('Reputation threshold:') %] - <input type="text" class="form-control" name="reputation_threshold" id="reputation_threshold" - value="[% contact.get_extra_metadata('reputation_threshold') | html %]" size="30"> - </label> - </p> - [% END %] - - <p><strong>[% loc('Note:') %] </strong><textarea class="form-control" name="note" rows="3" cols="40"></textarea> - - [% IF body.can_be_devolved %] - <h2>[% loc('Configure Endpoint') %]</h2> - <form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> - <p> - <label for="endpoint">Endpoint</label> - <input type="text" class="form-control" name="endpoint" id="endpoint" value="[% contact.endpoint | html %]" size="50"> - </p> - - <p> - <label for="jurisdiction">Jurisdiction</label> - <input type="text" class="form-control" name="jurisdiction" id="jurisdiction" value="[% contact.jurisdiction | html %]" size="50"> - </p> - - <p> - <label for="api_key">Api Key</label> - <input type="text" class="form-control" name="api_key" id="api_key" value="[% contact.api_key | html %]" size="25"> - </p> - - <p> - <label for="send_method">Send Method</label> - <select class="form-control" name="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> - [% END %] - - <input type="hidden" name="posted" value="new"> - <p><input type="submit" class="btn" name="Save changes" value="[% loc('Save changes') %]"> -</form> +[% INCLUDE 'admin/contact-form.html' %] [% IF contact.extra %] <h2>[% loc('Extra data:') %] </h2> diff --git a/templates/web/base/admin/contact-form.html b/templates/web/base/admin/contact-form.html new file mode 100644 index 000000000..83f634188 --- /dev/null +++ b/templates/web/base/admin/contact-form.html @@ -0,0 +1,139 @@ +<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8" id="category_edit"> + + [% IF contact.in_storage %] + <p> + <h1>[% contact.category | html %]</h2> + <input type="hidden" name="category" value="[% contact.category | html %]" > + </p> + [% ELSE %] + <div class="admin-hint"> + <p> + [% loc('Choose a <strong>category</strong> name that makes sense to the public (e.g., "Pothole", "Street lighting") but is helpful + to the body too. These will appear in the drop-down menu on the report-a-problem page.') %] + <br> + [% loc("If two or more bodies serve the same location, FixMyStreet combines identical categories into a single entry in + the menu. Make sure you use the same category name in the bodies if you want this to happen.") %] + </p> + </div> + <p> + <strong>[% loc('Category') %] </strong><input type="text" class="form-control" name="category" size="30" value="[% contact.category | html %]" required> + </p> + [% END %] + + <div class="admin-hint"> + <p> + [% loc("The <strong>email address</strong> is the destination to which reports about this category will be sent. + Other categories for this body may have the same email address.") %] + </p> + [% IF (body.send_method AND body.send_method != 'Email') OR body.can_be_devolved %] + <p> + [% loc("If you're using <strong>a send method that is not email</strong>, enter the service ID (Open311) or equivalent identifier here.") %] + </p> + [% END %] + </div> + + <p> + <strong>[% loc('Email address') %] </strong><input type="text" class="form-control" name="email" size="30" value="[% contact.email | html %]" required> + </p> + + <div class="admin-hint"> + <p> + [% loc("Check <strong>confirmed</strong> to indicate that this contact has been confirmed as correct. + If you are not sure of the origin or validity of the contact, leave this unchecked.") %] + </p> + </div> + <p> + <input type="checkbox" name="confirmed" value="1" id="confirmed"[% ' checked' IF contact.confirmed OR contact.confirmed == "" %]> + <label for="confirmed" class="inline">[% loc('Confirmed') %]</label> + </p> + + <div class="admin-hint"> + <p> + [% loc("Check <strong>deleted</strong> to remove the category from use. + It will not appear as an available category in the drop-down menu on the report-a-problem page.") %] + </p> + </div> + <p> + <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> + <label for="deleted" class="inline">[% loc('Deleted') %]</label> + </p> + + <div class="admin-hint"> + <p> + [% loc("Check <strong>private</strong> if reports in this category should <strong>never be displayed on the website</strong>. + <br> + Normally, categories are not private. + <br> + This is suitable for issues that you want to allow users to report to the body, but for which there is no public + interest in displaying the report. In the UK, we've used this for services like requesting an extra rubbish bin + at a specific address.") %] + </p> + </div> + <p> + <input type="checkbox" name="non_public" value="1" id="non_public" [% ' checked' IF contact.non_public %]> + <label for="non_public" class="inline">[% loc('Private') %]</label> + </p> + + <div class="admin-hint"> + <p> + [% loc("Check <strong>inspection required</strong> if reports in this category <strong>must be inspected</strong> before being sent.") %] + </p> + </div> + <p> + <input type="checkbox" name="inspection_required" value="1" id="inspection_required" [% 'checked' IF contact.get_extra_metadata('inspection_required') %]> + <label for="inspection_required" class="inline">[% loc('Inspection required') %]</label> + </p> + + <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> + </div> + <p [% 'class=hidden' UNLESS contact.get_extra_metadata('inspection_required') %]> + <label> + [% loc('Reputation threshold') %] + <input type="text" class="form-control" name="reputation_threshold" id="reputation_threshold" + value="[% contact.get_extra_metadata('reputation_threshold') | html %]" size="30"> + </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.") %] + </p> + </div> + <p> + <label> + [% loc('Summarise your changes') %] + <input class="form-control" type="text" name="note" size="30" required> + </label> + </p> + + <p> + <input type="hidden" name="posted" value="new" > + <input type="hidden" name="token" value="[% csrf_token %]" > + <input type="submit" class="btn" name="Create category" value="[% contact.in_storage ? loc('Save changes') : loc('Create category') %]" > + </p> +</form> 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/templates/web/zurich/admin/body.html b/templates/web/zurich/admin/body.html index 435f42885..cf860990d 100644 --- a/templates/web/zurich/admin/body.html +++ b/templates/web/zurich/admin/body.html @@ -61,11 +61,6 @@ <input type="hidden" name="token" value="[% csrf_token %]" > <input type="submit" class="btn" name="Create category" value="[% errors ? loc('Save changes') : loc('Create category') %]"> </p> - - <div> - <input type="hidden" name=".cgifields" value="confirmed" > - <input type="hidden" name=".cgifields" value="deleted" > - </div> </form> [% END %] diff --git a/templates/web/zurich/admin/contact-form.html b/templates/web/zurich/admin/contact-form.html new file mode 100644 index 000000000..dddfc6d01 --- /dev/null +++ b/templates/web/zurich/admin/contact-form.html @@ -0,0 +1,21 @@ +<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8" id="category_edit"> + <p><strong>[% loc('Category:') %] </strong>[% contact.category | html %] + <input type="hidden" name="category" value="[% contact.category | html %]" > + <input type="hidden" name="token" value="[% csrf_token %]" > + + <p><strong>[% loc('Email:') %] </strong> + <input type="text" class="form-control" name="email" value="[% contact.email | html %]" size="30"> + + <p> + <input type="hidden" name="confirmed" value="1"> + <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> + <label class="inline" for="deleted">[% loc('Deleted') %]</label> + <input type="checkbox" name="photo_required" value="1" id="photo_required"[% ' checked' IF contact.get_extra_metadata('photo_required') %]> + <label class="inline" for="photo_required">[% loc('Photo required') %]</label> + </p> + + <p><strong>[% loc('Note:') %] </strong><textarea class="form-control" name="note" rows="3" cols="40"></textarea> + + <input type="hidden" name="posted" value="new"> + <p><input type="submit" class="btn" name="Save changes" value="[% loc('Save changes') %]"> +</form> diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index 6f4580feb..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); + }); } @@ -83,10 +86,17 @@ $(function(){ // On category edit page, hide the reputation input if inspection isn't required $("form#category_edit #inspection_required").change(function() { var $p = $("form#category_edit #reputation_threshold").closest("p"); + var $hint = $p.prevUntil().first(); if (this.checked) { $p.removeClass("hidden"); + if ($hint.length) { + $hint.removeClass("hidden"); + } } else { $p.addClass("hidden"); + if ($hint.length) { + $hint.addClass("hidden"); + } } }); }); |