From: Bill Erickson Date: Thu, 29 Apr 2021 21:24:58 +0000 (-0400) Subject: LP1904036 Tracking/showing recent patrons X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4e48a2a92328a9bebd5240d8de8d0af46c386a74;p=Evergreen.git LP1904036 Tracking/showing recent patrons Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html index f2c2aa7038..9dfc6b3ef0 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.component.html @@ -226,6 +226,7 @@
{ - 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'); @@ -188,7 +203,7 @@ export class PatronComponent implements OnInit, AfterViewInit { } 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; } diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts index ac31438e82..41940b68a0 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts @@ -89,7 +89,7 @@ export class PatronContextService { .then(p => this.summary = new PatronSummary(p)) .then(_ => this.getPatronStats(id)) .then(_ => this.compileAlerts()) - .then(_ => this.addRecentPatron()) + .then(_ => this.addRecentPatron()); } addRecentPatron(): Promise { diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/routing.module.ts index 04fec6bffc..4d49e4faea 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/routing.module.ts @@ -40,6 +40,11 @@ const routes: Routes = [{ component: PatronComponent, resolve: {resolver : PatronResolver} }, { + path: 'search/recents', + component: PatronComponent, + resolve: {resolver : PatronResolver}, + data: {showRecentPatrons: true} + }, { path: 'bcsearch', component: BcSearchComponent }, { diff --git a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts index 67b7369728..8ca36a9aef 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/patron/search.component.ts @@ -1,8 +1,8 @@ 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'; @@ -58,6 +58,9 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { 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; @@ -162,8 +165,11 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { let observable: Observable; - 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); } @@ -223,12 +229,14 @@ export class PatronSearchComponent implements OnInit, AfterViewInit { ); } - searchById(): Observable { - 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 { + 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[] {