listReadOnlyFields: () => string;
startTimeShouldBeFuture: (fieldName: string, value: Moment, record: IdlObject) => string;
+ endTimeShouldBeAfterStartTime: (fieldName: string, value: Moment, record: IdlObject) => string;
handleRowActivate: (row: IdlObject) => void;
}
return '';
};
+ this.endTimeShouldBeAfterStartTime = (fieldName: string, value: Moment, record: IdlObject) => {
+ if (Moment(value) <= Moment(record['start_time'])) {
+ return 'End time must be after start time';
+ }
+ return '';
+ };
this.handleRowActivate = (row: IdlObject) => {
if (this.status) {
</eg-staff-banner>
<eg-title i18n-prefix i18n-suffix prefix="Booking" suffix="Return"></eg-title>
-<!-- TODO: DRY This out: there has to be a good way to reuse the template -->
<ngb-tabset (tabChange)="handleTabChange($event)" [activeId]="selectedTab">
<ngb-tab title="By patron" i18n-title id="patron">
<ng-template ngbTabContent>
</div>
<div *ngIf="patronId">
<h2 class="text-center" i18n>Ready for return</h2>
- <eg-reservations-grid #patronReady [patron]="patronId" status="returnReady" persistSuffix="return.patron.picked_up"></eg-reservations-grid>
+ <eg-reservations-grid #readyGrid [patron]="patronId" status="returnReady" (onReturn)="this.returnedGrid.reloadGrid()" persistSuffix="return.patron.picked_up"></eg-reservations-grid>
<h2 class="text-center" i18n>Returned today</h2>
- <eg-reservations-grid #patronReturned [patron]="patronId" status="returnedToday" persistSuffix="return.patron.returned"></eg-reservations-grid>
+ <eg-reservations-grid #returnedGrid [patron]="patronId" status="returnedToday" persistSuffix="return.patron.returned"></eg-reservations-grid>
</div>
</ng-template>
</ngb-tab>
</div>
<div *ngIf="patronId">
<h2 class="text-center" i18n>Ready for return</h2>
- <eg-reservations-grid #resourceReady [resource]="patronId" status="returnReady" persistSuffix="return.resource.picked_up"></eg-reservations-grid>
+ <eg-reservations-grid #readyGrid [patron]="patronId" status="returnReady" (onReturn)="this.returnedGrid.reloadGrid()" persistSuffix="return.resource.picked_up"></eg-reservations-grid>
<h2 class="text-center" i18n>Returned today</h2>
- <eg-reservations-grid #resourceReturned [patron]="patronId" status="returnedToday" persistSuffix="return.resource.returned"></eg-reservations-grid>
+ <eg-reservations-grid #returnedGrid [patron]="patronId" status="returnedToday" persistSuffix="return.resource.returned"></eg-reservations-grid>
</div>
</ng-template>
</ngb-tab>
</ngb-tabset>
+
-import { Component, Input, OnInit, ViewChild } from '@angular/core';
+import { Component, Input, OnInit, QueryList, ViewChildren } from '@angular/core';
import {Router, ActivatedRoute, ParamMap} from '@angular/router';
import { NgbTabChangeEvent } from '@ng-bootstrap/ng-bootstrap';
import {Observable} from 'rxjs';
noSelectedRows: (rows: IdlObject[]) => boolean;
handleTabChange: ($event: NgbTabChangeEvent) => void;
- @ViewChild('patronReady') patronReady: ReservationsGridComponent;
- @ViewChild('patronReturned') patronReturned: ReservationsGridComponent;
- @ViewChild('resourceReady') resourceReady: ReservationsGridComponent;
- @ViewChild('resourceReturned') resourceReturned: ReservationsGridComponent;
+ @ViewChildren('readyGrid') readyGrids: QueryList<ReservationsGridComponent>;
+ @ViewChildren('returnedGrid') returnedGrids: QueryList<ReservationsGridComponent>;
constructor(
private auth: AuthService,
}).subscribe(
(resp) => {
this.patronBarcode = resp.card().barcode();
- this.patronReady.reloadGrid();
- this.patronReturned.reloadGrid();
+ this.readyGrids.forEach (readyGrid => readyGrid.reloadGrid());
+ this.returnedGrids.forEach (returnedGrid => returnedGrid.reloadGrid());
}, (err) => { console.debug(err); }
);
} else {
}).subscribe((resp) => {
if (resp.curr_rsrcs()[0].usr()) {
this.patronId = resp.curr_rsrcs()[0].usr();
- this.resourceReady.reloadGrid();
- this.resourceReturned.reloadGrid();
+ this.readyGrids.forEach (readyGrid => readyGrid.reloadGrid());
+ this.returnedGrids.forEach (returnedGrid => returnedGrid.reloadGrid());
}
});
}
this.noSelectedRows = (rows: IdlObject[]) => (rows.length === 0);
this.handleTabChange = ($event) => {
- this.store.setItem('eg.booking.return.tab', $event.nextId);
- this.router.navigate(['/staff', 'booking', 'return']);
- this.resourceBarcode = null;
- this.patronBarcode = null;
- this.patronId = null;
+ this.store.setItem('eg.booking.return.tab', $event.nextId)
+ .then(() => {
+ this.router.navigate(['/staff', 'booking', 'return']);
+ this.resourceBarcode = null;
+ this.patronBarcode = null;
+ this.patronId = null;
+ });
};
}
}
+