<eg-staff-banner bannerText="Staff Catalog (Experimental)" i18n-bannerText>
</eg-staff-banner>
+
+<ng-container *ngIf="holdForUser()">
+ <div class="row border border-info mb-2 pt-1 pb-1">
+ <div class="col-lg-10 offset-lg-1 d-flex justify-content-center">
+ <span class="mt-2" i18n>
+ Placing hold for patron
+ <a href="/eg/staff/circ/patron/{{holdForUser().id()}}/holds">
+ {{holdForUser().family_name()}}, {{holdForUser().first_given_name()}}
+ </a>.
+ </span>
+ </div>
+ <div class="col-lg-1">
+ <button class="btn btn-info btn-sm"
+ (click)="clearHoldPatron()" i18n>Clear</button>
+ </div>
+ </div>
+</ng-container>
+
<!-- search form sits atop every catalog page -->
<eg-catalog-search-form></eg-catalog-search-form>
import {Component, OnInit} from '@angular/core';
+import {IdlObject} from '@eg/core/idl.service';
import {StaffCatalogService} from './catalog.service';
import {BasketService} from '@eg/share/catalog/basket.service';
// reset and updated as needed to apply new search parameters.
this.staffCat.createContext();
}
+
+ // Returns the 'au' object for the patron who we are
+ // trying to place a hold for.
+ holdForUser(): IdlObject {
+ return this.staffCat.holdForUser;
+ }
+
+ clearHoldPatron() {
+ this.staffCat.holdForUser = null;
+ this.staffCat.holdForBarcode = null;
+ }
}
import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service';
import {CatalogSearchContext} from '@eg/share/catalog/search-context';
import {BibRecordSummary} from '@eg/share/catalog/bib-record.service';
+import {PatronService} from '@eg/staff/share/patron/patron.service';
/**
* Shared bits needed by the staff version of the catalog.
// Default search tab
defaultTab: string;
+ // Patron barcode we hope to place a hold for.
+ holdForBarcode: string;
+ // User object for above barcode.
+ holdForUser: IdlObject;
+
// Cache the currently selected detail record (i.g. catalog/record/123)
// summary so the record detail component can avoid duplicate fetches
// during record tab navigation.
private route: ActivatedRoute,
private org: OrgService,
private cat: CatalogService,
+ private patron: PatronService,
private catUrl: CatalogUrlService
) { }
this.searchContext =
this.catUrl.fromUrlParams(this.route.snapshot.queryParamMap);
+ this.holdForBarcode = this.route.snapshot.queryParams['holdForBarcode'];
+
+ if (this.holdForBarcode) {
+ this.patron.getByBarcode(this.holdForBarcode)
+ .then(user => this.holdForUser = user);
+ }
+
this.searchContext.org = this.org; // service, not searchOrg
this.searchContext.isStaff = true;
this.applySearchDefaults();
import {HoldsService, HoldRequest,
HoldRequestTarget} from '@eg/staff/share/holds/holds.service';
import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
+import {PatronService} from '@eg/staff/share/patron/patron.service';
import {PatronSearchDialogComponent
} from '@eg/staff/share/patron/search-dialog.component';
private cat: CatalogService,
private staffCat: StaffCatalogService,
private holds: HoldsService,
+ private patron: PatronService,
private perm: PermService
) {
this.holdContexts = [];
this.holdTargets = this.route.snapshot.queryParams['target'];
this.holdFor = this.route.snapshot.queryParams['holdFor'] || 'patron';
+ if (this.staffCat.holdForBarcode) {
+ this.holdFor = 'patron';
+ this.userBarcode = this.staffCat.holdForBarcode;
+ }
+
if (!Array.isArray(this.holdTargets)) {
this.holdTargets = [this.holdTargets];
}
return ctx;
});
- if (this.holdFor === 'staff') {
+ if (this.holdFor === 'staff' || this.userBarcode) {
this.holdForChanged();
}
this.user = null;
this.currentUserBarcode = this.userBarcode;
+ this.getUser();
+ }
- this.net.request(
- 'open-ils.actor',
- 'open-ils.actor.get_barcodes',
- this.auth.token(), this.auth.user().ws_ou(),
- 'actor', this.userBarcode
- ).subscribe(barcodes => {
-
- // Use the first successful barcode response.
- // TODO: What happens when there are multiple responses?
- // Use for-loop for early exit since we have async
- // action within the loop.
- for (let i = 0; i < barcodes.length; i++) {
- const bc = barcodes[i];
- if (!this.evt.parse(bc)) {
- this.getUser(bc.id);
- break;
- }
- }
+ getUser(id?: number) {
+ const flesh = {flesh: 1, flesh_fields: {au: ['settings']}};
+
+ const promise = id ? this.patron.getById(id, flesh) :
+ this.patron.getByBarcode(this.userBarcode);
+
+ promise.then(user => {
+ this.user = user;
+ this.applyUserSettings();
});
}
this.pickupLib = this.requestor.ws_ou();
}
- getUser(id: number) {
- this.pcrud.retrieve('au', id, {flesh: 1, flesh_fields: {au: ['settings']}})
- .subscribe(user => {
- this.user = user;
- this.applyUserSettings();
- });
- }
-
applyUserSettings() {
if (!this.user || !this.user.settings()) { return; }
import {Injectable} from '@angular/core';
+import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
+import {EventService} from '@eg/core/event.service';
+import {PcrudService} from '@eg/core/pcrud.service';
import {AuthService} from '@eg/core/auth.service';
import {Observable} from 'rxjs';
export class PatronService {
constructor(
private net: NetService,
+ private evt: EventService,
+ private pcrud: PcrudService,
private auth: AuthService
) {}
'actor', barcode.trim());
}
+ getByBarcode(barcode: string, pcrudOps?: any): Promise<IdlObject> {
+ return this.bcSearch(barcode).toPromise()
+ .then(barcodes => {
+
+ // Use the first successful barcode response.
+ // TODO: What happens when there are multiple responses?
+ // Use for-loop for early exit since we have async
+ // action within the loop.
+ for (let i = 0; i < barcodes.length; i++) {
+ const bc = barcodes[i];
+ if (!this.evt.parse(bc)) {
+ return this.getById(bc.id);
+ }
+ }
+
+ return null;
+ });
+ }
+
+ getById(id: number, pcrudOps?: any): Promise<IdlObject> {
+ return this.pcrud.retrieve('au', id, pcrudOps).toPromise();
+ }
+
}
<!-- catalog view for holds placement -->
+<!-- Replaced with Angular catalog link
<div ng-if="placing_hold">
<eg-embed-frame url="catalog_url" handlers="handlers"
onchange="handle_page"></eg-embed-frame>
</div>
+-->
}
$scope.place_hold = function() {
- $location.path($location.path() + '/create');
+ $window.location.href = '/eg2/staff/catalog?holdForBarcode=' +
+ encodeURIComponent(patronSvc.current.card().barcode());
+
+ //$location.path($location.path() + '/create');
}
// when the detail hold is fetched (and updated), update the bib