From 52b6784eabf109b1ab533b3a9c2709d6c649e324 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 29 Apr 2021 17:00:56 -0400 Subject: [PATCH] LP1904036 Tracking/showing recent patrons Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- .../src/app/staff/circ/patron/last.component.html | 7 ++++++ .../src/app/staff/circ/patron/last.component.ts | 28 +++++++++++++++++++++ .../eg2/src/app/staff/circ/patron/patron.module.ts | 2 ++ .../src/app/staff/circ/patron/patron.service.ts | 29 +++++++++++++++++++++- .../src/app/staff/circ/patron/resolver.service.ts | 1 + .../src/app/staff/circ/patron/routing.module.ts | 5 ++++ 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.html new file mode 100644 index 0000000000..943c840546 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.html @@ -0,0 +1,7 @@ + + +
+
+ No patrons recently accessed +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.ts new file mode 100644 index 0000000000..51f649691c --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.ts @@ -0,0 +1,28 @@ +import {Component, Input, OnInit, AfterViewInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; +import {StoreService} from '@eg/core/store.service'; + +@Component({ + templateUrl: 'last.component.html' +}) +export class LastPatronComponent implements OnInit { + noRecents = false; + + constructor( + private router: Router, + private route: ActivatedRoute, + private store: StoreService + ) {} + + ngOnInit() { + + const ids = this.store.getLoginSessionItem('eg.circ.recent_patrons'); + if (ids && ids[0]) { + this.noRecents = false; + this.router.navigate([`/staff/circ/patron/${ids[0]}/checkout`]); + } else { + this.noRecents = true; + } + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts index 2d7d490023..040e5d7127 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts @@ -33,6 +33,7 @@ import {PatronMessagesComponent} from './messages.component'; import {PatronPermsComponent} from './perms.component'; import {BillingHistoryComponent} from './billing-history.component'; import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module'; +import {LastPatronComponent} from './last.component'; @NgModule({ declarations: [ @@ -54,6 +55,7 @@ import {WorkLogModule} from '@eg/staff/share/worklog/worklog.module'; RegisterPatronComponent, PatronStatCatsComponent, PatronPermsComponent, + LastPatronComponent, PatronBarcodesDialogComponent, SecondaryGroupsDialogComponent, HoldNotifyUpdateDialogComponent 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 c7948e015c..ac31438e82 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 @@ -7,6 +7,7 @@ import {PatronService, PatronSummary, PatronStats, PatronAlerts } from '@eg/staff/share/patron/patron.service'; import {PatronSearch} from '@eg/staff/share/patron/search.component'; import {StoreService} from '@eg/core/store.service'; +import {ServerStoreService} from '@eg/core/server-store.service'; import {CircService, CircDisplayInfo} from '@eg/staff/share/circ/circ.service'; export interface BillGridEntry extends CircDisplayInfo { @@ -55,10 +56,13 @@ export class PatronContextService { // These should persist tab changes checkouts: CircGridEntry[] = []; + maxRecentPatrons = 1; + settingsCache: {[key: string]: any} = {}; constructor( private store: StoreService, + private serverStore: ServerStoreService, private org: OrgService, private circ: CircService, public patrons: PatronService @@ -84,7 +88,30 @@ export class PatronContextService { return this.patrons.getFleshedById(id, PATRON_FLESH_FIELDS) .then(p => this.summary = new PatronSummary(p)) .then(_ => this.getPatronStats(id)) - .then(_ => this.compileAlerts()); + .then(_ => this.compileAlerts()) + .then(_ => this.addRecentPatron()) + } + + addRecentPatron(): Promise { + + return this.serverStore.getItem('ui.staff.max_recent_patrons') + .then(sets => { + const num = sets['ui.staff.max_recent_patrons']; + if (num) { this.maxRecentPatrons = num; } + + const patrons: number[] = + this.store.getLoginSessionItem('eg.circ.recent_patrons') || []; + + patrons.splice(0, 0, this.summary.id); // put this user at front + patrons.splice(this.maxRecentPatrons, 1); // remove excess + + // remove any other occurrences of this user, which may have been + // added before the most recent user. + const idx = patrons.indexOf(this.summary.id, 1); + if (idx > 0) { patrons.splice(idx, 1); } + + this.store.setLoginSessionItem('eg.circ.recent_patrons', patrons); + }); } getPatronStats(id: number): Promise { diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts index 2bb85639aa..47e6f79fb5 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts @@ -33,6 +33,7 @@ export class PatronResolver implements Resolve> { 'eg.circ.patron.summary.collapse', 'circ.do_not_tally_claims_returned', 'circ.tally_lost', + 'ui.staff.max_recent_patrons', 'ui.staff.require_initials.patron_standing_penalty', 'ui.admin.work_log.max_entries', 'ui.admin.patron_log.max_entries', 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 4e4e142f2a..04fec6bffc 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 @@ -5,6 +5,7 @@ import {BcSearchComponent} from './bcsearch.component'; import {PatronResolver} from './resolver.service'; import {TestPatronPasswordComponent} from './test-password.component'; import {RegisterPatronComponent} from './register.component'; +import {LastPatronComponent} from './last.component'; import {CanDeactivateGuard} from '@eg/share/util/can-deactivate.guard'; const routes: Routes = [{ @@ -20,6 +21,10 @@ const routes: Routes = [{ component: RegisterPatronComponent, resolve: {resolver : PatronResolver} }, { + path: 'last', + component: LastPatronComponent, + resolve: {resolver : PatronResolver} + }, { path: 'register/clone/:cloneId', component: RegisterPatronComponent, resolve: {resolver : PatronResolver} -- 2.11.0