Skip to content

Commit

Permalink
[Brent] Add field for if 'other' small item is picked.
Browse files Browse the repository at this point in the history
  • Loading branch information
MorayMySoc authored and dracos committed Oct 9, 2023
1 parent 4b1e70c commit ad02466
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 11 deletions.
5 changes: 3 additions & 2 deletions perllib/FixMyStreet/App/Controller/Admin/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ sub edit : Chained('body') : PathPart('') : Args(0) {
band1_max => 'int',
free_mode => 'bool',
food_bags_disabled => 'bool',
show_location_page => 'sel'
show_location_page => 'sel',
show_individual_notes => 'bool',
);
foreach (keys %keys) {
my $val = $c->get_param($_);
Expand Down Expand Up @@ -217,7 +218,7 @@ sub stash_body_config_json : Private {
} else {
$c->stash->{body_config_json} = JSON->new->utf8(1)->pretty->canonical->encode($cfg);
}
foreach (qw(free_mode per_item_costs base_price daily_slots items_per_collection_max food_bags_disabled show_location_page band1_price band1_max)) {
foreach (qw(free_mode per_item_costs base_price daily_slots items_per_collection_max food_bags_disabled show_location_page band1_price band1_max show_individual_notes)) {
$c->stash->{$_} = $c->get_param($_) || $cfg->{$_};
}
}
Expand Down
9 changes: 8 additions & 1 deletion perllib/FixMyStreet/App/Controller/Waste/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sub item_list : Private {

my $max_items = $c->cobrand->bulky_items_maximum;
my $field_list = [];

for my $num ( 1 .. $max_items ) {
push @$field_list,
"item_$num" => {
Expand All @@ -81,13 +82,19 @@ sub item_list : Private {
type => 'FileIdPhoto',
num_photos_required => 0,
linked_field => "item_photo_$num",
},
"item_notes_${num}" => {
type => 'TextArea',
label => 'Item note (optional)',
maxlength => 100,
tags => { hint => 'Describe the item to help our crew pick up the right thing' },
};
}

$c->stash->{page_list} = [
add_items => {
fields => [ 'continue',
map { ("item_$_", "item_photo_$_", "item_photo_${_}_fileid") } ( 1 .. $max_items ),
map { ("item_$_", "item_photo_$_", "item_photo_${_}_fileid", "item_notes_$_") } ( 1 .. $max_items ),
],
template => 'waste/bulky/items.html',
title => 'Add items for collection',
Expand Down
4 changes: 3 additions & 1 deletion perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@ sub waste_munge_bulky_data {
$data->{extra_Collection_Date} = $date;
$data->{extra_Exact_Location} = $data->{location};

my (%types, @photos);
my (%types, @photos, @notes);
my $max = $self->bulky_items_maximum;
for (1..$max) {
if (my $item = $data->{"item_$_"}) {
Expand All @@ -1414,8 +1414,10 @@ sub waste_munge_bulky_data {
$data->{extra_Small_WEEE} = 1;
}
push @photos, $data->{"item_photos_$_"} || '';
push @notes, $data->{"item_notes_$_"} || ''; # XXX IF other
};
}
# TODO Include notes in this field as well, if the key is Other?
$data->{extra_Notes} = join("\n", map { "$types{$_} x $_" } sort keys %types);
$data->{extra_Image} = join("::", @photos);
}
Expand Down
2 changes: 2 additions & 0 deletions perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ sub bulky_show_location_page {
};
sub bulky_show_location_field_mandatory { 0 }

sub bulky_show_individual_notes { $_[0]->wasteworks_config->{show_individual_notes} };

sub bulky_pricing_strategy {
my $self = shift;
my $base_price = $self->wasteworks_config->{base_price};
Expand Down
2 changes: 0 additions & 2 deletions perllib/FixMyStreet/Roles/CobrandSLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,4 @@ sub dashboard_export_problems_add_columns {
});
}



1;
1 change: 1 addition & 0 deletions t/app/controller/waste_peterborough.t
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ FixMyStreet::override_config {
$body->discard_changes;
is_deeply $body->get_extra_metadata('wasteworks_config'), {
show_location_page => 'noshow',
show_individual_notes => 0,
band1_max => '',
band1_price => '',
daily_slots => 50,
Expand Down
6 changes: 3 additions & 3 deletions templates/web/base/admin/waste/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ <h3>Bulky Collections</h3>
<option value="users" [% 'selected' IF show_location_page == 'users' %]>[% loc('Users') %]</option>

<p>
<input type=checkbox name="per_item_costs" value=1 id="waste_per_item_costs"
[% 'checked' IF per_item_costs %]>
<label class="inline" for="waste_per_item_costs">Charge per item, not per collection</label>
<input type=checkbox name="show_individual_notes" value=1 id="waste_show_individual_notes"
[% 'checked' IF show_individual_notes %]>
<label class="inline" for="waste_show_individual_notes">Add text box for extra notes on every item</label>

[% IF c.cobrand.moniker == 'peterborough' %]
<p>
Expand Down
4 changes: 4 additions & 0 deletions templates/web/base/waste/bulky/items.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
[% # Building names beforehand because override_fields does not seem to like them being built inside its arg list %]
[% item = 'item_' _ num %]
[% PROCESS form override_fields = [ item ] %]
[% IF c.cobrand.moniker == 'brent' AND c.cobrand.call_hook('bulky_show_individual_notes') %]
[% notes = 'item_notes_' _ num %]
[% PROCESS form override_fields = [ notes ] %]
[% END %]
[% PROCESS extra_text num = num %]
[% IF c.cobrand.moniker != 'brent' %]
[% photo = 'item_photo_' _ num %]
Expand Down
8 changes: 6 additions & 2 deletions templates/web/base/waste/bulky/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ <h3 class="summary-section--heading">Items to be collected</h3>
item_key = 'item_' _ num;
photo_key = 'item_photo_' _ num;
item = data.$item_key;
notes_key = 'item_notes_' _ num;
NEXT UNLESS item;
items.push({ item => item, photo => data.$photo_key });
items.push({ item => item, photo => data.$photo_key, notes => data.$notes_key });
END %]
[% IF c.cobrand.moniker != 'brent' %]
<dl>
Expand Down Expand Up @@ -155,6 +156,9 @@ <h3 class="summary-section--heading">Items to be collected</h3>
<tr [% IF extra_text %]class="is--no-border-bottom"[% END %]>
<td>
<p class="govuk-!-margin-bottom-0">[% item.item %]</p>
[% IF item.notes %]
<p class="govuk-!-margin-bottom-0"><i>[% item.notes %]</i></p>
[% END %]
</td>
[% IF c.cobrand.moniker != 'brent' %]
<td>
Expand All @@ -168,7 +172,7 @@ <h3 class="summary-section--heading">Items to be collected</h3>
</tr>
[% IF extra_text %]
<tr>
<td colspan="3">
<td colspan="2">
<div class="govuk-warning-text due" style="padding:1em">
<div class="govuk-warning-text__img">
<span class="govuk-warning-text__icon" aria-hidden="true">!</span>
Expand Down

0 comments on commit ad02466

Please sign in to comment.