From 94729a0c79d1094daae5c1c7bc80805b50a23f75 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 28 Jun 2022 17:53:25 -0400 Subject: [PATCH] LP1840773 SCKO Angular Signed-off-by: Bill Erickson --- .../src/eg2/src/app/scko/checkout.component.html | 24 +++++++++++ .../src/eg2/src/app/scko/checkout.component.ts | 21 ++++++++++ Open-ILS/src/eg2/src/app/scko/items.component.ts | 18 +-------- Open-ILS/src/eg2/src/app/scko/scko.component.html | 23 ++++++----- Open-ILS/src/eg2/src/app/scko/scko.service.ts | 47 +++++++++++++++++++--- 5 files changed, 102 insertions(+), 31 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/scko/checkout.component.html b/Open-ILS/src/eg2/src/app/scko/checkout.component.html index 42df0f4cdd..a4029705b0 100644 --- a/Open-ILS/src/eg2/src/app/scko/checkout.component.html +++ b/Open-ILS/src/eg2/src/app/scko/checkout.component.html @@ -1,3 +1,9 @@ +
+
+
+ +
+
@@ -12,6 +18,24 @@ + + + + + + + + +
+ + + + {{cocirc.target_copy().barcode()}}{{getTitle(circ)}}{{getAuthor(circ)}}{{co.circ | egDueDate}}{{co.circ.renewal_remaining()}} + + Renewal + Checkout + +
diff --git a/Open-ILS/src/eg2/src/app/scko/checkout.component.ts b/Open-ILS/src/eg2/src/app/scko/checkout.component.ts index 89ff3d3d41..483978a43b 100644 --- a/Open-ILS/src/eg2/src/app/scko/checkout.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/checkout.component.ts @@ -1,6 +1,7 @@ import {Component, OnInit, ViewEncapsulation} from '@angular/core'; import {Router, ActivatedRoute, NavigationEnd} from '@angular/router'; import {AuthService} from '@eg/core/auth.service'; +import {IdlObject} from '@eg/core/idl.service'; import {SckoService} from './scko.service'; import {ServerStoreService} from '@eg/core/server-store.service'; @@ -18,5 +19,25 @@ export class SckoCheckoutComponent implements OnInit { ngOnInit() { } + + displayValue(circ: IdlObject, field: string): string { + const entry = + circ.target_copy().call_number().record().flat_display_entries() + .filter(e => e.name() === field)[0]; + + return entry ? entry.value() : ''; + } + + getTitle(circ: IdlObject): string { + if (!circ) { return ''; } + const copy = circ.target_copy(); + return this.displayValue(circ, 'title'); + } + + getAuthor(circ: IdlObject): string { + if (!circ) { return ''; } + const copy = circ.target_copy(); + return this.displayValue(circ, 'author'); + } } diff --git a/Open-ILS/src/eg2/src/app/scko/items.component.ts b/Open-ILS/src/eg2/src/app/scko/items.component.ts index a4e3d8f939..bd759e84f8 100644 --- a/Open-ILS/src/eg2/src/app/scko/items.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/items.component.ts @@ -9,14 +9,6 @@ import {SckoService} from './scko.service'; import {ServerStoreService} from '@eg/core/server-store.service'; import {PrintService} from '@eg/share/print/print.service'; -const CIRC_FLESH_DEPTH = 4; -const CIRC_FLESH_FIELDS = { - circ: ['target_copy'], - acp: ['call_number'], - acn: ['record'], - bre: ['flat_display_entries'] -}; - @Component({ templateUrl: 'items.component.html' }) @@ -51,15 +43,7 @@ export class SckoItemsComponent implements OnInit { .then(data => { const ids = data.out.concat(data.overdue).concat(data.long_overdue); - - return this.pcrud.search('circ', {id: ids}, { - flesh: CIRC_FLESH_DEPTH, - flesh_fields: CIRC_FLESH_FIELDS, - order_by : {circ : 'due_date'}, - - select: {bre : ['id']} - - }).pipe(tap(circ => { + return this.scko.getFleshedCircs(ids).pipe(tap(circ => { this.circs.push(circ); })).toPromise(); }); diff --git a/Open-ILS/src/eg2/src/app/scko/scko.component.html b/Open-ILS/src/eg2/src/app/scko/scko.component.html index 20da9a7526..97098d6bf4 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.component.html +++ b/Open-ILS/src/eg2/src/app/scko/scko.component.html @@ -44,17 +44,24 @@ text="Item was not found in the system. Try re-scanning the item."> - -No more renewals allowed for item {{barcode}} + + + - + + Item {{barcode}} was not found in the system. Try re-scanning the item. + + + + + + Item {{barcode}} is not allowed to circulate + + - text="The item cannot transit this far"> - - diff --git a/Open-ILS/src/eg2/src/app/scko/scko.service.ts b/Open-ILS/src/eg2/src/app/scko/scko.service.ts index 0cae316041..4dfdaecb9a 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.service.ts +++ b/Open-ILS/src/eg2/src/app/scko/scko.service.ts @@ -1,5 +1,6 @@ import {Injectable, EventEmitter} from '@angular/core'; import {Router, ActivatedRoute, NavigationEnd} from '@angular/router'; +import {Observable} from 'rxjs'; import {OrgService} from '@eg/core/org.service'; import {NetService} from '@eg/core/net.service'; import {AuthService} from '@eg/core/auth.service'; @@ -12,6 +13,7 @@ import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {PrintService} from '@eg/share/print/print.service'; import {AudioService} from '@eg/share/util/audio.service'; import {StringService} from '@eg/share/string/string.service'; +import {PcrudService} from '@eg/core/pcrud.service'; interface CheckoutContext { barcode: string; // item @@ -28,6 +30,19 @@ interface CheckoutContext { renewalFailure?: boolean; } +interface SessionCheckout { + circ: IdlObject, + ctx: CheckoutContext +} + +const CIRC_FLESH_DEPTH = 4; +const CIRC_FLESH_FIELDS = { + circ: ['target_copy'], + acp: ['call_number'], + acn: ['record'], + bre: ['flat_display_entries'] +}; + @Injectable({providedIn: 'root'}) export class SckoService { @@ -48,7 +63,7 @@ export class SckoService { overrideCheckoutEvents: string[] = []; blockStatuses: number[] = []; - sessionCheckouts: any[] = []; + sessionCheckouts: SessionCheckout[] = []; // We get this from the main scko component. logoutDialog: ConfirmDialogComponent; @@ -62,6 +77,7 @@ export class SckoService { private net: NetService, private evt: EventService, public auth: AuthService, + private pcrud: PcrudService, private printer: PrintService, private audio: AudioService, private strings: StringService, @@ -136,6 +152,19 @@ export class SckoService { }); } + getFleshedCircs(circIds: number[]): Observable { + return this.pcrud.search('circ', {id: circIds}, { + flesh: CIRC_FLESH_DEPTH, + flesh_fields: CIRC_FLESH_FIELDS, + order_by : {circ : 'due_date'}, + select: {bre : ['id']} + }); + } + + getFleshedCirc(circId: number): Promise { + return this.getFleshedCircs([circId]).toPromise(); + } + loadPatron(username: string, password?: string): Promise { this.resetPatron(); @@ -308,7 +337,7 @@ export class SckoService { } notifyPatron(ctx: CheckoutContext) { - console.debug("notifyPatron()", ctx); + console.debug('notifyPatron(): ', ctx); this.statusDisplayText = ''; @@ -316,6 +345,8 @@ export class SckoService { this.focusBarcode.emit(); + // TODO on success tell the summary to update its numbers. + if (this.alertAudio && ctx.alertSound) { this.audio.play(ctx.alertSound); } @@ -364,7 +395,13 @@ export class SckoService { if (evt.textcode === 'SUCCESS') { ctx.displayText = `scko.${action}.success`; ctx.alertSound = `success.scko.${action}`; - return Promise.resolve(ctx); + + return this.getFleshedCirc(payload.circ.id()).then( + circ => { + this.sessionCheckouts.push({circ: circ, ctx: ctx}); + return ctx; + } + ); } if (evt.textcode === 'OPEN_CIRCULATION_EXISTS' && action === 'checkout') { @@ -420,7 +457,7 @@ export class SckoService { [].concat(ctx.result).some(res => { if (!this.overrideCheckoutEvents.includes(res.textcode)) { - console.debug("We are not configured to override", res.textcode); + console.debug('We are not configured to override', res.textcode); lastErrorText = this.getErrorDisplyText(this.evt.parse(res)); return override = false; } @@ -481,7 +518,7 @@ export class SckoService { default: if (evt.payload && evt.payload.fail_part) { return 'scko.error.' + - evt.payload.fail_part.replace(/\./g, "_"); + evt.payload.fail_part.replace(/\./g, '_'); } } -- 2.11.0