Skip to content

Commit

Permalink
[Waste] [Bulky] List all bookings on bin day page.
Browse files Browse the repository at this point in the history
Still only one booking can be made, though.
  • Loading branch information
dracos committed Sep 12, 2023
1 parent 8c2ea2b commit 60f0eb5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
3 changes: 2 additions & 1 deletion perllib/FixMyStreet/App/Controller/Waste/Bulky.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ sub item_list : Private {
sub index : PathPart('') : Chained('setup') : Args(0) {
my ($self, $c) = @_;

if ($c->stash->{property}{pending_bulky_collection}) {
# TODO Remove when allowing more than one booking
if ($c->stash->{pending_bulky_collections}) {
$c->detach('/waste/property_redirect');
}

Expand Down
5 changes: 3 additions & 2 deletions perllib/FixMyStreet/Cobrand/Peterborough.pm
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,9 @@ sub look_up_property {

my %premises = map { $_->{uprn} => $_ } @$premises;

$premises{$uprn}{pending_bulky_collection}
= $self->find_pending_bulky_collection( $premises{$uprn} );
my @pending = $self->find_pending_bulky_collections($uprn)->all;
$self->{c}->stash->{pending_bulky_collections}
= @pending ? \@pending : undef;

return $premises{$uprn};
}
Expand Down
8 changes: 0 additions & 8 deletions perllib/FixMyStreet/Roles/CobrandBulkyWaste.pm
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,6 @@ sub find_pending_bulky_collections {
});
}

# Originally was only a single open collection for a given property,
# so this returns the most recent
sub find_pending_bulky_collection {
my ( $self, $property ) = @_;

return $self->find_pending_bulky_collections($property->{uprn})->first;
}

sub _bulky_collection_window {
my ($self, $last_earlier_date_str) = @_;
my $fmt = '%F';
Expand Down
40 changes: 23 additions & 17 deletions templates/web/base/waste/bulky/_bin_days_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[% IF property.pending_bulky_collection AND NOT c.user_exists %]
[% TRY %][% PROCESS waste/_bulky_not_signed_user.html %][% CATCH file %][% END %]
[% IF pending_bulky_collections AND NOT c.user_exists %]
[% PROCESS waste/_bulky_not_signed_user.html %]
[% END %]

<dl class="govuk-summary-list govuk-!-margin-bottom-0">
Expand All @@ -25,26 +25,40 @@
</dd>
</div>

[% IF c.cobrand.bulky_can_view_collection(property.pending_bulky_collection) %]
[% FOR booking IN pending_bulky_collections %]

[% IF c.cobrand.bulky_can_view_collection(booking) %]
<!-- #01 Should only display when: There IS a booking AND is a signed user -->
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Next collection</dt>
<dd class="govuk-summary-list__value">[% c.cobrand.bulky_nice_collection_date(property.pending_bulky_collection) %]</dd>
<dd class="govuk-summary-list__value">[% c.cobrand.bulky_nice_collection_date(booking) %]</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Reference number</dt>
<dd class="govuk-summary-list__value">[% property.pending_bulky_collection.id %]</dd>
<dd class="govuk-summary-list__value">[% booking.id %]</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Items to be collected</dt>
<dd class="govuk-summary-list__value">
<p class="govuk-!-margin-bottom-0">[% c.cobrand.bulky_nice_item_list(property.pending_bulky_collection).size %]</p>
<p class="govuk-!-margin-bottom-0">[% c.cobrand.bulky_nice_item_list(booking).size %]</p>
</dd>
</div>
<!-- END #01 -->
[% END %]

<div class="waste-services-launch-panel">
[% IF c.cobrand.bulky_can_view_collection(booking) %]
<!-- #05 Should only display when: There IS a booking AND is a signed user -->
<a class="btn btn-primary govuk-!-margin-bottom-2" href="/report/[% booking.id %]">Check collection details</a>
[% IF c.cobrand.bulky_collection_can_be_cancelled(booking) %]
<a class="btn btn-primary govuk-!-margin-bottom-2" href="[% c.uri_for_action('waste/bulky/cancel', [ property.id, booking.id ]) %]">Cancel booking</a>
[% END %]
<!-- END #05 -->
[% END %]
</div>
[% END %]

[% IF c.user_exists AND NOT property.pending_bulky_collection %]
[% IF NOT booking AND c.user_exists %]
<!-- #04 Should only display when: There is NO booking AND is a signed user -->
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Next collection</dt>
Expand All @@ -57,20 +71,12 @@
<hr>

<div class="waste-services-launch-panel">
[% IF c.cobrand.bulky_can_view_collection(property.pending_bulky_collection) %]
<!-- #05 Should only display when: There IS a booking AND is a signed user -->
<a class="btn btn-primary govuk-!-margin-bottom-2" href="/report/[% property.pending_bulky_collection.id %]">Check collection details</a>
[% IF c.cobrand.bulky_collection_can_be_cancelled(property.pending_bulky_collection) %]
<a class="btn btn-primary govuk-!-margin-bottom-2" href="[% c.uri_for_action('waste/bulky/cancel', [ property.id, property.pending_bulky_collection.id ]) %]">Cancel booking</a>
[% END %]
<!-- END #05 -->
[% END %]
[% UNLESS c.user_exists %]
<!-- #07 Should be displayed when: user HASN'T signed in -->
<a class="btn btn-primary govuk-!-margin-bottom-2" href="/auth?r=report/[% property.pending_bulky_collection.id %]">Sign in</a>
<a class="btn btn-primary govuk-!-margin-bottom-2" href="/auth?r=waste/[% property.id %]">Sign in</a>
<!-- END #07 -->
[% END %]
[% UNLESS property.pending_bulky_collection %]
[% UNLESS pending_bulky_collections %]
<!-- #06 Should NOT be displayed when: there is a signed user with a booking request -->
<form method="post" action="[% c.uri_for_action('waste/bulky/index', [ property.id ]) %]">
<input type="hidden" name="token" value="[% csrf_token %]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
You need to sign in to see the full details of this property.
</p>
<p class="govuk-!-margin-bottom-0">
<a class="btn btn-primary govuk-!-margin-bottom-2" href="/auth?r=report/[% property.pending_bulky_collection.id %]">Sign in</a>
<a class="btn btn-primary govuk-!-margin-bottom-2" href="/auth?r=waste/[% property.id %]">Sign in</a>
</p>
</div>
</div>

0 comments on commit 60f0eb5

Please sign in to comment.