diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm | 1 | ||||
-rw-r--r-- | t/app/controller/admin.t | 20 | ||||
-rw-r--r-- | templates/web/base/admin/responsepriorities/edit.html | 12 | ||||
-rw-r--r-- | templates/web/base/admin/responsepriorities/list.html | 2 |
5 files changed, 36 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fc68419b..86fd35983 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Clearer highlight for selected duplicate on inspect form. #1798 - Include MapIt API key on admin config page. #1778 - Redirect to same map view after inspection. #1820 + - A default response priority can now be set #1838 - Bugfixes: - Set up action scheduled field when report loaded. #1789 - Fix display of thumbnail images on page reload. #1815 diff --git a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm index bae0f71a7..7b206690e 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/ResponsePriorities.pm @@ -71,6 +71,7 @@ sub edit : Path : Args(2) { $priority->name( $c->get_param('name') ); $priority->description( $c->get_param('description') ); $priority->external_id( $c->get_param('external_id') ); + $priority->is_default( $c->get_param('is_default') ? 1 : 0 ); $priority->update_or_insert; my @live_contact_ids = map { $_->id } @live_contacts; diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 075ab0fd0..bd0f9e408 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1470,6 +1470,7 @@ subtest "response priorities can be added" => sub { name => "Cat 1A", description => "Fixed within 24 hours", deleted => undef, + is_default => undef, "contacts[".$oxfordshirecontact->id."]" => 1, }; $mech->submit_form_ok( { with_fields => $fields } ); @@ -1478,6 +1479,25 @@ subtest "response priorities can be added" => sub { is $oxfordshirecontact->response_priorities->count, 1, "Response template was added to contact"; }; +subtest "response priorities can set to default" => sub { + my $priority_id = $oxfordshire->response_priorities->first->id; + is $oxfordshire->response_priorities->count, 1, "Response priority exists"; + $mech->get_ok( "/admin/responsepriorities/" . $oxfordshire->id . "/$priority_id" ); + + my $fields = { + name => "Cat 1A", + description => "Fixed within 24 hours", + deleted => undef, + is_default => 1, + "contacts[".$oxfordshirecontact->id."]" => 1, + }; + $mech->submit_form_ok( { with_fields => $fields } ); + + is $oxfordshire->response_priorities->count, 1, "Still one response priority"; + is $oxfordshirecontact->response_priorities->count, 1, "Still one response template"; + ok $oxfordshire->response_priorities->first->is_default, "Response priority set to default"; +}; + subtest "response priorities can be listed" => sub { $mech->get_ok( "/admin/responsepriorities/" . $oxfordshire->id ); diff --git a/templates/web/base/admin/responsepriorities/edit.html b/templates/web/base/admin/responsepriorities/edit.html index 07d6906ba..608f19e74 100644 --- a/templates/web/base/admin/responsepriorities/edit.html +++ b/templates/web/base/admin/responsepriorities/edit.html @@ -30,6 +30,18 @@ <div class="admin-hint"> <p> + [% loc('Select if this is the default priority') %] + </p> + </div> + <p> + <label> + <input type="checkbox" name="is_default" is="is_deleted" value="1"[% ' checked' IF rp.is_default %]> + [% loc('Default priority') %] + </label> + </p> + + <div class="admin-hint"> + <p> [% loc('If you only want this priority to be an option for specific categories, pick them here. By default they will show for all categories.') %] </p> </div> diff --git a/templates/web/base/admin/responsepriorities/list.html b/templates/web/base/admin/responsepriorities/list.html index 80d4e2cee..eedaccfdb 100644 --- a/templates/web/base/admin/responsepriorities/list.html +++ b/templates/web/base/admin/responsepriorities/list.html @@ -6,6 +6,7 @@ <th> [% loc('Name') %] </th> <th> [% loc('Description') %] </th> <th> [% loc('Categories') %] </th> + <th> [% loc('Default') %] </th> <th> </th> </tr> </thead> @@ -23,6 +24,7 @@ [% END %] [% END %] </td> + <td> [% IF p.is_default %]X[% END %]</td> <td> <a href="[% c.uri_for('', body.id, p.id) %]" class="btn">[% loc('Edit') %]</a> </td> </tr> [% END %] |