diff options
author | Struan Donald <struan@exo.org.uk> | 2011-10-20 18:53:32 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2011-10-20 18:53:32 +0100 |
commit | 64cc9b22581f24acffbdae19ef6f06b96334135f (patch) | |
tree | 8a7e80a48a0dd6a9b2ecfd8d1b3f3b53f25ba81c /perllib/FixMyStreet/App/Controller | |
parent | 284b74472e30db0f1b1e82a4538f4bebfc0b67a5 (diff) |
remove javascript eval and send down html instead
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, } ); |