aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/integration/oxfordshire.js25
-rwxr-xr-xbin/browser-tests16
-rwxr-xr-xbin/fixmystreet.com/fixture3
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm10
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm60
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm11
-rw-r--r--t/app/controller/report_inspect.t58
-rw-r--r--t/cobrand/oxfordshire.t51
-rw-r--r--templates/web/base/report/_inspect.html1
-rw-r--r--templates/web/base/report/_item.html4
-rw-r--r--templates/web/base/report/inspect/extra_details.html10
-rw-r--r--templates/web/oxfordshire/report/inspect/_extra_details_field.html35
-rw-r--r--templates/web/oxfordshire/report/inspect/_raise_defect.html107
-rw-r--r--web/cobrands/fixmystreet/staff.js13
16 files changed, 354 insertions, 64 deletions
diff --git a/.cypress/cypress/integration/oxfordshire.js b/.cypress/cypress/integration/oxfordshire.js
new file mode 100644
index 000000000..f235802e6
--- /dev/null
+++ b/.cypress/cypress/integration/oxfordshire.js
@@ -0,0 +1,25 @@
+describe("Oxfordshire cobrand", function() {
+ it("allows inspectors to instruct defects", function() {
+ cy.server();
+ cy.request({
+ method: 'POST',
+ url: 'http://oxfordshire.localhost:3001/auth',
+ form: true,
+ body: { username: 'inspector-instructor@example.org', password_sign_in: 'password' }
+ });
+ cy.visit('http://oxfordshire.localhost:3001/report/1');
+ cy.contains('Oxfordshire');
+
+ cy.get('#report_inspect_form').should('be.visible');
+ cy.get('#js-inspect-action-scheduled').should('not.be.visible');
+ cy.get('#raise_defect_yes').should('not.have.attr', 'required');
+
+ cy.get('#report_inspect_form select[name=state]').select('Action scheduled');
+ cy.get('#js-inspect-action-scheduled').should('be.visible');
+ cy.get('#raise_defect_yes').should('have.attr', 'required', 'required');
+
+ cy.get('#report_inspect_form select[name=state]').select('No further action');
+ cy.get('#js-inspect-action-scheduled').should('not.be.visible');
+ cy.get('#raise_defect_yes').should('not.have.attr', 'required');
+ });
+});
diff --git a/bin/browser-tests b/bin/browser-tests
index e0b9bedfe..bfbe4e51d 100755
--- a/bin/browser-tests
+++ b/bin/browser-tests
@@ -11,7 +11,19 @@ my ($cobrand, $coords, $area_id, $name, $mapit_url, $coverage);
BEGIN {
$config_file = 'conf/general.yml-example';
- $cobrand = [ 'borsetshire', 'fixmystreet', 'northamptonshire', 'bathnes', 'buckinghamshire', 'hounslow', 'isleofwight', 'peterborough', 'tfl', 'hackney' ];
+ $cobrand = [qw(
+ bathnes
+ borsetshire
+ buckinghamshire
+ fixmystreet
+ hackney
+ hounslow
+ isleofwight
+ northamptonshire
+ oxfordshire
+ peterborough
+ tfl
+ )];
$coords = '51.532851,-2.284277';
$area_id = 2608;
$name = 'Borsetshire';
@@ -190,7 +202,7 @@ browser-tests [running options] [fixture options] [cypress options]
--help this help message
Fixture option:
- --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight,peterborough,tfl,hackney
+ --cobrand Cobrand(s) to use, default is fixmystreet,northamptonshire,bathnes,buckinghamshire,isleofwight,peterborough,tfl,hackney,oxfordshire
--coords Default co-ordinates for created reports
--area_id Area ID to use for created body
--name Name to use for created body
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture
index e8dd3f364..59de8e222 100755
--- a/bin/fixmystreet.com/fixture
+++ b/bin/fixmystreet.com/fixture
@@ -103,6 +103,7 @@ if ($opt->test_fixtures) {
{ area_id => 2636, categories => [ 'Potholes', 'Private', 'Extra' ], name => 'Isle of Wight Council' },
{ area_id => 2566, categories => [ 'Fallen branch', 'Light Out', 'Light Dim', 'Fallen Tree', 'Damaged Tree' ], name => 'Peterborough City Council' },
{ area_id => 2498, categories => [ 'Incorrect timetable', 'Glass broken', 'Mobile Crane Operation' ], name => 'TfL' },
+ { area_id => 2237, categories => [ 'Flytipping', 'Roads', 'Parks' ], name => 'Oxfordshire County Council' },
) {
$bodies->{$_->{area_id}} = FixMyStreet::DB::Factory::Body->find_or_create($_);
my $cats = join(', ', @{$_->{categories}});
@@ -279,6 +280,7 @@ $priority->add_to_contacts($body->contacts->first);
say "Created users, all with password 'password':";
my %users;
my $perms_inspector = ['report_inspect', 'planned_reports'];
+my $perms_inspector_with_instruct = [@$perms_inspector, 'report_instruct'];
my $perms_cs = [
'contribute_as_body', 'contribute_as_another_user',
'moderate', 'view_body_contribute_details',
@@ -290,6 +292,7 @@ my $perms_cs_full = [
];
foreach (
{ name => 'Inspector Gadget', email => 'inspector@example.org', email_verified => 1, body => $body, permissions => $perms_inspector },
+ { name => 'Inspector Instructor', email => 'inspector-instructor@example.org', email_verified => 1, body => $body, permissions => $perms_inspector_with_instruct },
{ name => 'Harriet Helpful', email_verified => 1, email => 'cs@example.org', body => $body, permissions => $perms_cs },
{ name => 'Andrew Agreeable', email_verified => 1, email => 'cs_full@example.org', body => $body, permissions => $perms_cs_full },
{ name => 'Super User', email_verified => 1, email => 'super@example.org', body => $body, permissions => [
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 98c4aba17..1e5751588 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -467,7 +467,7 @@ sub inspect : Private {
}
}
- if ( $c->get_param('include_update') ) {
+ if ( $c->get_param('include_update') or $c->get_param('raise_defect') ) {
$update_text = Utils::cleanup_text( $c->get_param('public_update'), { allow_multiline => 1 } );
if (!$update_text) {
$valid = 0;
@@ -512,6 +512,14 @@ sub inspect : Private {
};
$c->user->create_alert($problem->id, $options);
}
+
+ # If the state has been changed to action scheduled and they've said
+ # they want to raise a defect, consider the report to be inspected.
+ if ($problem->state eq 'action scheduled' && $c->get_param('raise_defect') && !$problem->get_extra_metadata('inspected')) {
+ $update_params{extra} = { 'defect_raised' => 1 };
+ $problem->set_extra_metadata( inspected => 1 );
+ $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'inspected' ] );
+ }
}
$problem->non_public($c->get_param('non_public') ? 1 : 0);
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 2dfb0d7b1..e58bceb2a 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -1286,14 +1286,6 @@ sub category_extra_hidden {
return 0;
}
-sub traffic_management_options {
- return [
- _("Yes"),
- _("No"),
- ];
-}
-
-
=item display_days_ago_threshold
Used to control whether a relative 'n days ago' or absolute date is shown
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index 0f34ff09f..97174e1ce 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -155,6 +155,48 @@ sub open311_post_send {
$row->detail($self->{ox_original_detail});
}
+sub open311_munge_update_params {
+ my ($self, $params, $comment, $body) = @_;
+
+ if ($comment->get_extra_metadata('defect_raised')) {
+ my $p = $comment->problem;
+ my ($e, $n) = $p->local_coords;
+ my $usrn = $p->get_extra_field_value('usrn');
+ if (!$usrn) {
+ my $cfg = {
+ url => 'https://tilma.mysociety.org/mapserver/oxfordshire',
+ typename => "OCCRoads",
+ srsname => 'urn:ogc:def:crs:EPSG::27700',
+ accept_feature => sub { 1 },
+ filter => "<Filter xmlns:gml=\"http://www.opengis.net/gml\"><DWithin><PropertyName>SHAPE_GEOMETRY</PropertyName><gml:Point><gml:coordinates>$e,$n</gml:coordinates></gml:Point><Distance units='m'>20</Distance></DWithin></Filter>",
+ };
+ my $features = $self->_fetch_features($cfg);
+ my $feature = $self->_nearest_feature($cfg, $e, $n, $features);
+ if ($feature) {
+ my $props = $feature->{properties};
+ $usrn = Utils::trim_text($props->{TYPE1_2_USRN});
+ }
+ }
+ $params->{'attribute[usrn]'} = $usrn;
+ $params->{'attribute[raise_defect]'} = 1;
+ $params->{'attribute[easting]'} = $e;
+ $params->{'attribute[northing]'} = $n;
+ my $details = $comment->user->email . ' ';
+ if (my $traffic = $p->get_extra_metadata('traffic_information')) {
+ $details .= 'TM1 ' if $traffic eq 'Signs and Cones';
+ $details .= 'TM2 ' if $traffic eq 'Stop and Go Boards';
+ }
+ (my $type = $p->get_extra_metadata('defect_item_type')) =~ s/ .*//;
+ $details .= $type eq 'Sweep' ? 'S&F' : $type;
+ $details .= ' ' . ($p->get_extra_metadata('detailed_information') || '');
+ $params->{'attribute[extra_details]'} = $details;
+
+ foreach (qw(defect_item_category defect_item_type defect_item_detail defect_location_description)) {
+ $params->{"attribute[$_]"} = $p->get_extra_metadata($_);
+ }
+ }
+}
+
sub should_skip_sending_update {
my ($self, $update ) = @_;
@@ -168,18 +210,20 @@ sub should_skip_sending_update {
return 0;
}
-sub on_map_default_status { return 'open'; }
-sub admin_user_domain { 'oxfordshire.gov.uk' }
+sub report_inspect_update_extra {
+ my ( $self, $problem ) = @_;
-sub traffic_management_options {
- return [
- "Signs and Cones",
- "Stop and Go Boards",
- "High Speed Roads",
- ];
+ foreach (qw(defect_item_category defect_item_type defect_item_detail defect_location_description)) {
+ my $value = $self->{c}->get_param($_);
+ $problem->set_extra_metadata($_ => $value) if $value;
+ }
}
+sub on_map_default_status { return 'open'; }
+
+sub admin_user_domain { 'oxfordshire.gov.uk' }
+
sub admin_pages {
my $self = shift;
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index f472876ef..0e8341d57 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -425,7 +425,7 @@ sub _nearest_feature {
# We have a list of features, and we want to find the one closest to the
# report location.
- my $site_code = '';
+ my $chosen = '';
my $nearest;
# We shouldn't receive anything aside from these geometry types, but belt and braces.
@@ -452,14 +452,14 @@ sub _nearest_feature {
for (my $i=0; $i<@$coordinates-1; $i++) {
my $distance = $self->_distanceToLine($x, $y, $coordinates->[$i], $coordinates->[$i+1]);
if ( !defined $nearest || $distance < $nearest ) {
- $site_code = $feature->{properties}->{$cfg->{property}};
+ $chosen = $feature;
$nearest = $distance;
}
}
}
}
- return $site_code;
+ return $cfg->{property} && $chosen ? $chosen->{properties}->{$cfg->{property}} : $chosen;
}
sub contact_name {
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index cd5e876b4..ceb41b40f 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -1125,17 +1125,6 @@ has duplicates => (
},
);
-has traffic_management_options => (
- is => 'ro',
- lazy => 1,
- default => sub {
- my $self = shift;
- my $cobrand = $self->get_cobrand_logged;
- $cobrand = $cobrand->call_hook(get_body_handler_for_problem => $self) || $cobrand;
- return $cobrand->traffic_management_options;
- },
-);
-
has inspection_log_entry => (
is => 'ro',
lazy => 1,
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t
index c10fe7f94..3f267a086 100644
--- a/t/app/controller/report_inspect.t
+++ b/t/app/controller/report_inspect.t
@@ -60,7 +60,6 @@ FixMyStreet::override_config {
$mech->content_lacks('Save changes');
$mech->content_lacks('Private');
$mech->content_lacks('Priority');
- $mech->content_lacks('Traffic management');
$mech->content_lacks('Change asset');
$mech->content_lacks('/admin/report_edit/'.$report_id.'">admin</a>)');
@@ -70,7 +69,6 @@ FixMyStreet::override_config {
$mech->content_contains('Save changes');
$mech->content_lacks('Change asset');
$mech->content_lacks('Priority');
- $mech->content_lacks('Traffic management');
$mech->content_lacks('/admin/report_edit/'.$report_id.'">admin</a>)');
$user->user_body_permissions->create({ body => $oxon, permission_type => 'report_edit_priority' });
@@ -79,7 +77,6 @@ FixMyStreet::override_config {
$mech->content_contains('Save changes');
$mech->content_contains('Priority');
$mech->content_lacks('Change asset');
- $mech->content_lacks('Traffic management');
$mech->content_lacks('/admin/report_edit/'.$report_id.'">admin</a>)');
$user->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' });
@@ -87,7 +84,6 @@ FixMyStreet::override_config {
$mech->content_contains('Save changes');
$mech->content_contains('Private');
$mech->content_contains('Priority');
- $mech->content_contains('Traffic management');
$mech->content_contains('Change asset');
$mech->content_lacks('/admin/report_edit/'.$report_id.'">admin</a>)');
};
@@ -210,14 +206,14 @@ FixMyStreet::override_config {
$user->user_body_permissions->create({ body => $oxon, permission_type => 'report_inspect' });
$mech->get_ok("/report/$report_id");
- $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Yes', state => 'Action scheduled', include_update => undef } });
+ $mech->submit_form_ok({ button => 'save', with_fields => { detailed_information => 'Info', state => 'Action scheduled', include_update => undef } });
$report->discard_changes;
my $alert = FixMyStreet::DB->resultset('Alert')->find(
{ user => $user, alert_type => 'new_updates', confirmed => 1, }
);
is $report->state, 'action scheduled', 'report state changed';
- is $report->get_extra_metadata('traffic_information'), 'Yes', 'report data changed';
+ is $report->get_extra_metadata('detailed_information'), 'Info', 'report data changed';
ok defined( $alert ) , 'sign up for alerts';
};
@@ -246,7 +242,7 @@ FixMyStreet::override_config {
$user->update;
};
- subtest "test update is required when instructing" => sub {
+ subtest "test public update is required if include_update is checked" => sub {
$report->update;
$report->comments->delete_all;
$mech->get_ok("/report/$report_id");
@@ -703,15 +699,6 @@ FixMyStreet::override_config {
return $perms;
});
- subtest "Oxfordshire-specific traffic management options are shown" => sub {
- $report->update({ state => 'confirmed' });
- $mech->get_ok("/report/$report_id");
- $mech->submit_form_ok({ button => 'save', with_fields => { traffic_information => 'Signs and Cones', state => 'Action scheduled', include_update => undef } });
- $report->discard_changes;
- is $report->state, 'action scheduled', 'report state changed';
- is $report->get_extra_metadata('traffic_information'), 'Signs and Cones', 'report data changed';
- };
-
subtest "admin link present on inspect page on cobrand" => sub {
my $report_edit_permission = $user->user_body_permissions->create({
body => $oxon, permission_type => 'report_edit' });
@@ -745,7 +732,6 @@ FixMyStreet::override_config {
priority => $rp->id,
include_update => '1',
detailed_information => 'XXX164XXXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
- traffic_information => '',
photo1 => '',
photo2 => '',
photo3 => '',
@@ -913,6 +899,44 @@ FixMyStreet::override_config {
$contact2->unset_extra_metadata('assigned_users_only');
$contact2->update;
};
+
+ subtest 'instruct defect' => sub {
+ $user->user_body_permissions->create({ body => $oxon, permission_type => 'report_instruct' });
+ $mech->get_ok("/report/$report2_id");
+ $mech->submit_form_ok({ button => 'save', with_fields => {
+ public_update => "This is a public update.", include_update => "1",
+ traffic_information => 'Signs and cones',
+ state => 'action scheduled', raise_defect => 1,
+ defect_item_category => 'Kerbing',
+ } });
+ $report2->discard_changes;
+ is $report2->get_extra_metadata('inspected'), 1, 'report marked as inspected';
+ $mech->get_ok("/report/$report2_id");
+ $mech->content_like(qr/Defect category<\/dt>\s*<dd>Kerbing/);
+ my $meta = $mech->extract_update_metas;
+ like $meta->[0], qr/State changed to: Action scheduled/, 'First update mentions action scheduled';
+ like $meta->[1], qr/Posted by .*defect raised/, 'Update mentions defect raised';
+ my $log_entry = $report2->inspection_log_entry;
+ is $log_entry->object_id, $report2_id, 'Log entry has correct ID';
+ is $log_entry->object_type, 'problem', 'Log entry has correct type';
+ is $log_entry->action, 'inspected', 'Log entry has correct action';
+ };
+
+ subtest "test update is required when instructing defect" => sub {
+ $report2->unset_extra_metadata('inspected');
+ $report2->update;
+ $report2->inspection_log_entry->delete;
+ $report2->comments->delete_all;
+ $mech->get_ok("/report/$report2_id");
+ $mech->submit_form_ok({ button => 'save', with_fields => {
+ public_update => "", include_update => "0",
+ state => 'action scheduled', raise_defect => 1,
+ } });
+ is_deeply $mech->page_errors, [ "Please provide a public update for this report." ], 'errors match';
+ $report2->discard_changes;
+ is $report2->comments->count, 0, "Update wasn't created";
+ is $report2->get_extra_metadata('inspected'), undef, 'report not marked as inspected';
+ };
};
done_testing();
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index cfa98254f..a1c842e2d 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -4,6 +4,7 @@ use CGI::Simple;
use FixMyStreet::TestMech;
use FixMyStreet::Script::Alerts;
use FixMyStreet::Script::Reports;
+use Open311;
my $mech = FixMyStreet::TestMech->new;
my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council');
@@ -178,6 +179,56 @@ FixMyStreet::override_config {
};
}
+ subtest 'extra data sent with defect update' => sub {
+ my $comment = FixMyStreet::DB->resultset('Comment')->first;
+ $comment->set_extra_metadata(defect_raised => 1);
+ $comment->update;
+ $comment->problem->external_id('hey');
+ $comment->problem->set_extra_metadata(defect_location_description => 'Location');
+ $comment->problem->set_extra_metadata(defect_item_category => 'Kerbing');
+ $comment->problem->set_extra_metadata(defect_item_type => 'Damaged');
+ $comment->problem->set_extra_metadata(defect_item_detail => '1 kerb unit or 1 linear m');
+ $comment->problem->set_extra_metadata(traffic_information => 'Signs and Cones');
+ $comment->problem->set_extra_metadata(detailed_information => '100x100');
+ $comment->problem->update;
+
+ my $cbr = Test::MockModule->new('FixMyStreet::Cobrand::Oxfordshire');
+ $cbr->mock('_fetch_features', sub {
+ my ($self, $cfg, $x, $y) = @_;
+ [ {
+ type => 'Feature',
+ geometry => { type => 'LineString', coordinates => [ [ 1, 2 ], [ 3, 4 ] ] },
+ properties => { TYPE1_2_USRN => 13579 },
+ } ];
+ });
+ my $test_res = HTTP::Response->new();
+ $test_res->code(200);
+ $test_res->message('OK');
+ $test_res->content('<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id>248</update_id></request_update></service_request_updates>');
+
+ my $o = Open311->new(
+ fixmystreet_body => $oxon,
+ test_mode => 1,
+ test_get_returns => { 'servicerequestupdates.xml' => $test_res },
+ );
+
+ $o->post_service_request_update($comment);
+ my $cgi = CGI::Simple->new($o->test_req_used->content);
+ is $cgi->param('attribute[usrn]'), 13579, 'USRN sent with update';
+ is $cgi->param('attribute[raise_defect]'), 1, 'Defect flag sent with update';
+ is $cgi->param('attribute[defect_item_category]'), 'Kerbing';
+ is $cgi->param('attribute[extra_details]'), $user2->email . ' TM1 Damaged 100x100';
+
+ # Now set a USRN on the problem (found at submission)
+ $comment->problem->push_extra_fields({ name => 'usrn', value => '12345' });
+ $comment->problem->update;
+
+ $o->post_service_request_update($comment);
+ $cgi = CGI::Simple->new($o->test_req_used->content);
+ is $cgi->param('attribute[usrn]'), 12345, 'USRN sent with update';
+ is $cgi->param('attribute[raise_defect]'), 1, 'Defect flag sent with update';
+ };
+
};
done_testing();
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index 30848b5d4..1877640b4 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -34,6 +34,7 @@
<label for="state">[% loc('State') %]</label>
[% INCLUDE 'report/inspect/state_groups_select.html' %]
</p>
+ [% TRY %][% INCLUDE 'report/inspect/_raise_defect.html' %][% CATCH file %][% END %]
<div id="js-duplicate-reports" class="[% "hidden" UNLESS problem.duplicate_of %]">
<input type="hidden" name="duplicate_of" value="[% problem.duplicate_of.id %]">
<p class="[% "hidden" UNLESS problem.duplicate_of %]"><strong>[% loc('Duplicate of') %]</strong></p>
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index 9a5168986..f25d5d2a1 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -96,10 +96,6 @@ END;
<p>[% problem.response_priority.name OR '-' %]</p>
</div>
<div>
- <h4>[% loc('Traffic management required?') %]</h4>
- <p>[% problem.get_extra_metadata('traffic_information') %]</p>
- </div>
- <div>
<h4>[% loc('Extra details') %]</h4>
<p>[% problem.get_extra_metadata('detailed_information') | html %]</p>
</div>
diff --git a/templates/web/base/report/inspect/extra_details.html b/templates/web/base/report/inspect/extra_details.html
index 66e464cef..621ae3688 100644
--- a/templates/web/base/report/inspect/extra_details.html
+++ b/templates/web/base/report/inspect/extra_details.html
@@ -9,15 +9,5 @@
</p>
[% IF permissions.report_inspect %]
- <p>
- <label for="traffic_information">[% loc('Traffic management required?') %]</label>
- [% traffic_info = problem.get_extra_metadata('traffic_information') %]
- <select id="traffic_information" name="traffic_information" class="form-control">
- <option value=""[% ' selected' IF NOT traffic_info %]>-</option>
- [% FOREACH option IN problem.traffic_management_options %]
- <option value='[% option %]'[% ' selected' IF traffic_info == option %]>[% option %]</option>
- [% END %]
- </select>
- </p>
[% INCLUDE 'report/inspect/_extra_details_field.html' %]
[% END %]
diff --git a/templates/web/oxfordshire/report/inspect/_extra_details_field.html b/templates/web/oxfordshire/report/inspect/_extra_details_field.html
new file mode 100644
index 000000000..5fc7b0086
--- /dev/null
+++ b/templates/web/oxfordshire/report/inspect/_extra_details_field.html
@@ -0,0 +1,35 @@
+<p>
+ <label for="detailed_information">[% loc('Extra details') %]</label>
+ [% IF max_detailed_info_length %]
+ <span id="detailed_information_length">
+ [% tprintf(loc('%d characters maximum'), max_detailed_info_length) %]
+ </span>
+ [% END %]
+ <span class="js-inspect-defect-yes hidden-js">
+ <br>[% c.user.email %] <span id="js-defect-prefix"></span> &hellip;
+ </span>
+ <textarea rows="2" name="detailed_information" id="detailed_information" class="form-control"
+ [% IF max_detailed_info_length %]data-max-length="[% max_detailed_info_length %]"[% END %]>[% problem.get_extra_metadata('detailed_information') | html %]</textarea>
+</p>
+
+<script nonce="[% csp_nonce %]">
+(function(){
+ function update_prefix() {
+ var prefix = document.getElementById('js-defect-prefix');
+ var text = '';
+ var traffic = document.getElementById('traffic_information');
+ if (traffic.selectedIndex) {
+ text += 'TM' + traffic.selectedIndex + ' ';
+ }
+ var type = document.getElementById('defect_item_type');
+ type = type.options[type.selectedIndex].value;
+ type = type.split(' ')[0];
+ text += (type == 'Sweep') ? 'S&F' : type;
+ text += ' ';
+ prefix.textContent = text;
+ }
+
+ document.getElementById('traffic_information').addEventListener('change', update_prefix);
+ document.getElementById('defect_item_type').addEventListener('change', update_prefix);
+})();
+</script>
diff --git a/templates/web/oxfordshire/report/inspect/_raise_defect.html b/templates/web/oxfordshire/report/inspect/_raise_defect.html
new file mode 100644
index 000000000..d6e05d3b5
--- /dev/null
+++ b/templates/web/oxfordshire/report/inspect/_raise_defect.html
@@ -0,0 +1,107 @@
+[% IF permissions.report_instruct %]
+
+[% IF problem.get_extra_metadata('inspected') AND NOT errors %]
+
+<dl>
+ <dt>Defect category</dt>
+ <dd>[% problem.get_extra_metadata('defect_item_category') %]</dd>
+
+ <dt>Defect type</dt>
+ <dd>[% problem.get_extra_metadata('defect_item_type') %]</dd>
+
+ <dt>Defect detail</dt>
+ <dd>[% problem.get_extra_metadata('defect_item_detail') %]</dd>
+
+ <dt>Location description</dt>
+ <dd>[% problem.get_extra_metadata('defect_location_description') %]</dd>
+
+ <dt>Traffic management required?</dt>
+ <dd>[% problem.get_extra_metadata('traffic_information') %]</dd>
+</dl>
+
+[% ELSE %]
+
+<div id="js-inspect-action-scheduled" class="[% "hidden" UNLESS problem.state == 'action scheduled' %]">
+
+ <p>[% loc('Do you want to automatically raise a defect?') %]</p>
+ <p class="segmented-control segmented-control--radio">
+ <input type="radio" name="raise_defect" id="raise_defect_yes" value="1" data-show=".js-inspect-defect-yes">
+ <label class="btn" for="raise_defect_yes">[% loc('Yes') %]</label>
+ <input type="radio" name="raise_defect" id="raise_defect_no" value="0" data-hide=".js-inspect-defect-yes">
+ <label class="btn" for="raise_defect_no">[% loc('No') %]</label>
+ </p>
+
+ <div class="js-inspect-defect-yes hidden-js">
+
+ <p>Please fill in the below:</p>
+
+ <label for="defect_item_category">Defect category</label>
+ <select id="defect_item_category" name="defect_item_category" class="form-control" required>
+ <option value="">-- Pick a category --</option>
+ <option data-show=".defect-non-kerb-options" data-hide=".defect-kerb-options">Minor Carriageway</option>
+ <option data-show=".defect-non-kerb-options" data-hide=".defect-kerb-options">Footway/ Cycleway</option>
+ <option data-show=".defect-kerb-options" data-hide=".defect-non-kerb-options">Kerbing</option>
+ </select>
+
+ <label for="defect_item_type">Defect type</label>
+ <select id="defect_item_type" name="defect_item_type" class="form-control" required>
+ <option value="">-- Pick a type --</option>
+ <optgroup class="defect-non-kerb-options" label="Minor Carriageway/ Footway/ Cycleway">
+ <option>Sweep &amp; Fill</option>
+ </optgroup>
+ <optgroup class="defect-kerb-options" label="Kerbing">
+ <option>Damaged</option>
+ <option>Loose</option>
+ <option>Misaligned Single Units or Uneven Run of Units</option>
+ <option>Missing</option>
+ </optgroup>
+ </select>
+
+ <label for="defect_item_detail">Defect detail</label>
+ <select id="defect_item_detail" name="defect_item_detail" class="form-control" required>
+ <option value="">-- Pick a detail --</option>
+ <optgroup class="defect-non-kerb-options" label="Minor Carriageway/ Footway/ Cycleway">
+ <option>Pothole Sweep &amp; Fill 0-1m&sup2;</option>
+ <option>Pothole Cluster Sweep &amp; Fill 1-2m&sup2;</option>
+ </optgroup>
+ <optgroup class="defect-kerb-options" label="Kerbing">
+ <option>1 kerb unit or 1 linear m</option>
+ <option>Greater than 1 kerb unit or 1 linear m</option>
+ </optgroup>
+ </select>
+
+ <label for="traffic_information">[% loc('Traffic management required?') %]</label>
+ [% traffic_info = problem.get_extra_metadata('traffic_information') %]
+ <select id="traffic_information" name="traffic_information" class="form-control">
+ <option value=""[% ' selected' IF NOT traffic_info %]>-</option>
+ [% FOREACH option IN ['Signs and Cones', 'Stop and Go Boards'] %]
+ <option value='[% option %]'[% ' selected' IF traffic_info == option %]>[% option %]</option>
+ [% END %]
+ </select>
+
+ <label for="defect_location_description">Location description</label>
+ <textarea rows="2" id="defect_location_description" name="defect_location_description" class="form-control"></textarea>
+
+ </div>
+
+</div>
+
+<script nonce="[% csp_nonce %]">
+(function(){
+ var item = document.getElementById('defect_item_category');
+ item.addEventListener('change', function(){
+ var opt = item.options[item.selectedIndex].value;
+ if (opt !== 'Kerbing') {
+ var type = document.getElementById('defect_item_type');
+ type.selectedIndex = 1;
+ var event = document.createEvent("Event");
+ event.initEvent("change", true, false);
+ type.dispatchEvent(event);
+ }
+ });
+})();
+</script>
+
+[% END %]
+
+[% END %]
diff --git a/web/cobrands/fixmystreet/staff.js b/web/cobrands/fixmystreet/staff.js
index 4bbc0b11d..ec85dbb8d 100644
--- a/web/cobrands/fixmystreet/staff.js
+++ b/web/cobrands/fixmystreet/staff.js
@@ -1,4 +1,16 @@
fixmystreet.staff_set_up = {
+ action_scheduled_raise_defect: function() {
+ $("#report_inspect_form").find('[name=state]').on('change', function() {
+ if ($(this).val() !== "action scheduled") {
+ $("#js-inspect-action-scheduled").addClass("hidden");
+ $('#raise_defect_yes').prop('required', false);
+ } else {
+ $("#js-inspect-action-scheduled").removeClass("hidden");
+ $('#raise_defect_yes').prop('required', true);
+ }
+ });
+ },
+
list_item_actions: function() {
$('#js-reports-list').on('click', ':submit', function(e) {
e.preventDefault();
@@ -423,6 +435,7 @@ $(fixmystreet).on('display:report', function() {
fixmystreet.staff_set_up.response_templates();
if ($("#report_inspect_form").length) {
fixmystreet.staff_set_up.report_page_inspect();
+ fixmystreet.staff_set_up.action_scheduled_raise_defect();
}
});