<ng-template ngbNavContent>
<div class="">
<eg-patron-search
+ [patronIds]="recentPatronIds()"
[startWithSearch]="context.lastPatronSearch"
(searchFired)="patronSearchFired($event)"
(selectionChange)="patronSelectionChange($event)"
import {AuthService} from '@eg/core/auth.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {EventService} from '@eg/core/event.service';
+import {StoreService} from '@eg/core/store.service';
import {ServerStoreService} from '@eg/core/server-store.service';
import {PatronService} from '@eg/staff/share/patron/patron.service';
import {PatronContextService, BillGridEntry} from './patron.service';
billingHistoryTab: string;
showSummary = true;
loading = true;
+ showRecentPatrons = false;
/* eg-patron-edit is unable to find #editorToolbar directly
* within the template. Adding a ref here allows it to
private auth: AuthService,
private pcrud: PcrudService,
private evt: EventService,
- private store: ServerStoreService,
+ private store: StoreService,
+ private serverStore: ServerStoreService,
public patronService: PatronService,
public context: PatronContextService
) {}
fetchSettings(): Promise<any> {
- return this.store.getItemBatch([
+ return this.serverStore.getItemBatch([
'eg.circ.patron.summary.collapse'
]).then(prefs => {
this.showSummary = !prefs['eg.circ.patron.summary.collapse'];
});
}
+ recentPatronIds(): number[] {
+ if (this.patronTab === 'search' && this.showRecentPatrons) {
+ return this.store.getLoginSessionItem('eg.circ.recent_patrons') || [];
+ } else {
+ return null;
+ }
+ }
+
watchForTabChange() {
+ this.route.data.subscribe(data => {
+ this.showRecentPatrons = (data && data.showRecentPatrons);
+ });
+
this.route.paramMap.subscribe((params: ParamMap) => {
this.patronTab = params.get('tab') || 'search';
this.patronId = +params.get('id');
}
toggleSummaryPane() {
- this.store.setItem( // collapse is the opposite of show
+ this.serverStore.setItem( // collapse is the opposite of show
'eg.circ.patron.summary.collapse', this.showSummary);
this.showSummary = !this.showSummary;
}
.then(p => this.summary = new PatronSummary(p))
.then(_ => this.getPatronStats(id))
.then(_ => this.compileAlerts())
- .then(_ => this.addRecentPatron())
+ .then(_ => this.addRecentPatron());
}
addRecentPatron(): Promise<any> {
component: PatronComponent,
resolve: {resolver : PatronResolver}
}, {
+ path: 'search/recents',
+ component: PatronComponent,
+ resolve: {resolver : PatronResolver},
+ data: {showRecentPatrons: true}
+ }, {
path: 'bcsearch',
component: BcSearchComponent
}, {
import {Component, Input, Output, OnInit, AfterViewInit,
EventEmitter, ViewChild} from '@angular/core';
import {ActivatedRoute, ParamMap} from '@angular/router';
-import {Observable, of} from 'rxjs';
-import {map} from 'rxjs/operators';
+import {Observable, of, from} from 'rxjs';
+import {map, concatMap} from 'rxjs/operators';
import {IdlObject} from '@eg/core/idl.service';
import {NetService} from '@eg/core/net.service';
import {AuthService} from '@eg/core/auth.service';
startWithFired = false;
@Input() startWithSearch: PatronSearch;
+ // If set, load a batch of patrons by ID.
+ @Input() patronIds: number[];
+
// Fires on dbl-click or Enter while one or more search result
// rows are selected.
@Output() patronsActivated: EventEmitter<any>;
let observable: Observable<IdlObject>;
- if (this.search.id) {
- observable = this.searchById();
+ if (this.patronIds) {
+ observable = this.searchById(this.patronIds);
+ this.patronIds = null;
+ } else if (this.search.id) {
+ observable = this.searchById([this.search.id]);
} else {
observable = this.searchByForm(pager, sort);
}
);
}
- searchById(): Observable<IdlObject> {
- return this.net.request(
- 'open-ils.actor',
- 'open-ils.actor.user.fleshed.retrieve',
- this.auth.token(), this.search.id, DEFAULT_FLESH
- );
+ searchById(patronIds: number[]): Observable<IdlObject> {
+ return from(patronIds).pipe(concatMap(id => {
+ return this.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.fleshed.retrieve',
+ this.auth.token(), id, DEFAULT_FLESH
+ );
+ }));
}
compileSort(sort: any[]): string[] {