aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2017-08-14 12:32:34 +0100
committerDave Arter <davea@mysociety.org>2017-08-14 12:32:34 +0100
commit931e388fd8ed8d968e62155457c098c4a4dfe933 (patch)
tree35ec748b62b3d1fd291a0a145896b97382120b26
parent8e320beadae7cbc65967fc851f2448bbb1c7b2e0 (diff)
[Zurich] Fix map on /reports
A seemingly unrelated change in ef6ffbdb was causing JS errors on the /reports page which meant the map loading spinner was permanently present. This commit fixes that, and also fixes another bug which was uncovered where the ?ajax=1 param was being ignored by the Zürich /reports page, leading to HTML being returned and another JS error. The call to `new OpenLayers.Bounds` in OpenLayers.Strategy.FixMyStreet.getMapBounds was causing three of the 4 bounds params to be lost when run on OpenLayers 2.11, as this version doesn’t accept an array to the Bounds constructor. This in turn was using an invalid `bbox` parameter (only the west value was present) in the AJAX call to /reports which returned a 500 error. This then crashed the JS and caused the loading spinner to get stuck.
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm5
-rw-r--r--web/js/map-OpenLayers.js5
2 files changed, 9 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 33a1ac5b9..255ff4b28 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -36,6 +36,11 @@ sub index : Path : Args(0) {
if ( $c->cobrand->moniker eq 'zurich' ) {
$c->forward( 'stash_report_filter_status' );
$c->forward( 'load_and_group_problems' );
+
+ if ($c->get_param('ajax')) {
+ $c->detach('ajax', [ 'reports/_problem-list.html' ]);
+ }
+
my $pins = $c->stash->{pins};
$c->stash->{page} = 'reports';
FixMyStreet::Map::display_map(
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 97507ea4a..e7702e764 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -772,7 +772,10 @@ OpenLayers.Strategy.FixMyStreet = OpenLayers.Class(OpenLayers.Strategy.BBOX, {
getMapBounds: function() {
var bounds = OpenLayers.Strategy.BBOX.prototype.getMapBounds.apply(this);
if (bounds) {
- bounds = new OpenLayers.Bounds(bounds.toArray());
+ // OpenLayers 2.11 (as used by Zürich) doesn't allow Bounds to be
+ // created by passing an array to the constructor, so we have to use
+ // this convenience method instead.
+ bounds = OpenLayers.Bounds.fromArray(bounds.toArray());
}
return bounds;
},