aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-11-16 11:35:53 +0000
committerDave Arter <davea@mysociety.org>2016-12-13 16:14:55 +0000
commitca578e7c4150fab167f1a4ab422e23d0b1f09789 (patch)
treea098a2a173d41222cc82e05089e5772afcd6c9fa
parent96bddb2ebda556eff5a79bbd31b936fbf6f1ef6b (diff)
Use nearby problems for duplicate suggestions instead of bounding box of map
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm26
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js4
2 files changed, 28 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index cd42e89a4..f9eaf583c 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -300,6 +300,7 @@ sub action_router : Path('') : Args(2) {
my ( $self, $c, $id, $action ) = @_;
$c->go( 'map', [ $id ] ) if $action eq 'map';
+ $c->go( 'nearby_json', [ $id ] ) if $action eq 'nearby.json';
$c->detach( '/page_error_404_not_found', [] );
}
@@ -420,6 +421,31 @@ sub map : Private {
}
+sub nearby_json : Private {
+ my ( $self, $c, $id ) = @_;
+
+ $c->forward( 'load_problem_or_display_error', [ $id ] );
+ my $p = $c->stash->{problem};
+ my $dist = 1000;
+
+ my $nearby = $c->model('DB::Nearby')->nearby(
+ $c, $dist, [ $p->id ], 5, $p->latitude, $p->longitude, undef, [ $p->category ], undef
+ );
+ # my @reports = map { $_->problem : $_; } @$nearby;
+
+ my $on_map_list_html = $c->render_fragment(
+ 'around/on_map_list_items.html',
+ { on_map => [], around_map => $nearby }
+ );
+
+ my $json = {};
+ $json->{current} = $on_map_list_html if $on_map_list_html;
+ my $body = encode_json($json);
+ $c->res->content_type('application/json; charset=utf-8');
+ $c->res->body($body);
+}
+
+
=head2 check_has_permission_to
Ensure the currently logged-in user has any of the provided permissions applied
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index ac7ddacaf..1fc17ac9b 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -414,8 +414,8 @@ $.extend(fixmystreet.set_up, {
args.latitude = $('input[name="latitude"]').val();
args.longitude = $('input[name="longitude"]').val();
- $.getJSON('/ajax', args, function(data) {
- var report_id = $("#report_inspect_form [name=report_id]").val();
+ var report_id = $("#report_inspect_form [name=report_id]").val();
+ $.getJSON('/report/'+report_id+'/nearby', args, function(data) {
var duplicate_of = $("#report_inspect_form [name=duplicate_of]").val();
var $reports = $(data.current)
.filter("li")