diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-03-16 13:38:53 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-03-16 13:38:53 +0000 |
commit | 257d609b986b5f70282c68b75858cc5f2323a400 (patch) | |
tree | 3bc172aa1e96b9c0902dbc45accd13f731d5db51 | |
parent | ce6daecdf96955aab2f1d528d3fdc2f56213f400 (diff) |
Return an error if map clicked outside boundary, fixes #270.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 11 | ||||
-rw-r--r-- | templates/web/default/report/new/fill_in_details_form.html | 2 | ||||
-rw-r--r-- | web/js/map-OpenLayers.js | 5 |
3 files changed, 14 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 8d249b899..af4cdd5aa 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -109,9 +109,14 @@ sub report_form_ajax : Path('ajax') : Args(0) { $c->forward('initialize_report'); # work out the location for this report and do some checks - # XXX We don't want to do this here if this actually happens! - return $c->forward('redirect_to_around') - unless $c->forward('determine_location'); + if ( ! $c->forward('determine_location') ) { + my $body = JSON->new->utf8(1)->encode( { + error => $c->stash->{location_error}, + } ); + $c->res->content_type('application/json; charset=utf-8'); + $c->res->body($body); + return; + } $c->forward('setup_categories_and_councils'); diff --git a/templates/web/default/report/new/fill_in_details_form.html b/templates/web/default/report/new/fill_in_details_form.html index ed8b07ea1..2a74a44db 100644 --- a/templates/web/default/report/new/fill_in_details_form.html +++ b/templates/web/default/report/new/fill_in_details_form.html @@ -4,7 +4,7 @@ [% IF partial_token %] <p id="unknown">[% loc('Please note your report has <strong>not yet been sent</strong>. Choose a category and add further information below, then submit.') %]</p> [% END %] -<p>[% loc('You have located the problem at the point marked with a purple pin on the map. If this is not the correct location, simply click on the map again. ') %]</p> +<p>[% loc('You have located the problem at the point marked with a green pin on the map. If this is not the correct location, simply click on the map again. ') %]</p> [% END %] [% IF js %] diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 7522ae7d6..272fd6c12 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -433,6 +433,11 @@ OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { latitude: $('#fixmystreet\\.latitude').val(), longitude: $('#fixmystreet\\.longitude').val() }, function(data) { + if (data.error) { + // XXX If they then click back and click somewhere in the area, this error will still show. + $('#side-form').html('<h1>Reporting a problem</h1><p>' + data.error + '</p>'); + return; + } $('#councils_text').html(data.councils_text); $('#form_category_row').html(data.category); }); |