LP1904036 Tracking/showing recent patrons
authorBill Erickson <berickxx@gmail.com>
Thu, 29 Apr 2021 21:00:56 +0000 (17:00 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:33 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/circ/patron/last.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.module.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/patron.service.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/resolver.service.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/routing.module.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 (file)
index 0000000..943c840
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+<div class="row mt-3" *ngIf="noRecents">
+  <div class="col-lg-6 offset-lg-3 alert alert-warning" i18n>
+    No patrons recently accessed
+  </div>
+</div>
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 (file)
index 0000000..51f6496
--- /dev/null
@@ -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;
+        }
+    }
+}
index 2d7d490..040e5d7 100644 (file)
@@ -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
index c7948e0..ac31438 100644 (file)
@@ -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<any> {
+
+        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<any> {
index 2bb8563..47e6f79 100644 (file)
@@ -33,6 +33,7 @@ export class PatronResolver implements Resolve<Promise<any[]>> {
           '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',
index 4e4e142..04fec6b 100644 (file)
@@ -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}