diff options
24 files changed, 199 insertions, 117 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a500d688..28d37d847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Display user name/email for contributed as reports. #2990 - Interface for enabling anonymous reports for certain categories. #2989 - Better sort admin user table. + - Centralise update creation to include fields. - Development improvements: - `#geolocate_link` is now easier to re-style. #3006 - Links inside `#front-main` can be customised using `$primary_link_*` Sass variables. #3007 diff --git a/bin/fixmystreet.com/banes-close-reports b/bin/fixmystreet.com/banes-close-reports index bba4c88e0..79c1c44b9 100755 --- a/bin/fixmystreet.com/banes-close-reports +++ b/bin/fixmystreet.com/banes-close-reports @@ -50,7 +50,6 @@ my $q = FixMyStreet::DB->resultset("Problem")->search({ # Provide some variables to the archiving script FixMyStreet::Script::ArchiveOldEnquiries::update_options({ user => $body->comment_user->id, - user_name => $body->comment_user->name, closure_text => CLOSURE_TEXT, retain_alerts => 1, commit => $opts->commit, diff --git a/bin/fixmystreet.com/buckinghamshire-flytipping b/bin/fixmystreet.com/buckinghamshire-flytipping index a312f9fbe..65e87d30e 100755 --- a/bin/fixmystreet.com/buckinghamshire-flytipping +++ b/bin/fixmystreet.com/buckinghamshire-flytipping @@ -79,7 +79,6 @@ sub find_problems { # Provide some variables to the archiving script FixMyStreet::Script::ArchiveOldEnquiries::update_options({ user => $body->comment_user->id, - user_name => $body->comment_user->name, closure_text => $template->text, retain_alerts => $retain_alerts, commit => $opts->commit, diff --git a/bin/one-off-update-staff b/bin/one-off-update-staff new file mode 100755 index 000000000..d94d6b961 --- /dev/null +++ b/bin/one-off-update-staff @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +BEGIN { + use File::Basename qw(dirname); + use File::Spec; + my $d = dirname(File::Spec->rel2abs($0)); + require "$d/../setenv.pl"; +} + +use FixMyStreet::DB; + +my $rs = FixMyStreet::DB->resultset("Comment")->search({ + 'user.from_body' => { '!=', undef }, + 'user.is_superuser' => 0, + 'me.extra' => [ undef, { -not_like => '%is_body_user%' } ], +}, { + "+columns" => ["user.from_body"], + join => 'user', +}); +while (my $row = $rs->next) { + my $id = $row->user->{_column_data}->{from_body}; # Avoid DB lookups + $row->set_extra_metadata( is_body_user => $id ); + $row->update; +} + +$rs = FixMyStreet::DB->resultset("Comment")->search({ + 'user.is_superuser' => 1, + 'me.extra' => [ undef, { -not_like => '%is_superuser%' } ], +}, { + join => 'user', +}); +while (my $row = $rs->next) { + $row->set_extra_metadata( is_superuser => 1 ); + $row->update; +} diff --git a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm index 4866a657e..48386cf3e 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Reports.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Reports.pm @@ -368,24 +368,10 @@ sub edit : Path('/admin/report_edit') : Args(1) { if ( $problem->state ne $old_state ) { $c->forward( '/admin/log_edit', [ $id, 'problem', 'state_change' ] ); - my $name = $c->user->moderating_user_name; - my $extra = { is_superuser => 1 }; - if ($c->user->from_body) { - delete $extra->{is_superuser}; - $extra->{is_body_user} = $c->user->from_body->id; - } - my $timestamp = \'current_timestamp'; $problem->add_to_comments( { text => $c->stash->{update_text} || '', - created => $timestamp, - confirmed => $timestamp, - user_id => $c->user->id, - name => $name, - mark_fixed => 0, - anonymous => 0, - state => 'confirmed', + user => $c->user->obj, problem_state => $problem->state, - extra => $extra } ); } $c->forward( '/admin/log_edit', [ $id, 'problem', 'edit' ] ); @@ -444,13 +430,7 @@ sub edit_category : Private { } else { $problem->add_to_comments({ text => $update_text, - created => \'current_timestamp', - confirmed => \'current_timestamp', - user_id => $c->user->id, - name => $c->user->from_body ? $c->user->from_body->name : $c->user->name, - state => 'confirmed', - mark_fixed => 0, - anonymous => 0, + user => $c->user->obj, }); } $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'category_change' ] ); diff --git a/perllib/FixMyStreet/App/Controller/Admin/Triage.pm b/perllib/FixMyStreet/App/Controller/Admin/Triage.pm index 7cfcc93dd..c5bb6628d 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Triage.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Triage.pm @@ -117,27 +117,14 @@ sub update : Private { $c->stash->{problem}->update( { state => 'confirmed' } ); $c->forward( '/admin/log_edit', [ $problem->id, 'problem', 'triage' ] ); - my $name = $c->user->moderating_user_name; - my $extra = { is_superuser => 1 }; - if ($c->user->from_body) { - delete $extra->{is_superuser}; - $extra->{is_body_user} = $c->user->from_body->id; - } - + my $extra; $extra->{triage_report} = 1; $extra->{holding_category} = $current_category; $extra->{new_category} = $new_category; - my $timestamp = \'current_timestamp'; my $comment = $problem->add_to_comments( { text => "Report triaged from $current_category to $new_category", - created => $timestamp, - confirmed => $timestamp, - user_id => $c->user->id, - name => $name, - mark_fixed => 0, - anonymous => 0, - state => 'confirmed', + user => $c->user->obj, problem_state => $problem->state, extra => $extra, whensent => \'current_timestamp', diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm index f4143f0b4..c936f13c0 100644 --- a/perllib/FixMyStreet/App/Controller/Moderate.pm +++ b/perllib/FixMyStreet/App/Controller/Moderate.pm @@ -340,13 +340,8 @@ sub moderate_state : Private { $problem->state($new_state); $problem->add_to_comments( { text => $c->stash->{moderation_reason}, - created => \'current_timestamp', - confirmed => \'current_timestamp', - user_id => $c->user->id, - name => $c->user->from_body ? $c->user->from_body->name : $c->user->name, - state => 'confirmed', - mark_fixed => 0, - anonymous => $c->user->from_body ? 0 : 1, + user => $c->user->obj, + anonymous => $c->user->is_superuser || $c->user->from_body ? 0 : 1, problem_state => $new_state, } ); return 'state'; diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm index ab6117ae4..ef6152c30 100755 --- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm +++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm @@ -206,16 +206,12 @@ sub submit_standard : Private { $update = $c->model('DB::Comment')->new( { problem => $problem, - name => $problem->name, user => $problem->user, text => $update, - state => 'confirmed', mark_fixed => $c->stash->{new_state} eq 'fixed - user' ? 1 : 0, mark_open => $c->stash->{new_state} eq 'confirmed' ? 1 : 0, lang => $c->stash->{lang_code}, cobrand => $c->cobrand->moniker, - cobrand_data => '', - confirmed => \'current_timestamp', anonymous => $problem->anonymous, } ); diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 4f9825cae..dd7abc563 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -569,16 +569,11 @@ sub inspect : Private { epoch => $saved_at ); } - my $name = $c->user->from_body ? $c->user->from_body->name : $c->user->name; $problem->add_to_comments( { text => $update_text, created => $timestamp, confirmed => $timestamp, - user_id => $c->user->id, - name => $name, - state => 'confirmed', - mark_fixed => 0, - anonymous => 0, + user => $c->user->obj, %update_params, } ); } diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index 68e267d00..c876f3459 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -110,6 +110,41 @@ with 'FixMyStreet::Roles::Abuser', 'FixMyStreet::Roles::Moderation', 'FixMyStreet::Roles::PhotoSet'; +=head2 FOREIGNBUILDARGS + +Make sure that when creating a new Comment object, certain +other fields are set based upon the supplied data. + +=cut + +sub FOREIGNBUILDARGS { + my ($class, $opts) = @_; + + if (my $user = $opts->{user}) { + my $name; + if ($user->is_superuser) { + $opts->{extra}->{is_superuser} = 1; + $name = _('an administrator'); + } elsif (my $body = $user->from_body) { + $opts->{extra}->{is_body_user} = $body->id; + $name = $body->name; + $name = 'Island Roads' if $name eq 'Isle of Wight Council'; + } else { + $name = $user->name; + } + $opts->{name} //= $name; + } + + $opts->{anonymous} //= 0; + $opts->{mark_fixed} //= 0; + $opts->{state} //= 'confirmed'; # it's only public updates that need to be unconfirmed + if ($opts->{state} eq 'confirmed') { + $opts->{confirmed} //= \'current_timestamp'; + } + + return $opts; +}; + =head2 get_cobrand_logged Get a cobrand object for the cobrand the update was made on. diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm index 4463b4ed2..723dcd6dc 100644 --- a/perllib/FixMyStreet/Map/Bing.pm +++ b/perllib/FixMyStreet/Map/Bing.pm @@ -39,8 +39,8 @@ sub display_map { $self->SUPER::display_map($c, %params); } -my $road_base = '//t%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=G,L&src=t&shading=hill&og=969&n=z'; -my $aerial_base = '//t%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=A,G,L&src=t&og=969&n=z'; +my $road_base = '//%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=G,L&src=t&shading=hill&og=969&n=z'; +my $aerial_base = '//%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=A,G,L&src=t&og=969&n=z'; sub map_tiles { my ( $self, %params ) = @_; diff --git a/perllib/FixMyStreet/Map/FMS.pm b/perllib/FixMyStreet/Map/FMS.pm index 246d04bc0..1b556f6b3 100644 --- a/perllib/FixMyStreet/Map/FMS.pm +++ b/perllib/FixMyStreet/Map/FMS.pm @@ -24,7 +24,9 @@ sub map_tiles { my ( $self, %params ) = @_; my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} ); my $ni = in_northern_ireland_box( $params{latitude}, $params{longitude} ); - if (!$ni && $z >= 16) { + if ($params{aerial} || $ni || $z <= 11) { + return $self->SUPER::map_tiles(%params); + } elsif ($z >= 16) { my $tile_base = '//%stilma.mysociety.org/' . $self->map_tile_base . '/%d/%d/%d.png'; return [ sprintf($tile_base, 'a-', $z, $x-1, $y-1), @@ -32,7 +34,7 @@ sub map_tiles { sprintf($tile_base, 'c-', $z, $x-1, $y), sprintf($tile_base, '', $z, $x, $y), ]; - } elsif (!$ni && $z > 11) { + } elsif ($z > 11) { my $key = FixMyStreet->config('BING_MAPS_API_KEY'); my $base = "//ecn.%s.tiles.virtualearth.net/tiles/r%s?g=8702&lbl=l1&productSet=mmOS&key=$key"; return [ @@ -41,8 +43,6 @@ sub map_tiles { sprintf($base, "t2", $self->get_quadkey($x-1, $y, $z)), sprintf($base, "t3", $self->get_quadkey($x, $y, $z)), ]; - } else { - return $self->SUPER::map_tiles(%params); } } diff --git a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm index 7ba763515..7c183ecbc 100644 --- a/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm +++ b/perllib/FixMyStreet/Script/ArchiveOldEnquiries.pm @@ -141,7 +141,6 @@ sub close_problems { my $problems = shift; my $extra = { auto_closed_by_script => 1 }; - $extra->{is_superuser} = 1 if !$opts->{user_name}; my $cobrand; while (my $problem = $problems->next) { @@ -152,16 +151,9 @@ sub close_problems { $cobrand->set_lang_and_domain($problem->lang, 1); } - my $timestamp = \'current_timestamp'; my $comment = $problem->add_to_comments( { text => $opts->{closure_text} || '', - created => $timestamp, - confirmed => $timestamp, - user_id => $opts->{user}, - name => $opts->{user_name} || _('an administrator'), - mark_fixed => 0, - anonymous => 0, - state => 'confirmed', + user => FixMyStreet::DB->resultset("User")->find($opts->{user}), problem_state => $opts->{closed_state}, extra => $extra, } ); diff --git a/perllib/Open311/UpdatesBase.pm b/perllib/Open311/UpdatesBase.pm index 0be324773..c2f3fae0d 100644 --- a/perllib/Open311/UpdatesBase.pm +++ b/perllib/Open311/UpdatesBase.pm @@ -154,13 +154,8 @@ sub process_update { $request, $p, $state, $old_state, $external_status_code, $old_external_status_code ), - mark_fixed => 0, - mark_open => 0, - anonymous => 0, - name => $self->system_user->name, confirmed => $request->{comment_time}, created => $request->{comment_time}, - state => 'confirmed', } ); diff --git a/t/app/controller/admin/report_edit.t b/t/app/controller/admin/report_edit.t index f8101ab76..e041154db 100644 --- a/t/app/controller/admin/report_edit.t +++ b/t/app/controller/admin/report_edit.t @@ -329,7 +329,6 @@ foreach my $test ( closed_updates => undef, }, expect_comment => 1, - user_body => $oxfordshire, changes => { state => 'investigating' }, log_entries => [ qw/edit state_change edit edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/ @@ -351,7 +350,6 @@ foreach my $test ( }, expect_comment => 1, expected_text => '*Category changed from ‘Other’ to ‘Potholes’*', - user_body => $oxfordshire, changes => { state => 'in progress', category => 'Potholes' }, log_entries => [ qw/edit state_change category_change edit state_change edit edit resend edit state_change edit state_change edit state_change edit state_change edit state_change edit edit edit edit edit/ @@ -364,11 +362,6 @@ foreach my $test ( $report->comments->delete; $log_entries->reset; - if ( $test->{user_body} ) { - $superuser->from_body( $test->{user_body}->id ); - $superuser->update; - } - $mech->get_ok("/admin/report_edit/$report_id"); @{$test->{fields}}{'external_id', 'external_body', 'external_team', 'category'} = (13, "", "", "Other"); @@ -440,21 +433,12 @@ foreach my $test ( } else { is $comment->text, '', 'comment has no text'; } - if ( $test->{user_body} ) { - ok $comment->get_extra_metadata('is_body_user'), 'body user metadata set'; - ok !$comment->get_extra_metadata('is_superuser'), 'superuser metadata not set'; - is $comment->name, $test->{user_body}->name, 'comment name is body name'; - } else { - ok !$comment->get_extra_metadata('is_body_user'), 'body user metadata not set'; - ok $comment->get_extra_metadata('is_superuser'), 'superuser metadata set'; - is $comment->name, _('an administrator'), 'comment name is admin'; - } + ok !$comment->get_extra_metadata('is_body_user'), 'body user metadata not set'; + ok $comment->get_extra_metadata('is_superuser'), 'superuser metadata set'; + is $comment->name, _('an administrator'), 'comment name is admin'; } else { is $report->comments->count, 0, 'report has no comments'; } - - $superuser->from_body(undef); - $superuser->update; }; } diff --git a/t/app/controller/admin/update_edit.t b/t/app/controller/admin/update_edit.t index 57c8973d4..8650e7771 100644 --- a/t/app/controller/admin/update_edit.t +++ b/t/app/controller/admin/update_edit.t @@ -81,7 +81,7 @@ for my $test ( fields => { text => 'this is an update', state => 'confirmed', - name => '', + name => 'Test User', anonymous => 1, username => $update->user->email, }, @@ -96,7 +96,7 @@ for my $test ( fields => { text => 'this is a changed update', state => 'confirmed', - name => '', + name => 'Test User', anonymous => 1, username => $update->user->email, }, diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index e97b04f12..3198cf70c 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -1096,10 +1096,10 @@ subtest $test->{desc} => sub { unlike $update_meta->[1], qr/Commenter/, 'commenter name not included'; like $update_meta->[0], qr/investigating/i, 'update meta includes state change'; - if ($test->{body} || $test->{bodyuser}) { - like $update_meta->[1], qr/Westminster/, 'body user update uses body name'; - } elsif ($test->{superuser}) { + if ($test->{superuser}) { like $update_meta->[1], qr/an administrator/, 'superuser update says an administrator'; + } elsif ($test->{body} || $test->{bodyuser}) { + like $update_meta->[1], qr/Westminster/, 'body user update uses body name'; } ok $user->user_body_permissions->create({ diff --git a/t/app/model/comment.t b/t/app/model/comment.t index 3f30b3a1e..dd9af9eb9 100644 --- a/t/app/model/comment.t +++ b/t/app/model/comment.t @@ -1,20 +1,27 @@ use FixMyStreet::Test; -my $comment_rs = FixMyStreet::DB->resultset('Comment'); +my $user = FixMyStreet::DB->resultset('User')->new({ name => 'Test User', is_superuser => 1 }); +my $comment_rs = FixMyStreet::DB->resultset('Comment'); my $comment = $comment_rs->new( { - user_id => 1, + user => $user, problem_id => 1, text => '', - state => 'confirmed', - anonymous => 0, - mark_fixed => 0, - cobrand => 'default', - cobrand_data => '', } ); -is $comment->confirmed, undef, 'inflating null confirmed ok'; -is $comment->created, undef, 'inflating null confirmed ok'; +is $comment->created, undef, 'inflating null created ok'; +is $comment->mark_fixed, 0, 'mark fixed default set'; +is $comment->state, 'confirmed', 'state default is confirmed'; +is $comment->name, 'an administrator'; + +$user->is_superuser(0); +$comment = $comment_rs->new({ + user => $user, + problem_id => 1, + text => '', +}); +is $comment->name, 'Test User'; + done_testing(); diff --git a/t/map/bing.t b/t/map/bing.t new file mode 100644 index 000000000..ae8391871 --- /dev/null +++ b/t/map/bing.t @@ -0,0 +1,12 @@ +use Test::More; +use FixMyStreet::Map::Bing; + +my $tiles = FixMyStreet::Map::Bing->map_tiles(x_tile => 8105, y_tile => 5375, zoom_act => 14); +$tiles = [ map { m{ch/([^?]*)}; $1; } @$tiles ]; +is_deeply $tiles, [ '03131132323220', '03131132323221', '03131132323222', '03131132323223' ]; + +$tiles = FixMyStreet::Map::Bing->map_tiles(x_tile => 8105, y_tile => 5375, zoom_act => 14, aerial => 1); +$tiles = [ map { m{ch/([^?]*)\?.*A,G,L}; $1; } @$tiles ]; +is_deeply $tiles, [ '03131132323220', '03131132323221', '03131132323222', '03131132323223' ]; + +done_testing(); diff --git a/t/map/fms.t b/t/map/fms.t new file mode 100644 index 000000000..3a562db26 --- /dev/null +++ b/t/map/fms.t @@ -0,0 +1,55 @@ +use Test::More; +use FixMyStreet::Map::FMS; + +# Z NI Aerial +my $expected = { + 10 => { + 0 => { + 0 => 'ch/1010100100.*?=G,L', + 1 => 'ch/1010100100.*?A,G,L', + }, + 1 => { + 0 => 'ch/1010100100.*?=G,L', + 1 => 'ch/1010100100.*?A,G,L', + }, + }, + 13 => { + 0 => { + 0 => 'r3131010100100.*?mmOS', + 1 => 'ch/3131010100100.*?A,G,L', + }, + 1 => { + 0 => 'ch/3131010100100.*?=G,L', + 1 => 'ch/3131010100100.*?A,G,L', + }, + }, + 16 => { + 0 => { + 0 => 'oml/16/32420/21504', + 1 => 'ch/0313131010100100.*?A,G,L', + }, + 1 => { + 0 => 'ch/0313131010100100.*?=G,L', + 1 => 'ch/0313131010100100.*?A,G,L', + }, + }, +}; + +subtest "Correct tiles with various parameters" => sub { + for my $aerial (0, 1) { + for my $ni (0, 1) { + for my $zoom (qw(10 13 16)) { + my $tiles = FixMyStreet::Map::FMS->map_tiles( + x_tile => 32421, y_tile => 21505, zoom_act => $zoom, + aerial => $aerial, + latitude => $ni ? 55 : 51, + longitude => $ni ? -6 : -2, + ); + my $wanted = $expected->{$zoom}{$ni}{$aerial}; + like $tiles->[0], qr/$wanted/, "with zoom $zoom, NI $ni, aerial $aerial"; + } + } + } +}; + +done_testing(); diff --git a/t/open311.t b/t/open311.t index 9524006b8..941e35f7e 100644 --- a/t/open311.t +++ b/t/open311.t @@ -402,6 +402,7 @@ subtest 'Hounslow update description is correct for a different user' => sub { my $comment = make_comment('hounslow'); $comment->user($user2); + $comment->name($user2->name); my $results; FixMyStreet::override_config { ALLOWED_COBRANDS => 'hounslow', diff --git a/templates/web/base/js/translation_strings.html b/templates/web/base/js/translation_strings.html index 2eb652c1f..4c4902fc5 100644 --- a/templates/web/base/js/translation_strings.html +++ b/templates/web/base/js/translation_strings.html @@ -64,6 +64,8 @@ fixmystreet.password_minimum_length = [% c.cobrand.password_minimum_length %]; map_map: '[% loc('Map', "JS") %]', map_satellite: '[% loc('Satellite', "JS") %]', + map_aerial: '[% loc('Aerial', "JS") %]', + map_roads: '[% loc('Roads', "JS") %]', expand_map: '[% loc('Expand map', "JS") %]', collapse_map: '[% loc('Collapse map', "JS") %]', diff --git a/templates/web/highwaysengland/report/new/inline-tips.html b/templates/web/highwaysengland/report/new/inline-tips.html index ff0ef42f8..730b482e5 100644 --- a/templates/web/highwaysengland/report/new/inline-tips.html +++ b/templates/web/highwaysengland/report/new/inline-tips.html @@ -1,3 +1,9 @@ +<div class="description_tips" > + <p> + Content of reports shall be monitored and any language that could be deemed to cause offense or be inappropriate shall be removed. + </p> +</div> + <label for="where_hear">How did you hear about us?</label> [%~ SET where_hear = report.get_extra_metadata('where_hear') %] @@ -8,6 +14,6 @@ <option value="Highways England website"[% ' selected' IF 'Highways England website' == where_hear %]>Highways England website</option> <option value="Twitter"[% ' selected' IF 'Twitter' == where_hear %]>Twitter</option> <option value="Word of mouth"[% ' selected' IF 'Word of mouth' == where_hear %]>Word of mouth</option> -<option value="Through the post"[% ' selected' IF 'Through the post' == where_hear %]>Through the post</option> +<option value="Highways England correspondence"[% ' selected' IF 'Highways England correspondence' == where_hear %]>Highways England correspondence</option> <option value="Other"[% ' selected' IF 'Other' == where_hear %]>Other</option> </select> diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index bbaf22940..b0e5dfc6a 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -14,15 +14,18 @@ fixmystreet.maps.config = function() { (function() { $(function(){ - $('#map_layer_toggle').toggle(function(){ - $(this).text('Roads'); - fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]); - }, function(){ - $(this).text('Aerial'); - fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]); + $('#map_layer_toggle').click(function(e) { + e.preventDefault(); + var $this = $(this); + if ($this.text() == translation_strings.map_aerial) { + $this.text(translation_strings.map_roads); + fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]); + } else { + $this.text(translation_strings.map_aerial); + fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]); + } }); }); - })(); OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, { |