diff options
author | Matthew Somerville <matthew@mysociety.org> | 2011-08-17 13:21:14 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2011-08-17 13:21:14 +0100 |
commit | 7343c7729bfcab1bd81e832f182b76e475546bc8 (patch) | |
tree | f2e42cd6cef05e7170df451ad41b881f1cf3e250 /perllib/FixMyStreet/App/Controller | |
parent | ecc2f777c9f00425eccf0816042ece1e455d7c70 (diff) |
When on around page with JS, have click on map show hidden form and fetch category/council.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 176f2fb3b..ffbb5a161 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -98,6 +98,33 @@ sub report_new : Path : Args(0) { $c->forward('redirect_or_confirm_creation'); } +sub report_form_ajax : Path('ajax') : Args(0) { + my ( $self, $c ) = @_; + + $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'); + + $c->forward('setup_categories_and_councils'); + + # render templates to get the html + my $category = $c->view('Web')->render( $c, 'report/new/category.html'); + my $councils_text = $c->view('Web')->render( $c, 'report/new/councils_text.html'); + + my $body = JSON->new->utf8(1)->encode( + { + councils_text => $councils_text, + category => $category, + } + ); + + $c->res->content_type('application/json; charset=utf-8'); + $c->res->body($body); +} + =head2 report_import Action to accept report creations from iPhones and other mobile apps. URL is |