From 75a48f94aa55400426457deea0b6ce25abfe6dca Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Mon, 8 Apr 2019 14:31:32 -0700 Subject: [PATCH] LP1816475: Make those org selects work Signed-off-by: Jane Sandberg --- .../eg2/src/app/staff/booking/booking.module.ts | 2 + .../booking/create-reservation.component.html | 15 +----- .../staff/booking/create-reservation.component.ts | 15 ++++-- .../booking/manage-reservations.component.html | 23 ++------ .../staff/booking/manage-reservations.component.ts | 6 +++ .../org-select-with-descendants.component.ts | 61 ++++++++++++++++++++++ .../staff/booking/reservations-grid.component.ts | 4 ++ 7 files changed, 91 insertions(+), 35 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/booking/org-select-with-descendants.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/booking/booking.module.ts b/Open-ILS/src/eg2/src/app/staff/booking/booking.module.ts index 079a190f33..b50654c5b3 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/booking.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/booking.module.ts @@ -3,6 +3,7 @@ import {StaffCommonModule} from '@eg/staff/common.module'; 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'; @@ -22,6 +23,7 @@ import {PatronService} from '@eg/staff/share/patron.service'; CreateReservationComponent, ManageReservationsComponent, NoTimezoneSetComponent, + OrgSelectWithDescendantsComponent, PickupComponent, PullListComponent, ReservationsGridComponent, 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 ce0d0bca36..bcb37261c8 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 @@ -4,19 +4,8 @@
-
-
- -
- - -
-
-
-
- - -
+ +
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 c3f821ff13..4454b7f9d0 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 @@ -35,8 +35,11 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { selectedAttributes: number[] = []; multiday = false; handleDateChange: ($event: Date) => void; + handleOwnerChange: ($event: number[]) => void; resourceAvailabilityIcon: (row: any) => GridRowFlairEntry; + owningLibraries: number[] = []; + patronBarcode: string; patronId: number; resourceBarcode: string; @@ -109,6 +112,8 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { 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') @@ -186,6 +191,10 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { this.fetchData(); }); }; + this.handleOwnerChange = ($event: number[]) => { + this.owningLibraries = $event; + this.fetchData(); + } this.handleMultiDayReservation = () => { this.multiday = true; @@ -343,12 +352,12 @@ export class CreateReservationComponent implements OnInit, AfterViewInit { 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; } diff --git a/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.html b/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.html index 42ec2cab65..9926147907 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.html +++ b/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.html @@ -4,25 +4,10 @@
-
-
- -
- - -
-
-
-
- - -
-
- - -
+ +
-
+

Filter reservations

@@ -84,5 +69,5 @@
- + diff --git a/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts index da395737e0..5d225eba7c 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/manage-reservations.component.ts @@ -16,6 +16,7 @@ import {ToastService} from '@eg/share/toast/toast.service'; }) export class ManageReservationsComponent implements OnInit { + pickupLibIds: number[]; patronBarcode: string; patronId: number; resourceBarcode: string; @@ -25,6 +26,7 @@ export class ManageReservationsComponent implements OnInit { @ViewChild('reservationsGrid') reservationsGrid: ReservationsGridComponent; + handlePickupLibChange: ($event: number[]) => void; filterByCurrentPatronBarcode: () => void; filterByCurrentResourceBarcode: () => void; filterByResourceType: (selected: ComboboxEntry) => void; @@ -84,6 +86,10 @@ export class ManageReservationsComponent implements OnInit { } }); + this.handlePickupLibChange = ($event: number[]) => { + this.pickupLibIds = $event; + this.reservationsGrid.reloadGrid(); + }; this.setStickyFilter = ($event: NgbTabChangeEvent) => { this.store.setItem('eg.booking.manage.filter', $event.nextId); diff --git a/Open-ILS/src/eg2/src/app/staff/booking/org-select-with-descendants.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/org-select-with-descendants.component.ts new file mode 100644 index 0000000000..ffb2d39258 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/booking/org-select-with-descendants.component.ts @@ -0,0 +1,61 @@ +// 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: `
+
+ +
+ + +
+
+ + +
` +}) +export class OrgSelectWithDescendantsComponent implements OnInit { + + @Input() labelText = 'Library'; + @Output() ouChange: EventEmitter; + domId: string; + + selectedOrg: number; + includeOrgDescendants = true; + + orgOnChange: ($event: IdlObject) => void; + emitArray: () => void; + + constructor( + private auth: AuthService, + private org: OrgService + ) { + this.ouChange = new EventEmitter(); + } + + 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]); + } + } + } + +} + diff --git a/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts b/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts index 0efad5d446..28a30da79f 100644 --- a/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/booking/reservations-grid.component.ts @@ -30,6 +30,7 @@ export class ReservationsGridComponent implements OnInit { @Input() patron: number; @Input() resource: number; @Input() resourceType: number; + @Input() pickupLibIds: number[]; @Input() status: 'pickupReady' | 'pickedUp' | 'returnReady' | 'returnedToday'; @Input() persistSuffix: string; @Input() onlyCaptured = false; @@ -105,6 +106,9 @@ export class ReservationsGridComponent implements OnInit { if (this.resource) { where['current_resource'] = this.resource; } + if (this.pickupLibIds) { + where['pickup_lib'] = this.pickupLibIds; + } if (this.onlyCaptured) { where['capture_time'] = {'!=': null}; } -- 2.11.0