aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm14
2 files changed, 18 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index a2d7ed025..db2eceda3 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -9,6 +9,7 @@ use Encode;
use JSON::MaybeXS;
use Utils;
use Try::Tiny;
+use Text::CSV;
=head1 NAME
@@ -230,6 +231,10 @@ sub check_and_stash_category : Private {
my $all_areas = $c->stash->{all_areas};
my @bodies = $c->model('DB::Body')->active->for_areas(keys %$all_areas)->all;
my %bodies = map { $_->id => $_ } @bodies;
+ my @list_of_names = map { $_->name } values %bodies;
+ my $csv = Text::CSV->new();
+ $csv->combine(@list_of_names);
+ $c->{stash}->{list_of_names_as_string} = $csv->string;
my @categories = $c->model('DB::Contact')->not_deleted->search(
{
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 9172de5b6..5d24bc980 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -208,6 +208,7 @@ sub report_form_ajax : Path('ajax') : Args(0) {
my $extra_titles_list = $c->cobrand->title_list($c->stash->{all_areas});
+ my @list_of_names = map { $_->name } values %{$c->stash->{bodies}};
my $contribute_as = {};
if ($c->user_exists) {
my @bodies = keys %{$c->stash->{bodies}};
@@ -221,6 +222,7 @@ sub report_form_ajax : Path('ajax') : Args(0) {
my $body = encode_json(
{
+ bodies => \@list_of_names,
councils_text => $councils_text,
councils_text_private => $councils_text_private,
category => $category,
@@ -254,8 +256,10 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
$category = '' if $category eq _('-- Pick a category --');
my $bodies = $c->forward('contacts_to_bodies', [ $category ]);
+
+ my $list_of_names = [ map { $_->name } ($category ? @$bodies : values %{$c->stash->{bodies_to_list}}) ];
my $vars = {
- $category ? (list_of_names => [ map { $_->name } @$bodies ]) : (),
+ $category ? (list_of_names => $list_of_names) : (),
};
my $category_extra = '';
@@ -281,12 +285,14 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
my $councils_text_private = $c->render_fragment( 'report/new/councils_text_private.html');
$unresponsive = $c->stash->{unresponsive}->{$category} || $c->stash->{unresponsive}->{ALL} || '';
+
my $body = encode_json({
category_extra => $category_extra,
councils_text => $councils_text,
councils_text_private => $councils_text_private,
category_extra_json => $category_extra_json,
unresponsive => $unresponsive,
+ bodies => $list_of_names,
});
$c->res->content_type('application/json; charset=utf-8');
@@ -707,6 +713,12 @@ sub setup_categories_and_bodies : Private {
$c->stash->{non_public_categories} = \%non_public_categories;
$c->stash->{extra_name_info} = $first_area->{id} == COUNCIL_ID_BROMLEY ? 1 : 0;
+ # escape these so we can then split on , cleanly in the template.
+ my @list_of_names = map { $_->name } values %bodies_to_list;
+ my $csv = Text::CSV->new();
+ $csv->combine(@list_of_names);
+ $c->stash->{list_of_names_as_string} = $csv->string;
+
my @missing_details_bodies = grep { !$bodies_to_list{$_->id} } values %bodies;
my @missing_details_body_names = map { $_->name } @missing_details_bodies;