From e188ab372193872117fd1f1699c7f5bb2b2b15b3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 30 Jun 2022 11:10:24 -0400 Subject: [PATCH] LP1840773 SCKO Angular Signed-off-by: Bill Erickson --- .../src/eg2/src/app/scko/checkout.component.html | 6 +- .../src/eg2/src/app/scko/checkout.component.ts | 20 ------- Open-ILS/src/eg2/src/app/scko/items.component.html | 4 +- Open-ILS/src/eg2/src/app/scko/items.component.ts | 30 +--------- Open-ILS/src/eg2/src/app/scko/scko.component.html | 4 +- Open-ILS/src/eg2/src/app/scko/scko.service.ts | 33 +++++++---- .../src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm | 8 ++- .../src/sql/Pg/upgrade/YYYY.data.scko-angular.sql | 66 +++++++++++++++++++--- 8 files changed, 99 insertions(+), 72 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 a4029705b0..bf50486215 100644 --- a/Open-ILS/src/eg2/src/app/scko/checkout.component.html +++ b/Open-ILS/src/eg2/src/app/scko/checkout.component.html @@ -24,9 +24,9 @@ - {{cocirc.target_copy().barcode()}} - {{getTitle(circ)}} - {{getAuthor(circ)}} + {{co.circ.target_copy().barcode()}} + {{scko.getCircTitle(co.circ)}} + {{scko.getCircAuthor(co.circ)}} {{co.circ | egDueDate}} {{co.circ.renewal_remaining()}} 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 483978a43b..5afc1f6f29 100644 --- a/Open-ILS/src/eg2/src/app/scko/checkout.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/checkout.component.ts @@ -19,25 +19,5 @@ 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.html b/Open-ILS/src/eg2/src/app/scko/items.component.html index 28daf25bd7..c4a247bedf 100644 --- a/Open-ILS/src/eg2/src/app/scko/items.component.html +++ b/Open-ILS/src/eg2/src/app/scko/items.component.html @@ -25,8 +25,8 @@ {{circ.target_copy().barcode()}} - {{getTitle(circ)}} - {{getAuthor(circ)}} + {{scko.getCircTitle(circ)}} + {{scko.getCircAuthor(circ)}} {{circ | egDueDate}} {{circ.renewal_remaining()}} 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 9da559ea55..7a662a5245 100644 --- a/Open-ILS/src/eg2/src/app/scko/items.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/items.component.ts @@ -49,40 +49,14 @@ export class SckoItemsComponent implements OnInit { }); } - // TODO use scko versions - isPrecat(copy: IdlObject): boolean { - return Number(copy.id()) === -1; - } - - 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 { - const copy = circ.target_copy(); - if (this.isPrecat(copy)) { return copy.dummy_title(); } - return this.displayValue(circ, 'title'); - } - - getAuthor(circ: IdlObject): string { - const copy = circ.target_copy(); - if (this.isPrecat(copy)) { return copy.dummy_author(); } - return this.displayValue(circ, 'author'); - } - printList() { const data = this.circs.map(c => { return { circ: c, copy: c.target_copy(), - title: this.getTitle(c), - author: this.getAuthor(c) + title: this.scko.getCircTitle(c), + author: this.scko.getCircAuthor(c) }; }); 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 5d6ce82248..1ae367dffe 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.component.html +++ b/Open-ILS/src/eg2/src/app/scko/scko.component.html @@ -39,6 +39,7 @@ + @@ -102,5 +103,6 @@ text="The item's circulation library does not fulfill holds"> text="The system could not find this patron"> - + 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 26627eefcc..9b3ceaf287 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.service.ts +++ b/Open-ILS/src/eg2/src/app/scko/scko.service.ts @@ -48,14 +48,15 @@ export class SckoService { // Currently active patron account object. patronSummary: PatronSummary; + statusDisplayText = ''; + statusDisplaySuccess: boolean; + barcodeRegex: RegExp; patronPasswordRequired = false; patronIdleTimeout: number; patronTimeoutId: number; logoutWarningTimeout = 20; logoutWarningTimerId: number; - statusDisplayText = ''; - statusDisplaySuccess: boolean; alertAudio = false; alertPopup = false; @@ -92,6 +93,7 @@ export class SckoService { } resetPatron() { + this.statusDisplayText = ''; this.patronSummary = null; this.sessionCheckouts = []; } @@ -278,6 +280,9 @@ export class SckoService { checkout(barcode: string, override?: boolean): Promise { this.resetPatronTimeout(); + barcode = (barcode || '').trim(); + if (!barcode) { return Promise.resolve(); } + let method = 'open-ils.circ.checkout.full'; if (override) { method += '.override'; } @@ -419,9 +424,15 @@ export class SckoService { const age = this.orgSettings['circ.checkout_auto_renew_age']; if (!age || (age && ctx.payload.auto_renew)) { - ctx.previousCirc = ctx.payload.old_circ; ctx.renew = true; - return Promise.resolve(ctx); + + // Flesh the previous circ so we can show the title, + // etc. in the receipt. + return this.getFleshedCirc(ctx.payload.old_circ.id()) + .then(oldCirc => { + ctx.previousCirc = oldCirc; + return ctx; + }); } } @@ -507,6 +518,8 @@ export class SckoService { getErrorDisplyText(evt: EgEvent): string { switch (evt.textcode) { + case 'PATRON_EXCEEDS_CHECKOUT_COUNT': + return 'scko.error.patron_exceeds_checkout_count'; case 'MAX_RENEWALS_REACHED': return 'scko.error.max_renewals'; case 'ITEM_NOT_CATALOGED': @@ -620,21 +633,21 @@ export class SckoService { sub.unsubscribe(); // Give the print operation just a bit more time after // the data is passed to the printer just to be safe. - setTimeout(() => resolve, 1000); + setTimeout(() => resolve(null), 1000); }); const data = this.sessionCheckouts.map(c => { + const circ = c.circ || c.ctx.previousCirc; return { checkout: c, barcode: c.ctx.barcode, - circ: c.circ, - copy: c.circ ? c.circ.target_copy() : null, - title: this.getCircTitle(c.circ), - author: this.getCircAuthor(c.circ) + circ: circ, + copy: circ ? circ.target_copy() : null, + title: this.getCircTitle(circ), + author: this.getCircAuthor(circ) }; }); - this.printer.print({ templateName: 'scko_checkouts', contextData: { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm index 4454221f43..099cb4bbb0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm @@ -81,7 +81,13 @@ sub handler { my $staff_org = $e->retrieve_actor_org_unit([ $e->requestor->ws_ou, { flesh => 1, - flesh_fields => {aou => ['billing_address', 'mailing_address']} + flesh_fields => { + aou => [ + 'billing_address', + 'mailing_address', + 'hours_of_operation' + ] + } } ]); diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql index a2dc616a3a..fd87f29b5a 100644 --- a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql @@ -144,10 +144,17 @@ UPDATE config.print_template SET template = $TEMPLATE$ USE date; SET user = template_data.user; SET checkouts = template_data.checkouts; + SET lib = staff_org; + SET hours = lib.hours_of_operation; + SET lib_addr = staff_org.billing_address || staff_org.mailing_address; -%]
[% date.format(date.now, '%x %r') %]
+
[% lib.name %]
+
[% lib_addr.street1 %] [% lib_addr.street2 %]
+
[% lib_addr.city %], [% lib_addr.state %] [% lib_addr.post_code %]
+
[% lib.phone %]

[% user.pref_family_name || user.family_name %], @@ -158,16 +165,61 @@ UPDATE config.print_template SET template = $TEMPLATE$
  • [% checkout.title %]
    Barcode: [% checkout.barcode %]
    -
    Due Date: [% - IF checkout.circ; - date.format(helpers.format_date( - checkout.circ.due_date, staff_org_timezone), '%x %r') - END; - %] -
    + + [% IF checkout.ctx.renewalFailure %] +
    Renewal Failed
    + [% END %] + +
    Due Date: [% date.format(helpers.format_date( + checkout.circ.due_date, staff_org_timezone), '%x') %]
  • [% END %] + +
    + Library Hours + [%- + BLOCK format_time; + date.format(time _ ' 1/1/1000', format='%I:%M %p'); + END + -%] +
    + Monday + [% PROCESS format_time time = hours.dow_0_open %] + [% PROCESS format_time time = hours.dow_0_close %] +
    +
    + Tuesday + [% PROCESS format_time time = hours.dow_1_open %] + [% PROCESS format_time time = hours.dow_1_close %] +
    +
    + Wednesday + [% PROCESS format_time time = hours.dow_2_open %] + [% PROCESS format_time time = hours.dow_2_close %] +
    +
    + Thursday + [% PROCESS format_time time = hours.dow_3_open %] + [% PROCESS format_time time = hours.dow_3_close %] +
    +
    + Friday + [% PROCESS format_time time = hours.dow_4_open %] + [% PROCESS format_time time = hours.dow_4_close %] +
    +
    + Saturday + [% PROCESS format_time time = hours.dow_5_open %] + [% PROCESS format_time time = hours.dow_5_close %] +
    +
    + Sunday + [% PROCESS format_time time = hours.dow_6_open %] + [% PROCESS format_time time = hours.dow_6_close %] +
    +
    +
    $TEMPLATE$ WHERE name = 'scko_checkouts'; -- 2.11.0