From dfbfc02e454e0b2c10d349232aeedc21d4f5861f Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 23 Jun 2022 17:02:42 -0400 Subject: [PATCH] LP1840773 SCKO Angular Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/scko/holds.component.html | 6 ++ Open-ILS/src/eg2/src/app/scko/holds.component.ts | 13 +++ Open-ILS/src/eg2/src/app/scko/items.component.html | 6 ++ Open-ILS/src/eg2/src/app/scko/items.component.ts | 22 +++++ Open-ILS/src/eg2/src/app/scko/scko.service.ts | 13 +++ .../src/eg2/src/app/share/print/print.service.ts | 3 + .../src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm | 4 + .../src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm | 3 +- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 11 ++- .../src/sql/Pg/upgrade/YYYY.data.scko-angular.sql | 93 ++++++++++++++++++++++ 10 files changed, 172 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql diff --git a/Open-ILS/src/eg2/src/app/scko/holds.component.html b/Open-ILS/src/eg2/src/app/scko/holds.component.html index 0834559589..ff10e9bc7d 100644 --- a/Open-ILS/src/eg2/src/app/scko/holds.component.html +++ b/Open-ILS/src/eg2/src/app/scko/holds.component.html @@ -1,3 +1,9 @@ +
+
+
+ +
+
diff --git a/Open-ILS/src/eg2/src/app/scko/holds.component.ts b/Open-ILS/src/eg2/src/app/scko/holds.component.ts index 81ae44fb08..131cf73a23 100644 --- a/Open-ILS/src/eg2/src/app/scko/holds.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/holds.component.ts @@ -7,6 +7,7 @@ import {NetService} from '@eg/core/net.service'; import {IdlObject} from '@eg/core/idl.service'; import {SckoService} from './scko.service'; import {ServerStoreService} from '@eg/core/server-store.service'; +import {PrintService} from '@eg/share/print/print.service'; @Component({ templateUrl: 'holds.component.html' @@ -22,6 +23,7 @@ export class SckoHoldsComponent implements OnInit { private net: NetService, private auth: AuthService, private pcrud: PcrudService, + private printer: PrintService, public scko: SckoService ) {} @@ -60,6 +62,17 @@ export class SckoHoldsComponent implements OnInit { this.holds.push(holdData); }); } + + printList() { + this.printer.print({ + templateName: 'scko_holds', + contextData: { + holds: this.holds, + user: this.scko.patronSummary.patron + }, + printContext: 'default' + }); + } } 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 e861623116..28daf25bd7 100644 --- a/Open-ILS/src/eg2/src/app/scko/items.component.html +++ b/Open-ILS/src/eg2/src/app/scko/items.component.html @@ -1,3 +1,9 @@ +
+
+
+ +
+
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 9f2bf716d6..e9ceba159e 100644 --- a/Open-ILS/src/eg2/src/app/scko/items.component.ts +++ b/Open-ILS/src/eg2/src/app/scko/items.component.ts @@ -7,6 +7,7 @@ import {NetService} from '@eg/core/net.service'; import {IdlObject} from '@eg/core/idl.service'; 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 = { @@ -30,6 +31,7 @@ export class SckoItemsComponent implements OnInit { private net: NetService, private auth: AuthService, private pcrud: PcrudService, + private printer: PrintService, public scko: SckoService ) {} @@ -87,5 +89,25 @@ export class SckoItemsComponent implements OnInit { 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) + }; + }); + + this.printer.print({ + templateName: 'scko_items_out', + contextData: {checkouts: data}, + printContext: 'default' + }); + } } + + 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 9927903c70..2268edfdc3 100644 --- a/Open-ILS/src/eg2/src/app/scko/scko.service.ts +++ b/Open-ILS/src/eg2/src/app/scko/scko.service.ts @@ -8,6 +8,7 @@ import {IdlService, IdlObject} from '@eg/core/idl.service'; import {StoreService} from '@eg/core/store.service'; import {PatronService, PatronSummary, PatronStats} from '@eg/staff/share/patron/patron.service'; import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; +import {PrintService} from '@eg/share/print/print.service'; @Injectable({providedIn: 'root'}) export class SckoService { @@ -33,6 +34,7 @@ export class SckoService { private net: NetService, private evt: EventService, public auth: AuthService, + private printer: PrintService, private patrons: PatronService, ) {} @@ -191,6 +193,17 @@ export class SckoService { this.patronSummary.stats.checkouts.overdue + this.patronSummary.stats.checkouts.long_overdue; } + + + /* + logout(receiptType: + this.printer.print({ + templateName: 'bills_current', + contextData: {xacts: rows}, + printContext: 'default' + }); + */ + } diff --git a/Open-ILS/src/eg2/src/app/share/print/print.service.ts b/Open-ILS/src/eg2/src/app/share/print/print.service.ts index 5723a4cfd9..e2d7a9767b 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.service.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.service.ts @@ -99,6 +99,9 @@ export class PrintService { } else if (this.status === 404) { console.error('No active template found: ', printReq); reject({notFound: true}); + } else { + console.error( + "Print template generator returned status: " + this.status); } reject({}); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm index dab85c0a19..aff703552f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm @@ -57,6 +57,10 @@ sub personality { # Instance-specific personality if ($app) { + # Reset everything in case this editor instance was + # previously used as a different personality. + delete $self->{session}; + $self->{app} = $app; $self->{personality} = $app; init(); } diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm index d678fb3962..a5931eff5f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm @@ -52,9 +52,10 @@ sub handler { # Requires staff login return Apache2::Const::FORBIDDEN - unless $e->checkauth && $e->requestor->wsid; + unless $e->checkauth && $e->allowed('STAFF_LOGIN'); # Let pcrud handle the authz + #$e->{app} = 'open-ils.pcrud'; $e->personality('open-ils.pcrud'); my $tmpl_owner = $cgi->param('template_owner') || $e->requestor->ws_ou; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index efcf20a9c2..9d22cd1cb7 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11226,7 +11226,16 @@ $$ SET udata = user_data.$idx -%]
  • -
    Title: [% udata.item_title %]
    +
  • + + + + + + + + +
    Author: [% udata.item_author %]
    Pickup Location: [% udata.pickup_lib %]
    Status: 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 new file mode 100644 index 0000000000..c92f1efb0c --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql @@ -0,0 +1,93 @@ + +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version); + +INSERT INTO config.print_template + (name, label, owner, active, locale, content_type, template) +VALUES ('scko_items_out', 'Self-Checkout Items Out', 1, TRUE, 'en-US', 'text/html', ''); + +UPDATE config.print_template SET template = $TEMPLATE$ +[%- + USE date; + SET user = template_data.user; + SET checkouts = template_data.checkouts; +-%] +
    + +
    [% date.format(date.now, '%x %r') %]
    +
    + + [% user.pref_family_name || user.family_name %], + [% user.pref_first_given_name || user.first_given_name %] + +
      + [% FOR checkout IN checkouts %] +
    1. +
      [% checkout.title %]
      +
      Barcode: [% checkout.copy.barcode %]
      +
      Due Date: [% + date.format(helpers.format_date( + checkout.circ.due_date, staff_org_timezone), '%x %r') + %] +
      +
    2. + [% END %] +
    +
    +$TEMPLATE$ WHERE name = 'scko_items_out'; + +INSERT INTO config.print_template + (name, label, owner, active, locale, content_type, template) +VALUES ('scko_holds', 'Self-Checkout Holds', 1, TRUE, 'en-US', 'text/html', ''); + +UPDATE config.print_template SET template = $TEMPLATE$ +[%- + USE date; + SET user = template_data.user; + SET holds = template_data.holds; +-%] +
    + +
    [% date.format(date.now, '%x %r') %]
    +
    + + [% user.pref_family_name || user.family_name %], + [% user.pref_first_given_name || user.first_given_name %] + +
      + [% FOR hold IN holds %] +
    1. +
    Title:[% hold.title %]
    author:[% hold.author %]
    + + + + + + + + + + + + + + + + + + + [% END %] + + +$TEMPLATE$ WHERE name = 'scko_holds'; + +COMMIT; + + -- 2.11.0
    Title:[% hold.title %]
    Author:[% hold.author %]
    Pickup Location:[% helpers.get_org_unit(hold.pickup_lib).name %]
    Status: + [%- IF hold.ready -%] + Ready for pickup + [% ELSE %] + #[% hold.relative_queue_position %] of [% hold.potentials %] copies. + [% END %] +