LP1816475: respect hours of operation
authorJane Sandberg <sandbej@linnbenton.edu>
Sat, 6 Apr 2019 15:32:31 +0000 (08:32 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 17 Apr 2019 20:41:53 +0000 (13:41 -0700)
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html
Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts

index 91f0b94..b8d1e09 100644 (file)
@@ -42,7 +42,7 @@
       <div class="input-group-prepend">
         <label class="input-group-text" for="ideal-reservation-date" i18n>Reservation date</label>
       </div>
-      <eg-date-select *ngIf="!multiday" #dateLimiter domId="ideal-reservation-date"></eg-date-select>
+      <eg-date-select *ngIf="!multiday" #dateLimiter domId="ideal-reservation-date" (onChangeAsDate)="handleDateChange($event)"></eg-date-select>
       <eg-daterange-select *ngIf="multiday" #dateRangeLimiter></eg-daterange-select>
     </div>
   </div>
index 6b3882e..ef6682a 100644 (file)
@@ -1,5 +1,6 @@
 import { Component, Input, OnInit, AfterViewInit, QueryList, ViewChildren, ViewChild } from '@angular/core';
 import { NgbTimeStruct } from '@ng-bootstrap/ng-bootstrap';
+import { AuthService } from '@eg/core/auth.service';
 import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 import {DateSelectComponent} from '@eg/share/date-select/date-select.component';
 import {DateRangeSelectComponent} from '@eg/share/daterange-select/daterange-select.component';
@@ -24,6 +25,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
     advancedCollapsed = true;
     attributes: IdlObject[] = [];
     multiday = false;
+    handleDateChange: ($event: Date) => void;
     isBooked: (col: any, row: any) => string;
     resourceAvailabilityIcon: (row: any) => GridRowFlairEntry;
 
@@ -49,6 +51,7 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
     @ViewChild('newDialog') newDialog: FmRecordEditorComponent;
 
     constructor(
+        private auth: AuthService,
         private format: FormatService,
         private pcrud: PcrudService,
         private store: ServerStoreService,
@@ -93,6 +96,23 @@ export class CreateReservationComponent implements OnInit, AfterViewInit {
            this.scheduleGrids.forEach((g) => g.reload());
         };
 
+       this.handleDateChange = ($event: Date) => {
+            this.pcrud.retrieve('aouhoo', this.auth.user().ws_ou())
+            .subscribe(hours => {
+                const startArray = hours['dow_' + ($event.getDay() + 6) % 7 + '_open']().split(':');
+                const endArray = hours['dow_' + ($event.getDay() + 6) % 7 + '_close']().split(':');
+                this.startOfDay = {
+                    hour: ('00' == startArray[0]) ? 9 : +startArray[0],
+                    minute: +startArray[1],
+                    second: 0};
+                this.endOfDay = {
+                    hour: ('00' == endArray[0]) ? 17 : +endArray[0],
+                    minute: +endArray[1],
+                    second: 0};
+                this.scheduleGrids.forEach((g) => g.reload());
+            });
+        }
+
         this.handleMultiDayReservation = () => {
             this.multiday = true;
             this.setGranularity();