diff options
author | Dave Arter <davea@mysociety.org> | 2020-01-07 20:20:45 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2020-01-07 20:20:45 +0000 |
commit | 26edd4ed7a5c8fd90e3dba279d745c11d2ce0faf (patch) | |
tree | 76a21c8a79dead8b9166eba4c4cd9738df0dd566 /perllib/FixMyStreet/App/Controller | |
parent | 27fe9940d3830b6a9d23c82aeca5a93975eee5c3 (diff) |
Hide ‘provide extra information’ preamble when no visible fields are present
For categories that use the extra metadata fields to just show a notice
message to the user, the ‘help the council fix the problem by providing
extra information’ text was a bit out of place. This commit hides it
unless there are actual UI elements also included in the markup.
Fixes #2811.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index db469f130..efcaf8ddc 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -697,6 +697,8 @@ sub setup_categories_and_bodies : Private { my %category_extras = (); # extra fields to fill in for open311 my %category_extras_hidden = (); # whether all of a category's fields are hidden + my %category_extras_notices = + (); # whether all of a category's fields are simple notices and not inputs my %non_public_categories = (); # categories for which the reports are not public $c->stash->{unresponsive} = {}; @@ -729,6 +731,16 @@ sub setup_categories_and_bodies : Private { } else { $category_extras_hidden{$contact->category} = $all_hidden; } + + my $all_notices = (grep { + ( $_->{variable} || '' ) ne 'false' + && !$c->cobrand->category_extra_hidden($_) + } @$metas) ? 0 : 1; + if (exists($category_extras_notices{$contact->category})) { + $category_extras_notices{$contact->category} &&= $all_notices; + } else { + $category_extras_notices{$contact->category} = $all_notices; + } } $non_public_categories{ $contact->category } = 1 if $contact->non_public; @@ -760,6 +772,7 @@ sub setup_categories_and_bodies : Private { $c->stash->{category_options} = \@category_options; $c->stash->{category_extras} = \%category_extras; $c->stash->{category_extras_hidden} = \%category_extras_hidden; + $c->stash->{category_extras_notices} = \%category_extras_notices; $c->stash->{non_public_categories} = \%non_public_categories; $c->stash->{extra_name_info} = $first_area->{id} == COUNCIL_ID_BROMLEY ? 1 : 0; |