From: Bill Erickson Date: Thu, 21 Jun 2018 19:23:58 +0000 (-0400) Subject: LP#1775466 Implement reprint last receipt X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=53b98d9da79942bcbd4950f00df3c98aa8bf44e5;p=working%2FEvergreen.git LP#1775466 Implement reprint last receipt Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/print/print.component.ts b/Open-ILS/src/eg2/src/app/share/print/print.component.ts index 81b8020d91..8102831587 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.component.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit, TemplateRef, ElementRef, Renderer2} from '@angular/core'; import {PrintService, PrintRequest} from './print.service'; +import {StoreService} from '@eg/core/store.service'; @Component({ selector: 'eg-print', @@ -20,6 +21,7 @@ export class PrintComponent implements OnInit { constructor( private renderer: Renderer2, private elm: ElementRef, + private store: StoreService, private printer: PrintService ) {} @@ -61,6 +63,22 @@ export class PrintComponent implements OnInit { } dispatchPrint(printReq: PrintRequest) { + + if (!printReq.text) { + // Sometimes the results come from an externally-parsed HTML + // template, other times they come from an in-page template. + printReq.text = this.elm.nativeElement.innerHTML; + } + + // Retain a copy of each printed document in localStorage + // so it may be reprinted. + this.store.setLocalItem('eg.print.last_printed', { + content: printReq.text, + context: printReq.printContext, + content_type: printReq.contentType, + show_dialog: printReq.showDialog + }); + if (0 /* this.hatch.isActive */) { this.printViaHatch(printReq); } else { @@ -71,12 +89,6 @@ export class PrintComponent implements OnInit { printViaHatch(printReq: PrintRequest) { - if (!printReq.text) { - // Sometimes the results come from an externally-parsed HTML - // template, other times they come from an in-page template. - printReq.text = this.elm.nativeElement.innerHTML; - } - // Send a full HTML document to Hatch const html = `${printReq.text}`; 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 e296720048..5ae6844dfd 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 @@ -1,4 +1,5 @@ import {Injectable, EventEmitter, TemplateRef} from '@angular/core'; +import {StoreService} from '@eg/core/store.service'; export interface PrintRequest { template?: TemplateRef; @@ -6,6 +7,7 @@ export interface PrintRequest { text?: string; printContext: string; contentType?: string; // defaults to text/html + showDialog?: boolean; } @Injectable() @@ -13,12 +15,27 @@ export class PrintService { onPrintRequest$: EventEmitter; - constructor() { + constructor(private store: StoreService) { this.onPrintRequest$ = new EventEmitter(); } print(printReq: PrintRequest) { this.onPrintRequest$.emit(printReq); } + + reprintLast() { + const prev = this.store.getLocalItem('eg.print.last_printed'); + + if (prev) { + const req: PrintRequest = { + text: prev.content, + printContext: prev.context || 'default', + contentType: prev.content_type || 'text/html', + showDialog: Boolean(prev.show_dialog) + }; + + this.print(req); + } + } } diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.html b/Open-ILS/src/eg2/src/app/staff/nav.component.html index 5b022dd43e..3f5144060d 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.html +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.html @@ -113,7 +113,7 @@ Scan Item as Missing Pieces - + redo Reprint Last Receipt diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.ts b/Open-ILS/src/eg2/src/app/staff/nav.component.ts index 922962db62..c528d0320d 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.ts @@ -1,6 +1,7 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; import {AuthService} from '@eg/core/auth.service'; +import {PrintService} from '@eg/share/print/print.service'; @Component({ selector: 'eg-staff-nav-bar', @@ -12,7 +13,8 @@ export class StaffNavComponent implements OnInit { constructor( private router: Router, - private auth: AuthService + private auth: AuthService, + private printer: PrintService ) {} ngOnInit() { @@ -37,6 +39,10 @@ export class StaffNavComponent implements OnInit { this.auth.broadcastLogout(); this.router.navigate(['/staff/login']); } + + reprintLast() { + this.printer.reprintLast(); + } }