diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-12-13 17:55:59 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-12-13 17:55:59 +0000 |
commit | 188221d35b59624ce686c97f650b114feb586709 (patch) | |
tree | 041facaa54a8d117c0d82a8a68d176ce11799945 /perllib/FixMyStreet/App/Controller/Report/New.pm | |
parent | 5a6d30ba74e70412593398b43e4c5e5c938c1d4c (diff) | |
parent | 5b49ba7aa2ba707bd7d157db6ef0bcfc6c00cf78 (diff) |
Merge branch 'yodenuncio'
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 951f6f2be..ca4fa2fd2 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -257,6 +257,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { }; my $category_extra = ''; + my $category_extra_json = []; my $generate; if ( $c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1 ) { $c->stash->{category_extras} = { $category => $c->stash->{category_extras}->{$category} }; @@ -270,6 +271,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { } if ($generate) { $category_extra = $c->render_fragment('report/new/category_extras.html', $vars); + $category_extra_json = $c->forward('generate_category_extra_json'); } my $councils_text = $c->render_fragment( 'report/new/councils_text.html', $vars); @@ -279,6 +281,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { category_extra => $category_extra, councils_text => $councils_text, councils_text_private => $councils_text_private, + category_extra_json => $category_extra_json, }); $c->res->content_type('application/json; charset=utf-8'); @@ -1457,6 +1460,24 @@ sub redirect_to_around : Private { return $c->res->redirect($around_uri); } +sub generate_category_extra_json : Private { + my ( $self, $c ) = @_; + + my $true = JSON->true; + my $false = JSON->false; + + my @fields = map { + { + %$_, + required => $_->{required} eq "true" ? $true : $false, + variable => $_->{variable} eq "true" ? $true : $false, + order => int($_->{order}), + } + } @{ $c->stash->{category_extras}->{$c->stash->{category}} }; + + return \@fields; +} + __PACKAGE__->meta->make_immutable; 1; |