fix error in hold component, put setpickuplib into function that will also set next...
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 24 Aug 2022 16:35:17 +0000 (12:35 -0400)
committerLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 24 Aug 2022 16:35:17 +0000 (12:35 -0400)
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.html
Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates-bootstrap/opac/parts/place_hold.tt2

index 27078af..bfe8b3d 100644 (file)
@@ -90,7 +90,7 @@
           <label i18n>Pickup Location: </label>
         </div>
         <div class="col-lg-6">
-          <eg-org-select (onChange)="pickupLib = $event ? $event.id() : null;if(suspendTilOpen)nextOpenTime();"
+          <eg-org-select (onChange)="setPickuplib($event)" 
             [disableOrgs]="disableOrgs" [applyOrgId]="pickupLib"></eg-org-select>
         </div>
       </div>
             <eg-date-select [(ngModel)]="activeDate" name='active-date'
               (onChangeAsYmd)="activeDateYmd = $event"
               (onChangeAsDate)="setActiveDate($event)"
-              (onChangeAsIso)="activeDateSelected($event)" [disabled]="!suspend && !suspendTilOpen">
+              (onChangeAsIso)="activeDateSelected($event)" [disabled]="!suspend || suspendTilOpen">
             </eg-date-select>
           </div>
         </div>
index 27c81cb..85448a2 100644 (file)
@@ -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();
+    }
 
 }
 
index 1d8dac3..a9cd479 100644 (file)
@@ -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
index a4d7249..9396ed9 100644 (file)
@@ -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 ($@) {
index 8172036..24088db 100755 (executable)
@@ -3,6 +3,7 @@
     PROCESS "opac/parts/metarecord_hold_filters.tt2";
 %]
 <script>
+
 // Toggle the activation date input and check the suspend checkbox.
 // If JavaScript is disabled, the CSS will handle the former, but
 // the latter will not happen.
@@ -277,11 +278,20 @@ function maybeToggleNumCopies(obj) {
             <div>
 
              [% IF ctx.hold_data.size > 0; %]
+             <span class="font-weight-bold">
+                [% l('Hold Suspension'); %] 
+                <a href="#" aria-label="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" title="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" data-toggle="tooltip">
+                        <i class="fas fa-question-circle" aria-hidden="true"></i>
+                </a>
+            </span>
+            <div class="form-group">
             <div class="form-check m-2">
-                               <input class="form-check-input" type="radio" value="t" id="no_hold_suspend" name="hold_suspend" />
+                               <input class="form-check-input" type="radio" value="f" id="no_hold_suspend" name="hold_suspend" checked />
                                <label class="form-check-label" for="no_hold_suspend">
                                        [% l('Do not suspend this hold'); %]
                                </label>
+            </div>
+            <div class="form-check m-2">
                 <input class="form-check-input" type="radio" value="t" id="hold_suspend" name="hold_suspend" />
                 <label class="form-check-label" for="hold_suspend">
                 [% IF ctx.hold_data.size == 1;
@@ -289,31 +299,33 @@ function maybeToggleNumCopies(obj) {
                 ELSE;
                     l('Suspend these holds?');
                 END %]
-                  <a href="#" aria-label="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" title="[% l('A suspended hold will retain its place in the queue, but will not be fulfilled until it has been activated.') %]" data-toggle="tooltip">
-                    <i class="fas fa-question-circle" aria-hidden="true"></i>
-                </a>
                 </label>
-                               <input class="form-check-input" type="radio" value="p" id="auto_hold_suspend" name="hold_suspend" checked />
+                </br>
+                <a class="btn btn-sm btn-action m-2" id="actDateToggle" href="#toggled-block-suspend" onclick="return toggleActivationDate();"><i class="fas fa-calendar" aria-hidden="true"></i> [% l('Set activation date') %]</a>
+                <blockquote id="toggled-block-suspend">
+                <label for="thaw_date">[% l('Activate on') %]
+                  <div class="input-group date" data-provide="datepicker">
+                    <input type="text" class="form-control" name="thaw_date" id="thaw_date" value="[% thaw_date | html %]" data-date-format="mm/dd/yyyy" />
+                    <div class="input-group-addon">
+                        <span class="glyphicon glyphicon-th"></span>
+                    </div>
+                </div>
+                </blockquote>
+            </div>
+            <div class="form-check m-2">
+                               <input class="form-check-input" type="radio" value="p" id="auto_hold_suspend" name="hold_suspend" />
                                <label class="form-check-label" for="auto_hold_suspend">
                                        [% l('Suspend until Pickup Library Open'); %]
                                </label>
             </div>
+            </div>
                 [% END %]
 
 
 
 
-                <a class="btn btn-sm btn-action m-2" id="actDateToggle" href="#toggled-block-suspend" onclick="return toggleActivationDate();"><i class="fas fa-calendar" aria-hidden="true"></i> [% l('Set activation date') %]</a>
-            </div>
-            <blockquote id="toggled-block-suspend">
-            <label for="thaw_date">[% l('Activate on') %]
-              <div class="input-group date" data-provide="datepicker">
-                <input type="text" class="form-control" name="thaw_date" id="thaw_date" value="[% thaw_date | html %]" data-date-format="mm/dd/yyyy" />
-                <div class="input-group-addon">
-                    <span class="glyphicon glyphicon-th"></span>
-                </div>
+
             </div>
-            </blockquote>
 
          [% IF CGI.param('from_basket') %]