aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Report/New.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2018-04-03 12:22:21 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-08-03 21:33:13 +0100
commitd90f4c2587380831d3cb6ed431a0c9c002575702 (patch)
tree0937be02104281e5b24ecd96aac7fd3cc2baca16 /perllib/FixMyStreet/App/Controller/Report/New.pm
parentf0a20065e8129f9da5d48a8f29a37755de61e4bb (diff)
Allow asset layer display to be body dependent.
Return a list of associated bodies on around/new pages and in category ajax calls, and use that when deciding whether to show/hide layers. If the layer has no body information, then we show it as before, maybe based on category selected; if it does, it is only shown if the layer body matches the bodies for the point. As part of this create a new VectorAsset class to handle all the visibility changes for asset layers as it makes it a bit tidier.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm14
1 files changed, 13 insertions, 1 deletions
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;