From 5d01ff778b1d9c042ed9a9dd4131f071b23d6477 Mon Sep 17 00:00:00 2001 From: Llewellyn Marshall Date: Wed, 24 Aug 2022 12:35:17 -0400 Subject: [PATCH] fix error in hold component, put setpickuplib into function that will also set next open time. --- .../src/app/staff/catalog/hold/hold.component.html | 4 +-- .../src/app/staff/catalog/hold/hold.component.ts | 25 ++++++++++--- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 17 ++++++--- .../lib/OpenILS/WWW/EGCatLoader/Account.pm | 4 +-- .../templates-bootstrap/opac/parts/place_hold.tt2 | 42 ++++++++++++++-------- 5 files changed, 65 insertions(+), 27 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html index 27078afc1b..bfe8b3d410 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html @@ -90,7 +90,7 @@
-
@@ -114,7 +114,7 @@ + (onChangeAsIso)="activeDateSelected($event)" [disabled]="!suspend || suspendTilOpen"> diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts index 27c81cb9a9..85448a26c2 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts @@ -708,11 +708,28 @@ export class HoldComponent implements OnInit { nextOpenTime(){ this.net.request('open-ils.actor', 'open-ils.actor.org_unit.next_operating_hour',this.pickupLib - ).subscribe(resp => { - console.log(resp); - this.activeDateSelected(resp); - }); + ).subscribe( + resp => { + console.log(resp); + if(resp){ + this.activeDateSelected(resp); + } + else{ + this.suspend = false; + this.suspendTilOpen = false; + } + }, + error => { + this.suspend = false; + this.suspendTilOpen = false; + } + ); } + + setPickuplib($event){ + this.pickupLib = $event ? $event.id() : null; + if(this.suspendTilOpen)this.nextOpenTime(); + } } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 1d8dac3d16..a9cd4794bd 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -1495,7 +1495,7 @@ sub get_next_operating_hour { } else{ # default to current time if none defined - $start_time = DateTime->now(); + $start_time = DateTime->now(time_zone => 'local'); } my $h = $e->search_actor_org_unit_hours_of_operation({id => $org_id})->[0]; return $e->event unless defined $h; @@ -1507,7 +1507,8 @@ sub get_next_operating_hour { $start_time->add(days => 1); $start_time->set(hour => 0,minute => 0, second=> 0); } - my $day_of_week = $start_time->wday; + # DateTime DOW index starts at 1, Evergreen starts at 0 + my $day_of_week = $start_time->wday - 1; my $open_time_f = 'dow_'.$day_of_week.'_open'; my $close_time_f = 'dow_'.$day_of_week.'_close'; my $open_time_st = $h->$open_time_f; @@ -1519,9 +1520,17 @@ sub get_next_operating_hour { # create open/close datetimes based on current thaw date my $open_time = $start_time->clone->set(hour => $open_times[0],minute => $open_times[1],second => $open_times[2]); my $close_time = $start_time->clone->set(hour => $close_times[0],minute => $close_times[1],second => $close_times[2]); + $logger->info("operating hours $open_time - $close_time current time: $start_time, day of week: $day_of_week"); if(DateTime->compare($start_time,$open_time) >= 0 && DateTime->compare($start_time,$close_time) < 0){ - # we found a good time, end loop - return $start_time->iso8601; + if($dow){ + # we found a good time, end loop + return $start_time->iso8601; + } + else{ + # there is no "next" open time because the library + # was open at the time API call is placed + return $e->event; + } } elsif(DateTime->compare($start_time,$open_time) <= 0){ # our start is before opening time diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm index a4d7249a0b..9396ed9a6f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm @@ -1553,8 +1553,8 @@ sub load_place_hold { my $thaw_date_str = $U->simplereq( 'open-ils.actor', 'open-ils.actor.org_unit.next_operating_hour', $cgi->param('pickup_lib') || $self->ctx->{search_ou}); - my $thaw_dt = DateTime::Format::ISO8601->parse_datetime($thaw_date_str); - $ctx->{thaw_date} = $thaw_dt->ymd; + #my $thaw_dt = DateTime::Format::ISO8601->parse_datetime($thaw_date_str); + $ctx->{thaw_date} = $thaw_date_str; $ctx->{frozen} = 1; }; if ($@) { diff --git a/Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2 b/Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2 index 8172036bfe..24088db8ad 100755 --- a/Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2 +++ b/Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2 @@ -3,6 +3,7 @@ PROCESS "opac/parts/metarecord_hold_filters.tt2"; %]