aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm25
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm8
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm26
-rw-r--r--perllib/FixMyStreet/SendReport/Email/TfL.pm23
-rw-r--r--t/app/controller/report_new.t6
-rw-r--r--t/app/sendreport/email/tfl.t32
-rw-r--r--t/cobrand/bromley.t34
-rw-r--r--templates/web/base/report/_item.html4
-rw-r--r--templates/web/bromley/report/_item.html23
-rw-r--r--templates/web/bromley/report/_item_heading.html1
-rw-r--r--templates/web/bromley/reports/_list-entry.html4
-rw-r--r--templates/web/buckinghamshire/report/_item.html139
-rw-r--r--templates/web/buckinghamshire/report/_item_heading.html1
-rw-r--r--web/cobrands/bromley/map.js25
-rw-r--r--web/cobrands/fixmystreet/assets.js2
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js17
16 files changed, 147 insertions, 223 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index b5e5c5738..aa2e09892 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -872,7 +872,6 @@ sub process_report : Private {
'partial', #
'service', #
'non_public',
- 'single_body_only'
);
# load the report
@@ -931,8 +930,18 @@ sub process_report : Private {
return 1;
}
- my $bodies = $c->forward('contacts_to_bodies', [ $report->category, $params{single_body_only} ]);
- my $body_string = join(',', map { $_->id } @$bodies) || '-1';
+ # check that we've not indicated we only want to sent to a single body
+ # and if we find a matching one then only send to that. e.g. if we clicked
+ # on a TfL road on the map.
+ my $body_string = do {
+ if (my $single_body_only = $c->get_param('single_body_only')) {
+ my $body = $c->model('DB::Body')->search({ name => $single_body_only })->first;
+ $body ? $body->id : '-1';
+ } else {
+ my $bodies = $c->forward('contacts_to_bodies', [ $report->category ]);
+ join(',', map { $_->id } @$bodies) || '-1';
+ }
+ };
$report->bodies_str($body_string);
# Record any body IDs which might have meant to match, but had no contact
@@ -988,18 +997,10 @@ sub process_report : Private {
}
sub contacts_to_bodies : Private {
- my ($self, $c, $category, $single_body_only) = @_;
+ my ($self, $c, $category) = @_;
my @contacts = grep { $_->category eq $category } @{$c->stash->{contacts}};
- # check that we've not indicated we only want to sent to a single body
- # and if we find a matching one then only send to that. e.g. if we clicked
- # on a TfL road on the map.
- if ($single_body_only) {
- my @contacts_filtered = grep { $_->body->name eq $single_body_only } @contacts;
- @contacts = @contacts_filtered if scalar @contacts_filtered;
- }
-
if ($c->stash->{unresponsive}{$category} || $c->stash->{unresponsive}{ALL} || !@contacts) {
[];
} else {
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index 5d14d0b01..36a3e3d5f 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -16,6 +16,13 @@ sub base_url {
return 'https://fix.bromley.gov.uk';
}
+sub problems_on_map_restriction {
+ my ($self, $rs) = @_;
+ return $rs if FixMyStreet->staging_flag('skip_checks');
+ my $tfl = FixMyStreet::DB->resultset('Body')->search({ name => 'TfL' })->first;
+ return $rs->to_body($tfl ? [ $self->body->id, $tfl->id ] : $self->body);
+}
+
sub default_show_name { 0 }
sub disambiguate_location {
@@ -64,6 +71,7 @@ sub map_type {
# Bromley pins always yellow
sub pin_colour {
my ( $self, $p, $context ) = @_;
+ return 'grey' if !$self->owns_problem( $p );
return 'yellow';
}
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 753aa2404..25f809d8c 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -38,10 +38,11 @@ sub restriction {
return { cobrand => shift->moniker };
}
-# UK cobrands assume that each MapIt area ID maps both ways with one body
+# UK cobrands assume that each MapIt area ID maps both ways with one
+# body. Except TfL.
sub body {
my $self = shift;
- my $body = FixMyStreet::DB->resultset('Body')->for_areas($self->council_area_id)->first;
+ my $body = FixMyStreet::DB->resultset('Body')->for_areas($self->council_area_id)->search({ name => { '!=', 'TfL' } })->first;
return $body;
}
@@ -175,28 +176,27 @@ sub owns_problem {
} else { # Object
@bodies = values %{$report->bodies};
}
- my %areas = map { %{$_->areas} } @bodies;
+ # Want to ignore the TfL body that covers London councils
+ my %areas = map { %{$_->areas} } grep { $_->name ne 'TfL' } @bodies;
return $areas{$self->council_area_id} ? 1 : undef;
}
-# If the council is two-tier then show pins for the other council as grey
+# If the council is two-tier, or e.g. TfL reports,
+# then show pins for the other council as grey
sub pin_colour {
my ( $self, $p, $context ) = @_;
- return 'grey' if $self->is_two_tier && !$self->owns_problem( $p );
+ return 'grey' if !$self->owns_problem( $p );
return $self->next::method($p, $context);
}
-# If we ever link to a county problem report, needs to be to main FixMyStreet
+# If we ever link to a county problem report, or a TfL report,
+# needs to be to main FixMyStreet
sub base_url_for_report {
my ( $self, $report ) = @_;
- if ( $self->is_two_tier ) {
- if ( $self->owns_problem( $report ) ) {
- return $self->base_url;
- } else {
- return FixMyStreet->config('BASE_URL');
- }
- } else {
+ if ( $self->owns_problem( $report ) ) {
return $self->base_url;
+ } else {
+ return FixMyStreet->config('BASE_URL');
}
}
diff --git a/perllib/FixMyStreet/SendReport/Email/TfL.pm b/perllib/FixMyStreet/SendReport/Email/TfL.pm
new file mode 100644
index 000000000..801489c62
--- /dev/null
+++ b/perllib/FixMyStreet/SendReport/Email/TfL.pm
@@ -0,0 +1,23 @@
+package FixMyStreet::SendReport::Email::TfL;
+
+use Moo;
+extends 'FixMyStreet::SendReport::Email';
+
+sub build_recipient_list {
+ my ( $self, $row, $h ) = @_;
+
+ return unless @{$self->bodies} == 1;
+ my $body = $self->bodies->[0];
+
+ # We don't care what the category was, look up the Traffic lights contact
+ my $contact = $row->result_source->schema->resultset("Contact")->not_deleted->find({
+ body_id => $body->id,
+ category => 'Traffic lights',
+ });
+ return unless $contact;
+
+ @{$self->to} = map { [ $_, $body->name ] } split /,/, $contact->email;
+ return 1;
+}
+
+1;
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index dff04176b..4022ba31a 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -960,9 +960,9 @@ foreach my $test (
email_count => 1,
},
{
- desc => "test invalid single_body_only means multiple report bodies",
+ desc => "test invalid single_body_only means no report bodies",
category => 'Street lighting',
- councils => [ 2226, 2326 ],
+ councils => [],
extra_fields => { single_body_only => 'Invalid council' },
email_count => 1,
},
@@ -1036,7 +1036,7 @@ foreach my $test (
ok $report, "Found the report";
# Check the report has been assigned appropriately
- is $report->bodies_str, join(',', @body_ids{@{$test->{councils}}});
+ is $report->bodies_str, join(',', @body_ids{@{$test->{councils}}}) || undef;
$mech->content_contains('Thank you for reporting this issue');
diff --git a/t/app/sendreport/email/tfl.t b/t/app/sendreport/email/tfl.t
new file mode 100644
index 000000000..0322de551
--- /dev/null
+++ b/t/app/sendreport/email/tfl.t
@@ -0,0 +1,32 @@
+use FixMyStreet::SendReport::Email::TfL;
+use FixMyStreet::TestMech;
+
+my $mech = FixMyStreet::TestMech->new;
+
+my $bromley = $mech->create_body_ok(2482, 'Bromley Council');
+my $tfl = $mech->create_body_ok(2482, 'TfL');
+
+$mech->create_contact_ok(email => 'council@example.com', body_id => $bromley->id, category => 'Graffiti');
+$mech->create_contact_ok(email => 'council@example.com', body_id => $bromley->id, category => 'Faulty street light');
+$mech->create_contact_ok(email => 'tfl@example.com', body_id => $tfl->id, category => 'Traffic lights');
+
+my $row = FixMyStreet::DB->resultset('Problem')->new( {
+ bodies_str => '1000',
+ category => 'Faulty street light',
+ cobrand => '',
+} );
+
+my $e = FixMyStreet::SendReport::Email::TfL->new;
+is $e->build_recipient_list($row), undef, 'no recipients if no body';
+
+$e = FixMyStreet::SendReport::Email::TfL->new;
+$e->add_body($bromley);
+is $e->build_recipient_list($row), undef, 'no recipients if category missing';
+
+$e = FixMyStreet::SendReport::Email::TfL->new;
+$e->add_body($tfl);
+is $e->build_recipient_list($row), 1, 'correct recipient list count';
+is_deeply $e->to, [ [ 'tfl@example.com', 'TfL' ] ], 'correct To line';
+
+done_testing();
+
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index b3fb3564b..d62a0ad0f 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -18,8 +18,16 @@ $contact->set_extra_fields(
{ code => 'service_request_id_ext', datatype => 'number', },
);
$contact->update;
+my $tfl = $mech->create_body_ok( 2482, 'TfL');
+$mech->create_contact_ok(
+ body_id => $tfl->id,
+ category => 'Traffic Lights',
+ email => 'tfl@example.org',
+);
my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
+ latitude => 51.402096,
+ longitude => 0.015784,
cobrand => 'bromley',
user => $user,
});
@@ -51,8 +59,8 @@ for my $test (
desc => 'testing special Open311 behaviour',
updates => {},
expected => {
- 'attribute[easting]' => 529025,
- 'attribute[northing]' => 179716,
+ 'attribute[easting]' => 540315,
+ 'attribute[northing]' => 168935,
'attribute[service_request_id_ext]' => $report->id,
'attribute[report_title]' => 'Test Test 1 for ' . $body->id,
'jurisdiction_id' => 'FMS',
@@ -66,8 +74,8 @@ for my $test (
postcode => ''
},
expected => {
- 'attribute[easting]' => 529025,
- 'attribute[northing]' => 179716,
+ 'attribute[easting]' => 540315,
+ 'attribute[northing]' => 168935,
'attribute[service_request_id_ext]' => $report->id,
'jurisdiction_id' => 'FMS',
'address_id' => '#NOTPINPOINTED#',
@@ -168,4 +176,22 @@ for my $test (
};
}
+subtest 'check display of TfL reports' => sub {
+ $mech->create_problems_for_body( 1, $tfl->id, 'TfL Test', {
+ latitude => 51.402096,
+ longitude => 0.015784,
+ cobrand => 'bromley',
+ user => $user,
+ });
+ $mech->get_ok( '/report/' . $report->id );
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => 'bromley',
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->follow_link_ok({ text_regex => qr/Back to all reports/i });
+ };
+ $mech->content_like(qr{<a title="TfL Test[^>]*www.example.org[^>]*><img[^>]*grey});
+ $mech->content_like(qr{<a title="Test Test[^>]*bromley.example.org[^>]*><img[^>]*yellow});
+};
+
done_testing();
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index b1fa8fcad..d710f6c81 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -34,7 +34,11 @@
[% IF problem.photo %]
<img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt="">
[% END %]
+ [% TRY %]
+ [% PROCESS 'report/_item_heading.html' %]
+ [% CATCH file %]
<h3 class="item-list__heading">[% problem.title | html %]</h3>
+ [% END %]
[% IF c.user.has_permission_to('report_inspect', problem.bodies_str_ids) %]
<div class="item-list__description">[% problem.detail | html %]</div>
[% END %]
diff --git a/templates/web/bromley/report/_item.html b/templates/web/bromley/report/_item.html
deleted file mode 100644
index 2540aec98..000000000
--- a/templates/web/bromley/report/_item.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<li class="item-list__item item-list--reports__item item-list__item--with-pin [% c.cobrand.pin_colour(problem) %]">
-<a class="[% problem.category %]" href="[% c.uri_for('/report', problem.id ) %]">
- [% IF problem.photo %]
- <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt="">
- [% END %]
- <span>[% problem.title | html %]</span><br />
- <small>[% prettify_dt( problem.confirmed, 1 ) %]
- [%- IF dist %], [% dist %]km[% END %]
- [%- IF include_lastupdate AND problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %],
- [% tprintf(loc('last updated %s'), prettify_dt( problem.lastupdate, 1 ) ) %]
- [%- END %]
- [% IF include_sentinfo %]
- [% IF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %]
- [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %]
- [% END %]
- [% END %]
- [% IF NOT no_fixed AND problem.is_fixed %]
- [% loc('(fixed)') %]
- [% ELSIF NOT no_fixed AND problem.is_closed %]
- [% loc('(closed)') %]
- [% END %]</small>
-</a>
-</li>
diff --git a/templates/web/bromley/report/_item_heading.html b/templates/web/bromley/report/_item_heading.html
new file mode 100644
index 000000000..e738075ad
--- /dev/null
+++ b/templates/web/bromley/report/_item_heading.html
@@ -0,0 +1 @@
+<span>[% problem.title | html %]</span><br />
diff --git a/templates/web/bromley/reports/_list-entry.html b/templates/web/bromley/reports/_list-entry.html
new file mode 100644
index 000000000..9ceaffc52
--- /dev/null
+++ b/templates/web/bromley/reports/_list-entry.html
@@ -0,0 +1,4 @@
+[% INCLUDE 'report/_item.html'
+ include_sentinfo = 1
+ item_extra_class = 'item-list__item--with-pin ' _ c.cobrand.pin_colour(problem)
+%]
diff --git a/templates/web/buckinghamshire/report/_item.html b/templates/web/buckinghamshire/report/_item.html
deleted file mode 100644
index b87363a6a..000000000
--- a/templates/web/buckinghamshire/report/_item.html
+++ /dev/null
@@ -1,139 +0,0 @@
-[% IF NOT report_blocks_included ~%]
-[% PROCESS 'admin/report_blocks.html' ~%]
-[% END ~%]
-
-[% IF c.user.has_permission_to('planned_reports', problem.bodies_str_ids) OR c.user.is_planned_report(problem) ~%]
- [% item_extra_class = "item-list__item--indented" ~%]
- [% item_action = BLOCK ~%]
- <input type="submit" value="1"
- data-label-remove="[% loc('Remove from shortlist') %]"
- data-label-add="[% loc('Add to shortlist') %]"
- [% IF c.user.is_planned_report(problem) ~%]
- name="shortlist-remove" title="[% loc('Remove from shortlist') %]" class="item-list__item__shortlist-remove"
- [%~ ELSE ~%]
- name="shortlist-add" title="[% IF problem.shortlisted_user %]
- [%~ tprintf(loc('Shortlisted by %s'), problem.shortlisted_user.name) %]; [% END %]
- [%~ loc('Add to shortlist') %]" class="item-list__item__shortlist-[% IF problem.shortlisted_user %]take[% ELSE %]add[% END %]"
- [%~ END ~%]
- >
- [%~ END %]
-[% END %]
-
-[% IF shortlist %]
- [% item_extra_class = "item-list__item--indented item-list__item--act-and-sort" %]
- [% item_action = BLOCK %]
- [% item_action %]
- <input type="submit" name="shortlist-up" value="[% loc('Up one') %]" title="[% loc('Up one') %]" class="item-list__item__shortlist-up" [% IF loop.first %]disabled[% END %]>
- <input type="submit" name="shortlist-down" value="[% loc('Down one') %]" title="[% loc('Down one') %]" class="item-list__item__shortlist-down" [% IF loop.last %]disabled[% END %]>
- [% END %]
-[% END %]
-
-<li class="item-list__item item-list--reports__item [% item_extra_class %]"
- data-report-id="[% problem.id | html %]" data-lastupdate="[% problem.lastupdate %]" id="report-[% problem.id | html %]">
-<a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %]">
- [% IF problem.photo %]
- <img class="img" height="60" width="90" src="[% problem.photos.first.url_fp %]" alt="">
- [% END %]
- <h3 class="item-list__heading">[% problem.category | html %]: [% problem.title | html %]</h3>
- [% IF c.user.has_permission_to('report_inspect', problem.bodies_str_ids) %]
- <div class="item-list__description">[% problem.detail | html %]</div>
- [% END %]
- <small>
- [% IF NOT no_fixed AND problem.is_fixed %]
- <span class="item-list__item__state">[% prettify_state('fixed') %]</span>
- [% ELSIF NOT no_fixed AND problem.is_closed %]
- <span class="item-list__item__state">[% prettify_state('closed') %]</span>
- [% ELSIF (c.user.has_permission_to('report_edit_priority', problem.bodies_str_ids) OR c.user.has_permission_to('report_inspect', problem.bodies_str_ids)) AND problem.response_priority %]
- <span class="item-list__item__state">[% problem.response_priority.name %]</span>
- [% END %]
- [%- IF c.cobrand.moniker != 'fixamingata' %] [%# Default: %]
- [%- IF problem.days_ago > 0 AND problem.days_ago <= c.cobrand.display_days_ago_threshold %]
- [% tprintf( nget('Reported %d day ago', 'Reported %d days ago', problem.days_ago), problem.days_ago ) %]
- [%- ELSE %]
- [% prettify_dt( problem.confirmed, 1 ) %]
- [%- END %]
- [%- ELSE %] [%# Swedish cobrand fixamingata: %]
- [%- prettify_dt( problem.confirmed) %]
- [%- END %]
- [%- IF dist %], [% dist %]km[% END %]
- [%- IF problem.confirmed != problem.lastupdate AND problem.whensent != problem.lastupdate %],
- [%- IF problem.days_ago('lastupdate') > 0 AND problem.days_ago('lastupdate') <= c.cobrand.display_days_ago_threshold %]
- [% tprintf( nget('last updated %d day ago', 'last updated %d days ago', problem.days_ago('lastupdate') ), problem.days_ago('lastupdate') ) %]
- [%- ELSE %]
- [% tprintf(loc('last updated %s'), prettify_dt( problem.lastupdate, 1 ) ) %]
- [%- END %]
- [%- END %]
- [% IF include_sentinfo %]
- [% IF c.cobrand.is_council && !c.cobrand.owns_problem( problem ) %]
- (sent to [% problem.body %])
- [% ELSIF problem.bodies_str_ids.size > 2 %] [% loc('(sent to all)') %]
- [% ELSIF problem.bodies_str_ids.size == 2 %] [% loc('(sent to both)') %]
- [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %]
- [% END %]
- [% END %]
- </small>
-
- [% IF c.user.has_permission_to('report_inspect', problem.bodies_str_ids) %]
- <div class="item-list__item__metadata">
- <div>
- <h4>[% loc('Report ID:') %]</h4>
- <p>[% problem.id %]</p>
- </div>
- [% IF problem.local_coords %]
- <div>
- <h4>[% loc('Easting/Northing:') %]</h4>
- <p>[% problem.local_coords.0 %], [% problem.local_coords.1 %]</p>
- </div>
- [% END %]
- <div>
- <h4>[% loc('Latitude/Longitude:') %]</h4>
- <p>[% problem.latitude %], [% problem.longitude %]</p>
- </div>
- <div>
- <h4>[% loc('Category') %]</h4>
- <p>[% (problem.category_display OR '-') | html %]</p>
- </div>
- <div>
- <h4>[% loc('State') %]</h4>
- <p>[% prettify_state(problem.state, 1) %]</p>
- </div>
- <div>
- <h4>[% loc('Priority') %]</h4>
- <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>
- [% SET fields = problem.get_extra_fields; IF fields.size %]
- [% FOR f IN fields %]
- <div>
- <h4>[% f.name %]</h4>
- <p>[% f.value %]</p>
- </div>
- [% END %]
- [% END %]
- </div>
- [% END %]
-
-
-</a>
-[% IF item_action ~%]
- [% IF page == 'report' ~%]
- [%# We don't want to output shortlist on report page (in duplicate list) %]
- [% ELSIF page == 'around' ~%]
- [%# The around page list is already contained within the new report form %]
- [% item_action.replace('("shortlist-[^"]*)', '$1-' _ problem.id) %]
- [% ELSE ~%]
- <form method="post" action="/my/planned/change">
- <input type="hidden" name="id" value="[% problem.id %]">
- <input type="hidden" name="token" value="[% csrf_token %]">
- [% item_action %]
- </form>
- [% END ~%]
-[% END %]
-</li>
diff --git a/templates/web/buckinghamshire/report/_item_heading.html b/templates/web/buckinghamshire/report/_item_heading.html
new file mode 100644
index 000000000..75c7bfdfb
--- /dev/null
+++ b/templates/web/buckinghamshire/report/_item_heading.html
@@ -0,0 +1 @@
+<h3 class="item-list__heading">[% problem.category | html %]: [% problem.title | html %]</h3>
diff --git a/web/cobrands/bromley/map.js b/web/cobrands/bromley/map.js
index e2e8e0073..5590b2627 100644
--- a/web/cobrands/bromley/map.js
+++ b/web/cobrands/bromley/map.js
@@ -79,30 +79,7 @@ fixmystreet.assets.add($.extend(true, {}, defaults, {
asset_category: ["Blocked drains", "Faulty street light", 'Faulty street sign', 'Floral displays', 'Grass needs cutting', 'Obstructions (skips, A boards)', 'Overhanging vegetation from private land', 'Pavement defect', 'Public Tree related issue', "Road defect"],
non_interactive: true,
road: true,
- actions: {
- found: function(layer) {
- if (fixmystreet.assets.selectedFeature()) {
- $('#road-warning').remove();
- return;
- }
- var msg = 'The location selected is a Transport for London Red Route. TfL are responsible for the reported category and can be alerted to issues via: <a href="https://tfl.gov.uk/help-and-contact/contact-us-about-streets-and-other-road-issues">Street issues</a>';
- if ( $('#road-warning').length ) {
- $('#road-warning').html(msg);
- } else {
- $('.change_location').after('<div class="box-warning" id="road-warning">' + msg + '</div>');
- }
- $('#single_body_only').val(layer.fixmystreet.body_found);
- },
-
- not_found: function(layer) {
- if ( $('#road-warning').length ) {
- $('#road-warning').remove();
- }
- $('#single_body_only').val(layer.fixmystreet.body_council);
- }
- },
- body_found: 'TfL',
- body_council: 'Bromley Council'
+ body: 'TfL'
}));
var prow_stylemap = new OpenLayers.StyleMap({
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index 5af8ef1cd..7e79776cd 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -85,7 +85,7 @@ OpenLayers.Layer.VectorNearest = OpenLayers.Class(OpenLayers.Layer.Vector, {
road_found: function() {
if (this.fixmystreet.actions) {
this.fixmystreet.actions.found(this, this.selected_feature);
- } else {
+ } else if (!fixmystreet.assets.selectedFeature()) {
$('#single_body_only').val(this.fixmystreet.body);
}
},
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index a849447ca..137fe5db7 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -395,8 +395,7 @@ $.extend(fixmystreet.set_up, {
$.getJSON('/report/new/category_extras', args, function(data) {
var $category_meta = $('#category_meta');
- $('#js-councils_text').html(data.councils_text);
- $('#js-councils_text_private').html(data.councils_text_private);
+ fixmystreet.update_councils_text(data);
if ( data.category_extra ) {
if ( $category_meta.length ) {
$category_meta.replaceWith( data.category_extra );
@@ -888,6 +887,17 @@ $.extend(fixmystreet.set_up, {
});
+fixmystreet.update_councils_text = function(data) {
+ var single_body_only = $('#single_body_only').val();
+ if (single_body_only) {
+ data.councils_text = data.councils_text.replace(/<strong>.*<\/strong>/, '<strong>' + single_body_only + '</strong>');
+ }
+
+ $('#js-councils_text').html(data.councils_text);
+ $('#js-councils_text_private').html(data.councils_text_private);
+
+};
+
// The new location will be saved to a history state unless
// savePushState is set to false.
fixmystreet.update_pin = function(lonlat, savePushState) {
@@ -917,8 +927,7 @@ fixmystreet.update_pin = function(lonlat, savePushState) {
}
$('#side-form, #site-logo').show();
var old_category = $("select#form_category").val();
- $('#js-councils_text').html(data.councils_text);
- $('#js-councils_text_private').html(data.councils_text_private);
+ fixmystreet.update_councils_text(data);
$('#js-top-message').html(data.top_message || '');
$('#form_category_row').html(data.category);
if ($("select#form_category option[value=\""+old_category+"\"]").length) {