aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-09-19 16:52:07 +0100
committerDave Arter <davea@mysociety.org>2016-09-23 11:53:51 +0100
commit6cbecb9445057bf7b892309d6e9af7b0f2a90ba7 (patch)
tree25bc4dad31447d53670e1ede8e7e6b282803b9bf
parent928d5335136e1da9c05ab3a9c746c9eec31b1272 (diff)
Add UI for managing category reputation threshold
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm3
-rw-r--r--templates/web/base/admin/category_edit.html11
-rw-r--r--web/js/fixmystreet-admin.js10
3 files changed, 23 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 46ac10d36..8ec9eeaab 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -385,6 +385,9 @@ sub update_contacts : Private {
else {
$contact->unset_extra_metadata( 'inspection_required' );
}
+ if ( $c->get_param('reputation_threshold') ) {
+ $contact->set_extra_metadata( reputation_threshold => int($c->get_param('reputation_threshold')) );
+ }
if ( %errors ) {
$c->stash->{updated} = _('Please correct the errors below');
diff --git a/templates/web/base/admin/category_edit.html b/templates/web/base/admin/category_edit.html
index 6aec0c132..05fa2ca4e 100644
--- a/templates/web/base/admin/category_edit.html
+++ b/templates/web/base/admin/category_edit.html
@@ -19,7 +19,7 @@
[% END %]
</p>
-<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8">
+<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 %]" >
@@ -47,6 +47,15 @@
[% END %]
</p>
+ [% IF c.cobrand.moniker != 'zurich' %]
+ <p [% 'class=hidden' UNLESS contact.get_extra_metadata('inspection_required') %]>
+ <label>
+ [% loc('Reputation threshold:') %]
+ <input type="text" 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 name="note" rows="3" cols="40"></textarea>
[% IF body.can_be_devolved %]
diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js
index aa79a9b46..6f4580feb 100644
--- a/web/js/fixmystreet-admin.js
+++ b/web/js/fixmystreet-admin.js
@@ -79,5 +79,15 @@ $(function(){
var show_area = $(this).val() == $(this).find("[data-originally-selected]").val();
$("form#user_edit select#area_id").closest("li").toggle(show_area);
});
+
+ // 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");
+ if (this.checked) {
+ $p.removeClass("hidden");
+ } else {
+ $p.addClass("hidden");
+ }
+ });
});