diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 26 |
1 files changed, 26 insertions, 0 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 |