diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-08-22 14:47:00 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-08-29 18:12:39 +0100 |
commit | 7a8dcd6b60877c37df6961abf6743981966dc30c (patch) | |
tree | ac41579c7437c47ee64992839d25f1d3fd3b6649 /perllib/FixMyStreet/App/Controller/Report/New.pm | |
parent | 7570b9d1d95ec5a5ee58df69feab487be78831aa (diff) |
Allow form-disabling per Open311 question answer.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 5e4018e4d..c50093f23 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -311,13 +311,22 @@ sub by_category_ajax_data : Private { sub disable_form_message : Private { my ( $self, $c ) = @_; - my @descriptions = map { - $_->{description} - } grep { - $_->{disable_form} && $_->{disable_form} eq 'true' - } @{ $c->stash->{category_extras}->{$c->stash->{category}} }; - - return join " ", @descriptions; + my %out; + foreach (@{$c->stash->{category_extras}->{$c->stash->{category}}}) { + if ($_->{disable_form} && $_->{disable_form} eq 'true') { + $out{all} .= ' ' if $out{all}; + $out{all} .= $_->{description}; + } elsif (($_->{variable} || '') eq 'true' && @{$_->{values} || []}) { + foreach my $opt (@{$_->{values}}) { + if ($opt->{disable}) { + $out{message} = $_->{datatype_description}; + $out{code} = $_->{code}; + push @{$out{answers}}, $opt->{key}; + } + } + } + } + return \%out; } =head2 report_import |