import {BookingRoutingModule} from './routing.module';
import {CreateReservationComponent} from './create-reservation.component';
import {ManageReservationsComponent} from './manage-reservations.component';
+import {OrgSelectWithDescendantsComponent} from './org-select-with-descendants.component';
import {ReservationsGridComponent} from './reservations-grid.component';
import {PickupComponent} from './pickup.component';
import {PullListComponent} from './pull-list.component';
CreateReservationComponent,
ManageReservationsComponent,
NoTimezoneSetComponent,
+ OrgSelectWithDescendantsComponent,
PickupComponent,
PullListComponent,
ReservationsGridComponent,
<div class="row">
<div class="col">
- <div class="input-group">
- <div class="input-group-prepend">
- <label for="pickup-library" i18n class="input-group-text">Owning library</label>
- </div>
- <eg-org-select domId="owning-library">
- </eg-org-select>
- </div>
- </div>
- <div class="col">
- <div class="form-check">
- <input type="checkbox" class="form-check-input" id="include-descendants">
- <label class="form-check-label" for="include-descendants" i18n>+ Descendants</label>
- </div>
+ <eg-org-select-with-descendants labelText="Owning library" i18n-labelText (ouChange)="handleOwnerChange($event)">
+ </eg-org-select-with-descendants>
</div>
<div class="col">
<div class="input-group">
selectedAttributes: number[] = [];
multiday = false;
handleDateChange: ($event: Date) => void;
+ handleOwnerChange: ($event: number[]) => void;
resourceAvailabilityIcon: (row: any) => GridRowFlairEntry;
+ owningLibraries: number[] = [];
+
patronBarcode: string;
patronId: number;
resourceBarcode: string;
ngOnInit() {
+ this.owningLibraries = [this.auth.user().ws_ou()];
+
this.defaultTimes = {
'start_time': Moment.tz([], this.format.wsOrgTimezone),
'end_time': Moment.tz([], this.format.wsOrgTimezone).add(this.granularity, 'minutes')
this.fetchData();
});
};
+ this.handleOwnerChange = ($event: number[]) => {
+ this.owningLibraries = $event;
+ this.fetchData();
+ }
this.handleMultiDayReservation = () => {
this.multiday = true;
fetchData () {
this.resources = [];
- let where = {};
+ let where = {'owner': this.owningLibraries};
if (this.resourceId) {
- where = {id: this.resourceId};
+ where['id'] = this.resourceId;
} else if (this.resourceTypeId) {
- where = {type: this.resourceTypeId};
+ where['type'] = this.resourceTypeId;
} else {
return;
}
<div class="card-body row">
<div class="col-sm-3">
- <div class="input-group">
- <div class="input-group-prepend">
- <label for="pickup-library" i18n class="input-group-text">Pickup library</label>
- </div>
- <eg-org-select domId="pickup-library">
- </eg-org-select>
- </div>
- </div>
- <div class="col-sm-3">
- <div class="form-check">
- <input type="checkbox" class="form-check-input" id="include-ancestors">
- <label class="form-check-label" for="include-ancestors" i18n>+ Ancestors</label>
- </div>
- <div class="form-check">
- <input type="checkbox" class="form-check-input" id="include-descendants">
- <label class="form-check-label" for="include-descendants" i18n>+ Descendants</label>
- </div>
+ <eg-org-select-with-descendants labelText="Pickup library" i18n-labelText (ouChange)="handlePickupLibChange($event)">
+ </eg-org-select-with-descendants>
</div>
- <div class="col-sm-6">
+ <div class="col-sm-6 offset-sm-3">
<div class="card">
<h2 class="card-header" i18n>Filter reservations</h2>
<ngb-tabset #filters [activeId]="selectedFilter" (tabChange)="setStickyFilter($event)" class="mt-1">
</div>
</div>
</div>
-<eg-reservations-grid #reservationsGrid [patron]="patronId" [resource]="resourceId" [resourceType]="resourceTypeId" persistSuffix="manage"></eg-reservations-grid>
+<eg-reservations-grid #reservationsGrid [patron]="patronId" [resource]="resourceId" [resourceType]="resourceTypeId" [pickupLibIds]="pickupLibIds" persistSuffix="manage"></eg-reservations-grid>
})
export class ManageReservationsComponent implements OnInit {
+ pickupLibIds: number[];
patronBarcode: string;
patronId: number;
resourceBarcode: string;
@ViewChild('reservationsGrid') reservationsGrid: ReservationsGridComponent;
+ handlePickupLibChange: ($event: number[]) => void;
filterByCurrentPatronBarcode: () => void;
filterByCurrentResourceBarcode: () => void;
filterByResourceType: (selected: ComboboxEntry) => void;
}
});
+ this.handlePickupLibChange = ($event: number[]) => {
+ this.pickupLibIds = $event;
+ this.reservationsGrid.reloadGrid();
+ };
this.setStickyFilter = ($event: NgbTabChangeEvent) => {
this.store.setItem('eg.booking.manage.filter', $event.nextId);
--- /dev/null
+// TODO: Combine with the OU Selector from AdminPage to create a reusable component
+import {Component, EventEmitter, OnInit, Input, Output, ViewChild} from '@angular/core';
+import {AuthService} from '@eg/core/auth.service';
+import {IdlObject} from '@eg/core/idl.service';
+import {OrgService} from '@eg/core/org.service';
+
+@Component({
+ selector: 'eg-org-select-with-descendants',
+ template: ` <div class="input-group">
+ <div class="input-group-prepend">
+ <label [for]="domId" class="input-group-text">{{labelText}}</label>
+ </div>
+ <eg-org-select [domId]="domId" (onChange)="orgOnChange($event)"
+ [initialOrgId]="selectedOrg">
+ </eg-org-select>
+ </div>
+ <div class="form-check">
+ <input type="checkbox" class="form-check-input" id="{{domId}}-include-descendants"
+ (click)="emitArray()" [(ngModel)]="includeOrgDescendants">
+ <label class="form-check-label" for="{{domId}}-include-descendants" i18n>+ Descendants</label>
+ </div>`
+})
+export class OrgSelectWithDescendantsComponent implements OnInit {
+
+ @Input() labelText = 'Library';
+ @Output() ouChange: EventEmitter<number[]>;
+ domId: string;
+
+ selectedOrg: number;
+ includeOrgDescendants = true;
+
+ orgOnChange: ($event: IdlObject) => void;
+ emitArray: () => void;
+
+ constructor(
+ private auth: AuthService,
+ private org: OrgService
+ ) {
+ this.ouChange = new EventEmitter<number[]>();
+ }
+
+ ngOnInit() {
+ this.domId = 'org-select-' + Math.floor(Math.random() * 100000);
+ this.selectedOrg = this.auth.user().ws_ou();
+
+ this.orgOnChange = ($event: IdlObject) => {
+ this.selectedOrg = $event.id();
+ this.emitArray();
+ }
+
+ this.emitArray = () => {
+ if (this.includeOrgDescendants) {
+ this.ouChange.emit(this.org.descendants(this.selectedOrg, true));
+ } else {
+ this.ouChange.emit([this.selectedOrg]);
+ }
+ }
+ }
+
+}
+
@Input() patron: number;
@Input() resource: number;
@Input() resourceType: number;
+ @Input() pickupLibIds: number[];
@Input() status: 'pickupReady' | 'pickedUp' | 'returnReady' | 'returnedToday';
@Input() persistSuffix: string;
@Input() onlyCaptured = false;
if (this.resource) {
where['current_resource'] = this.resource;
}
+ if (this.pickupLibIds) {
+ where['pickup_lib'] = this.pickupLibIds;
+ }
if (this.onlyCaptured) {
where['capture_time'] = {'!=': null};
}