LP1840773 SCKO Angular
authorBill Erickson <berickxx@gmail.com>
Thu, 30 Jun 2022 15:10:24 +0000 (11:10 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 30 Jun 2022 15:10:24 +0000 (11:10 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/scko/checkout.component.html
Open-ILS/src/eg2/src/app/scko/checkout.component.ts
Open-ILS/src/eg2/src/app/scko/items.component.html
Open-ILS/src/eg2/src/app/scko/items.component.ts
Open-ILS/src/eg2/src/app/scko/scko.component.html
Open-ILS/src/eg2/src/app/scko/scko.service.ts
Open-ILS/src/perlmods/lib/OpenILS/WWW/PrintTemplate.pm
Open-ILS/src/sql/Pg/upgrade/YYYY.data.scko-angular.sql

index a402970..bf50486 100644 (file)
@@ -24,9 +24,9 @@
             <img src="/opac/extras/ac/jacket/small/r/{{co.circ.target_copy().call_number().record().id()}}"/>
           </ng-container>
         </td>
-        <td><span *ngIf="co.circ">{{cocirc.target_copy().barcode()}}</span></td>
-        <td>{{getTitle(circ)}}</td>
-        <td>{{getAuthor(circ)}}</td>
+        <td><span *ngIf="co.circ">{{co.circ.target_copy().barcode()}}</span></td>
+        <td>{{scko.getCircTitle(co.circ)}}</td>
+        <td>{{scko.getCircAuthor(co.circ)}}</td>
         <td><span *ngIf="co.circ">{{co.circ | egDueDate}}</span></td>
         <td><span *ngIf="co.circ">{{co.circ.renewal_remaining()}}</span></td>
         <td>
index 483978a..5afc1f6 100644 (file)
@@ -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');
-    }
 }
 
index 28daf25..c4a247b 100644 (file)
@@ -25,8 +25,8 @@
           </ng-container>
         </td>
         <td>{{circ.target_copy().barcode()}}</td>
-        <td>{{getTitle(circ)}}</td>
-        <td>{{getAuthor(circ)}}</td>
+        <td>{{scko.getCircTitle(circ)}}</td>
+        <td>{{scko.getCircAuthor(circ)}}</td>
         <td>{{circ | egDueDate}}</td>
         <td>{{circ.renewal_remaining()}}</td>
         <td>
index 9da559e..7a662a5 100644 (file)
@@ -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)
             };
         });
 
index 5d6ce82..1ae367d 100644 (file)
@@ -39,6 +39,7 @@
 <eg-context-menu-container></eg-context-menu-container>
 
 <eg-string i18n-text key="scko.unknown" text="Unknown Error Occurred"></eg-string>
+<eg-string i18n-text key="scko.checkout.success" text="Checkout Succeeded"></eg-string>
 <eg-string i18n-text key="scko.renew.success" text="Renewal Succeeded"></eg-string>
 <eg-string i18n-text key="scko.item.not_found" 
   text="Item was not found in the system. Try re-scanning the item."></eg-string>
@@ -102,5 +103,6 @@ text="The item's circulation library does not fulfill holds"></eg-string>
   text="The system could not find this patron"></eg-string>
 <eg-string i18n-text key="scko.error.transit_range"
   text="The item cannot transit this far"></eg-string>
-
+<eg-string i18n-text key="scko.error.patron_exceeds_checkout_count"
+  text="Maximum checkouts reached on this account"></eg-string>
 
index 26627ee..9b3ceaf 100644 (file)
@@ -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<any> {
         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: {
index 4454221..099cb4b 100644 (file)
@@ -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'
+                ]
+            }
         }
     ]);
 
index a2dc616..fd87f29 100644 (file)
@@ -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;
 -%]
 <div>
   <style> li { padding: 8px; margin 5px; }</style>
   <div>[% date.format(date.now, '%x %r') %]</div>
+  <div>[% lib.name %]</div>
+  <div>[% lib_addr.street1 %] [% lib_addr.street2 %]</div>
+  <div>[% lib_addr.city %], [% lib_addr.state %] [% lib_addr.post_code %]</div>
+  <div>[% lib.phone %]</div>
   <br/>
 
   [% user.pref_family_name || user.family_name %], 
@@ -158,16 +165,61 @@ UPDATE config.print_template SET template = $TEMPLATE$
     <li>
       <div>[% checkout.title %]</div>
       <div>Barcode: [% checkout.barcode %]</div>
-      <div>Due Date: [% 
-        IF checkout.circ;
-            date.format(helpers.format_date(
-                checkout.circ.due_date, staff_org_timezone), '%x %r') 
-        END;
-      %]
-      </div>
+
+      [% IF checkout.ctx.renewalFailure %]
+      <div style="color:red;">Renewal Failed</div>
+      [% END %]
+
+      <div>Due Date: [% date.format(helpers.format_date(
+        checkout.circ.due_date, staff_org_timezone), '%x') %]</div>
     </li>
   [% END %]
   </ol>
+
+  <div>
+    Library Hours
+    [%- 
+        BLOCK format_time; 
+            date.format(time _ ' 1/1/1000', format='%I:%M %p'); 
+        END 
+    -%]
+    <div>
+      Monday 
+      [% PROCESS format_time time = hours.dow_0_open %] 
+      [% PROCESS format_time time = hours.dow_0_close %] 
+    </div>
+    <div>
+      Tuesday 
+      [% PROCESS format_time time = hours.dow_1_open %] 
+      [% PROCESS format_time time = hours.dow_1_close %] 
+    </div>
+    <div>
+      Wednesday 
+      [% PROCESS format_time time = hours.dow_2_open %] 
+      [% PROCESS format_time time = hours.dow_2_close %] 
+    </div>
+    <div>
+      Thursday
+      [% PROCESS format_time time = hours.dow_3_open %] 
+      [% PROCESS format_time time = hours.dow_3_close %] 
+    </div>
+    <div>
+      Friday
+      [% PROCESS format_time time = hours.dow_4_open %] 
+      [% PROCESS format_time time = hours.dow_4_close %] 
+    </div>
+    <div>
+      Saturday
+      [% PROCESS format_time time = hours.dow_5_open %] 
+      [% PROCESS format_time time = hours.dow_5_close %] 
+    </div>
+    <div>
+      Sunday 
+      [% PROCESS format_time time = hours.dow_6_open %] 
+      [% PROCESS format_time time = hours.dow_6_close %] 
+    </div>
+  </div>
+
 </div>
 $TEMPLATE$ WHERE name = 'scko_checkouts';