diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 20 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Bing.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/OSM.pm | 4 | ||||
-rw-r--r-- | t/app/controller/report_updates.t | 1 | ||||
-rw-r--r-- | templates/web/base/maps/_sub_links.html | 6 | ||||
-rw-r--r-- | templates/web/base/maps/bing.html | 9 | ||||
-rw-r--r-- | templates/web/base/maps/fms.html | 2 | ||||
-rw-r--r-- | templates/web/base/maps/google-ol.html | 2 | ||||
-rw-r--r-- | templates/web/base/maps/openlayers.html | 6 | ||||
-rw-r--r-- | templates/web/base/maps/osm.html | 8 | ||||
-rw-r--r-- | templates/web/tfl/front/pre-steps.html | 12 | ||||
-rw-r--r-- | templates/web/zurich/maps/zurich.html | 5 | ||||
-rw-r--r-- | web/js/map-OpenStreetMap.js | 7 | ||||
-rw-r--r-- | web/js/map-bing-ol.js | 4 |
15 files changed, 53 insertions, 45 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d7be16b11..df449a480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - Add lazy image loading on list items. - Improve Bing geocoder results. - Add option of checking passwords against Have I Been Pwned. - - Add aerial maps option to Bing maps. + - Add aerial maps option to Bing and OSM maps. - Select matches for both filter category and group. #3110 - Changes: - Mark user as active when sent an email alert. diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index c876f3459..2ef8925e6 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -145,6 +145,26 @@ sub FOREIGNBUILDARGS { return $opts; }; +=head2 around user + +Also make sure we catch the setting of a user on an object at a time other than +object creation, to set the extra field needed. + +=cut + +around user => sub { + my ( $orig, $self ) = ( shift, shift ); + my $res = $self->$orig(@_); + if (@_) { + if ($_[0]->is_superuser) { + $self->set_extra_metadata( is_superuser => 1 ); + } elsif (my $body = $_[0]->from_body) { + $self->set_extra_metadata( is_body_user => $body->id ); + } + } + return $res; +}; + =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 723dcd6dc..17bdc3a53 100644 --- a/perllib/FixMyStreet/Map/Bing.pm +++ b/perllib/FixMyStreet/Map/Bing.pm @@ -8,8 +8,6 @@ use strict; sub map_type { '' } -sub map_template { 'bing' } - sub map_javascript { [ '/vendor/OpenLayers/OpenLayers.fixmystreet.js', '/js/map-OpenLayers.js', @@ -31,14 +29,6 @@ sub get_quadkey { return $key; } -sub display_map { - my ($self, $c, %params) = @_; - - $params{aerial} = $c->get_param("aerial") ? 1 : 0; - - $self->SUPER::display_map($c, %params); -} - 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'; diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm index 417fdca0b..47c1c8535 100644 --- a/perllib/FixMyStreet/Map/OSM.pm +++ b/perllib/FixMyStreet/Map/OSM.pm @@ -21,11 +21,13 @@ sub map_template { 'osm' } sub map_javascript { [ '/vendor/OpenLayers/OpenLayers.wfs.js', '/js/map-OpenLayers.js', + FixMyStreet->config('BING_MAPS_API_KEY') ? ('/js/map-bing-ol.js') : (), '/js/map-OpenStreetMap.js', ] } sub map_tiles { my ( $self, %params ) = @_; + return FixMyStreet::Map::Bing->map_tiles(%params) if $params{aerial}; my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} ); my $tile_url = $self->base_tile_url(); return [ @@ -59,6 +61,8 @@ sub display_map { if defined $c->get_param('lon'); $params{zoomToBounds} = $params{any_zoom} && !defined $c->get_param('zoom'); + $params{aerial} = $c->get_param("aerial") && FixMyStreet->config('BING_MAPS_API_KEY') ? 1 : 0; + my %data; $data{cobrand} = $c->cobrand; $data{distance} = $c->stash->{distance}; diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index 3198cf70c..0b60ac02b 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -907,6 +907,7 @@ subtest "check comment with no status change has not status in meta" => sub { is $report->state, 'investigating', 'correct report state'; is $update->problem_state, 'investigating', 'correct update state'; + is $update->get_extra_metadata('is_body_user'), $body->id, 'correct metadata'; $update_meta = $mech->extract_update_metas; like $update_meta->[0], qr/fixed/i, 'first update meta says fixed'; unlike $update_meta->[2], qr/State changed to/, 'second update meta does not include state change'; diff --git a/templates/web/base/maps/_sub_links.html b/templates/web/base/maps/_sub_links.html deleted file mode 100644 index d58ecf97c..000000000 --- a/templates/web/base/maps/_sub_links.html +++ /dev/null @@ -1,6 +0,0 @@ -[% INCLUDE maps/openlayers.html %] -[% UNLESS around_page %] -<p class="sub-map-links" id="sub_map_links"> - [% map_sub_links | safe %] -</p> -[% END %] diff --git a/templates/web/base/maps/bing.html b/templates/web/base/maps/bing.html deleted file mode 100644 index 7d2c379c4..000000000 --- a/templates/web/base/maps/bing.html +++ /dev/null @@ -1,9 +0,0 @@ -[% map_sub_links = BLOCK %] - [% IF c.req.params.aerial %] - <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 0 } ) %]">[% loc('Roads') %]</a> - [% ELSE %] - <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 1 } ) %]">[% loc('Aerial') %]</a> - [% END %] -[% END %] - -[% map_html = INCLUDE maps/_sub_links.html %] diff --git a/templates/web/base/maps/fms.html b/templates/web/base/maps/fms.html index 739c00b4e..2df3bd11b 100644 --- a/templates/web/base/maps/fms.html +++ b/templates/web/base/maps/fms.html @@ -6,4 +6,4 @@ [% END %] [% END %] -[% map_html = INCLUDE maps/_sub_links.html include_key = 1 %] +[% map_html = INCLUDE maps/openlayers.html include_key = 1 %] diff --git a/templates/web/base/maps/google-ol.html b/templates/web/base/maps/google-ol.html index eb68ae804..9103ba42b 100644 --- a/templates/web/base/maps/google-ol.html +++ b/templates/web/base/maps/google-ol.html @@ -2,4 +2,4 @@ <a class="hidden-nojs" id="map_layer_toggle" href="">[% loc('Satellite') %]</a> [% END %] -[% map_html = INCLUDE maps/_sub_links.html %] +[% map_html = INCLUDE maps/openlayers.html %] diff --git a/templates/web/base/maps/openlayers.html b/templates/web/base/maps/openlayers.html index f4c78767c..60d7acfde 100644 --- a/templates/web/base/maps/openlayers.html +++ b/templates/web/base/maps/openlayers.html @@ -46,3 +46,9 @@ <div class="olControlAttribution" style="position: absolute;">[% map.copyright | safe %]</div> [% END %] <img id="loading-indicator" class="hidden" aria-hidden="true" src="/i/loading.svg" alt="Loading..."> + +[% IF NOT around_page AND map_sub_links %] +<p class="sub-map-links" id="sub_map_links"> + [% map_sub_links | safe %] +</p> +[% END %] diff --git a/templates/web/base/maps/osm.html b/templates/web/base/maps/osm.html index 70d05929f..560055f3b 100644 --- a/templates/web/base/maps/osm.html +++ b/templates/web/base/maps/osm.html @@ -1,3 +1,11 @@ +[% map_sub_links = BLOCK %][% IF c.config.BING_MAPS_API_KEY %] + [% IF c.req.params.aerial %] + <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 0 } ) %]">[% loc('Roads') %]</a> + [% ELSE %] + <a id="map_layer_toggle" href="[% c.uri_with( { aerial => 1 } ) %]">[% loc('Aerial') %]</a> + [% END %] +[% END %][% END %] + [% map.copyright = ''; # This is handled with OpenLayers.Control.Attribution map_html = INCLUDE maps/openlayers.html diff --git a/templates/web/tfl/front/pre-steps.html b/templates/web/tfl/front/pre-steps.html deleted file mode 100644 index 1dead5c89..000000000 --- a/templates/web/tfl/front/pre-steps.html +++ /dev/null @@ -1,12 +0,0 @@ -<p style="max-width: 38em; font-size: 1.2em; margin-bottom: 2.5em;"> - <strong> - All issues reported on Streetcare continue to be monitored by our teams at - Transport for London. We are not able to carry out all of our normal - maintenance works at the moment but we are working hard to deal with all - safety critical issues. - </strong> - <br> - If you are concerned about pavement overcrowding during social distancing - on the Transport for London Road Network, you can now report that to us - here. -</p> diff --git a/templates/web/zurich/maps/zurich.html b/templates/web/zurich/maps/zurich.html index f3a9bdc7f..8310b0758 100644 --- a/templates/web/zurich/maps/zurich.html +++ b/templates/web/zurich/maps/zurich.html @@ -5,9 +5,4 @@ [% map_html = BLOCK %] [% INCLUDE maps/openlayers.html %] [% INCLUDE maps/wmts_config.html %] -[% UNLESS around_page %] -<p class="sub-map-links" id="sub_map_links"> - [% map_sub_links | safe %] -</p> -[% END %] [% END %] diff --git a/web/js/map-OpenStreetMap.js b/web/js/map-OpenStreetMap.js index 9ed3a2ee3..bd3497343 100644 --- a/web/js/map-OpenStreetMap.js +++ b/web/js/map-OpenStreetMap.js @@ -7,6 +7,13 @@ fixmystreet.maps.config = function() { new OpenLayers.Control.PermalinkFMS('map'), new OpenLayers.Control.PanZoomFMS({id: 'fms_pan_zoom' }) ]; + + if (OpenLayers.Layer.BingAerial) { + fixmystreet.layer_options = [ + { map_type: fixmystreet.map_type }, + { map_type: OpenLayers.Layer.BingAerial } + ]; + } }; // http://www.openstreetmap.org/openlayers/OpenStreetMap.js (added maxResolution) diff --git a/web/js/map-bing-ol.js b/web/js/map-bing-ol.js index b0e5dfc6a..179238633 100644 --- a/web/js/map-bing-ol.js +++ b/web/js/map-bing-ol.js @@ -25,6 +25,10 @@ fixmystreet.maps.config = function() { fixmystreet.map.setBaseLayer(fixmystreet.map.layers[0]); } }); + // If page loaded with Aerial as starting, rather than default road + if ($('#map_layer_toggle').text() == translation_strings.map_roads) { + fixmystreet.map.setBaseLayer(fixmystreet.map.layers[1]); + } }); })(); |