Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions perllib/FixMyStreet/App/Controller/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ sub construct_bin_request_form {
option_label => $c->stash->{containers}->{$id},
tags => { toggle => "form-quantity-$id-row" },
disabled => $_->{requests_open}{$id} ? 1 : 0,
option_hint => $_->{requests_open}{$id} ? 'Unavailable to request as order in progress' : "",
};
$name = ''; # Only on first container
if ($max == 1) {
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Brent.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ sub waste_munge_request_form_fields {
value => $id,
label => $self->{c}->stash->{containers}->{$id},
disabled => $value->{disabled},
$hint ? (hint => $hint) : (),
hint => $value->{option_hint} || $hint, # In progress overrides
};
$seen{$id} = 1;
}
Expand Down
4 changes: 2 additions & 2 deletions perllib/FixMyStreet/Cobrand/Kingston.pm
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ sub bin_request_form_extra_fields {

return unless $id == $CONTAINERS{food_outdoor};
my %fields = @$field_list;
$fields{"container-$id"}{option_hint} = 'Only three are allowed per property. Any more than this will not be collected.';
$fields{"container-$id"}{option_hint} ||= 'Only three are allowed per property. Any more than this will not be collected.';
}

=head2 waste_munge_request_form_fields
Expand All @@ -286,7 +286,7 @@ sub waste_munge_request_form_fields {
if (my $cost = $self->container_cost($id)) {
my $price = sprintf("£%.2f", $cost / 100);
$price =~ s/\.00$//;
$value->{option_hint} = "There is a $price cost for this container";
$value->{option_hint} ||= "There is a $price cost for this container";
}
}
return;
Expand Down
58 changes: 29 additions & 29 deletions perllib/FixMyStreet/Cobrand/Merton/Waste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,39 @@ sub waste_munge_request_form_fields {
if ($cost) {
my $price = sprintf("£%.2f", $cost / 100);
$price =~ s/\.00$//;
$value->{option_hint} = "There is a $price cost for this container";
$value->{option_hint} ||= "There is a $price cost for this container";
}
}
}

=head2 bin_request_form_extra_fields

Include special note for domestic_mixed container requests.

=cut

sub bin_request_form_extra_fields {
my ($self, $service, $id, $field_list) = @_;
my $note = $self->container_request_note($service->{service_id});
return unless $note;
my %fields = @$field_list;
$fields{"container-$id"}{option_hint} = $note;
}

=head2 container_request_note

Include special note for domestic_mixed container requests.

=cut

sub container_request_note {
my ($self, $service_id) = @_;
if ($service_id && $service_id eq $SERVICE_IDS{domestic_mixed}) {
return 'Currently out of stock. ' .
'Orders will be delivered once stock is available, but we do not know when this will be.';
}
}

=head2 request_cost

Calculate how much, if anything, a request for a container should be.
Expand Down Expand Up @@ -638,32 +666,4 @@ sub _bulky_collection_overdue {
return $today > $collection_due_date;
}

=head2 container_request_note

Include special note for domestic_mixed container requests.

=cut

sub container_request_note {
my ($self, $service_id) = @_;
if ($service_id && $service_id eq $SERVICE_IDS{domestic_mixed}) {
return 'Currently out of stock. ' .
'Orders will be delievered once stock is available, but we do not know when this will be.';
}
}

=head2 bin_request_form_extra_fields

Include special note for domestic_mixed container requests.

=cut

sub bin_request_form_extra_fields {
my ($self, $service, $id, $field_list) = @_;
my $note = $self->container_request_note($service->{service_id});
return unless $note;
my %fields = @$field_list;
$fields{"container-$id"}{option_hint} = $note;
}

1;
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ sub waste_munge_request_form_fields {
value => $id,
label => $self->{c}->stash->{containers}->{$id},
disabled => $value->{disabled},
$hint ? (hint => $hint) : (),
hint => $value->{option_hint} || $hint, # In progress overrides
};
if ($cost && $change_cost && $cost == $change_cost) {
push @replace_options, $data;
Expand Down
6 changes: 3 additions & 3 deletions t/app/controller/waste_sutton_r.t
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ FixMyStreet::override_config {
$mech->content_contains('A mixed recycling (cans, plastics & glass) container request was made on Saturday, 10 September');
$mech->content_contains('Report a mixed recycling (cans, plastics & glass) collection as missed');
$mech->get_ok('/waste/12345/request');
$mech->content_like(qr/name="container-choice" value="12"\s+disabled/s); # green

$mech->content_like(qr/name="container-choice" value="12" aria-describedby="container-choice-item-hint"\s+disabled/s); # green
$mech->content_like(qr/Mixed Recycling Green Box \(55L\).*?<span id="container-choice-item-hint" class="govuk-hint govuk-checkboxes__hint">\s+Unavailable to request as order in progress/s);
$e->mock('GetEventsForObject', sub { [ {
# Request
EventDate => { DateTime => "2022-09-10T17:00:00Z" },
Expand All @@ -323,7 +323,7 @@ FixMyStreet::override_config {
$mech->get_ok('/waste/12345');
$mech->content_contains('A food waste container request was made on Saturday, 10 September');
$mech->get_ok('/waste/12345/request');
$mech->content_like(qr/name="container-choice" value="43"\s+disabled/s); # indoor
$mech->content_like(qr/name="container-choice" value="43" aria-describedby="container-choice-item-hint"\s+disabled/s); # indoor
$mech->content_like(qr/name="container-choice" value="46"\s*>/s); # outdoor

$e->mock('GetEventsForObject', sub { [ {
Expand Down
Loading