From: Jane Sandberg Date: Sun, 31 Mar 2019 23:04:53 +0000 (-0700) Subject: LP1816475: Populating the Create grid with actual reservations X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=20b8eb69f126aac818361deaf890b938142303e0;p=working%2FEvergreen.git LP1816475: Populating the Create grid with actual reservations Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html index 10fa30fe3b..6a9777f5b7 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html +++ b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.html @@ -122,11 +122,11 @@ [dataSource]="scheduleSource" [rowFlairIsEnabled]="true" [rowFlairCallback]="resourceAvailabilityIcon" - disablePager="true" - disableSaveSettings="true" + [disablePager]="true" + [disableSaveSettings]="true" [cellClassCallback]="isBooked"> - + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts index 4aabdeecbc..830d506fbf 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/create-reservation.component.ts @@ -107,33 +107,39 @@ export class CreateReservationComponent implements OnInit { } else if ('resource' === limiter) { where = {id: id}; } + this.scheduleSource.data = []; this.pcrud.search('brsrc', where, { order_by: 'barcode ASC', - flesh: 1, - flesh_fields: {'brsrc': ['curr_rsrcs']}, - select: {'curr_rsrcs': {'end_time': {'<' : '2019-04-01'}}} // TODO: make the time real using idlFormatDate; include all with an end time AFTER 12am AND start time BEFORE 11:59pm + flesh: 2, + flesh_fields: {'brsrc': ['curr_rsrcs'], 'bresv': ['usr']}, + select: {'curr_rsrcs': {'end_time': {'>' : Moment([], 'Asia/Tokyo').startOf('day').toISOString()}, 'start_time': {'<': Moment([], 'Asia/Tokyo').add(1,'days').endOf('day').toISOString()}}} }).subscribe( - r => { this.resources.push(r); }); - - this.scheduleSource.data = []; - this.startTime = Moment(new Date( - this.dateLimiter.current.year, - this.dateLimiter.current.month - 1, - this.dateLimiter.current.day, - 9, 0, 0), 'Asia/Tokyo'); - this.endTime = Moment(new Date( - this.dateLimiter.current.year, - this.dateLimiter.current.month - 1, - this.dateLimiter.current.day, - 17, 0, 0), 'Asia/Tokyo'); - let currentTime = this.startTime; - while (currentTime < this.endTime) { - this.scheduleSource.data.push({ - 'time': currentTime.format('LT'), - 'ROOM1231': 'Professor Pickle' + r => { + this.resources.push(r); + + this.startTime = Moment(new Date( + this.dateLimiter.current.year, + this.dateLimiter.current.month - 1, + this.dateLimiter.current.day, + 13, 0, 0), 'Asia/Tokyo'); + this.endTime = Moment(new Date( + this.dateLimiter.current.year, + this.dateLimiter.current.month - 1, + this.dateLimiter.current.day, + 17, 0, 0), 'Asia/Tokyo'); + let currentTime = this.startTime; + while (currentTime < this.endTime) { + const existingRow = this.scheduleSource.data.findIndex((row) => row['time'] === currentTime.format('LT')) ; + const idx = (existingRow > -1) ? existingRow : (this.scheduleSource.data.push({'time': currentTime.format('LT')}) - 1); + r.curr_rsrcs().forEach((reservation) => { + if ((Moment(reservation.start_time(), 'Asia/Tokyo') < (currentTime + this.granularity)) && (Moment(reservation.end_time(), 'Asia/Tokyo') > currentTime)) { + if (!this.scheduleSource.data[idx][r.barcode()]) { this.scheduleSource.data[idx][r.barcode()] = []; } + this.scheduleSource.data[idx][r.barcode()].push({'patronLabel': reservation.usr().usrname(), 'patronId': reservation.usr().id()}); + } + }); + currentTime.minute(currentTime.minute() + this.granularity); + } }); - currentTime.minute(currentTime.minute() + this.granularity); - } } }