diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 239fa7a1a..551e9b719 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -119,7 +119,36 @@ sub report_form_ajax : Path('ajax') : Args(0) { { councils_text => $councils_text, category => $category, - category_extras => $c->stash->{category_extras_json}, + } + ); + + $c->res->content_type('application/json; charset=utf-8'); + $c->res->body($body); +} + +sub category_extras_ajax : Path('category_extras') : Args(0) { + my ( $self, $c ) = @_; + + my $contacts + = $c + ->model('DB::Contact') + ->not_deleted + ->search( { area_id => $c->req->param('area_id'), category => $c->req->param('category') } ); + + my $category_extra = ''; + if ( my $contact = $contacts->first ) { + if ( $contact->extra ) { + $c->stash->{report_meta} = {}; + $c->stash->{report} = { category => $c->req->param('category') }; + $c->stash->{category_extras} = { $c->req->param('category' ) => $contact->extra }; + + $category_extra= $c->view('Web')->render( $c, 'report/new/category_extras.html'); + } + } + + my $body = JSON->new->utf8(1)->encode( + { + category_extra => $category_extra, } ); |