From b11e6fee636e40f5f6617dc86101516e459005a5 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 14 May 2018 12:35:38 -0400 Subject: [PATCH] LP#1775466 more printing Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/print/print.component.ts | 35 ++++++++++++++++++---- .../src/eg2/src/app/share/print/print.service.ts | 3 +- .../eg2/src/app/staff/sandbox/sandbox.component.ts | 3 +- Open-ILS/src/eg2/src/styles.css | 18 ++++++----- 4 files changed, 44 insertions(+), 15 deletions(-) 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 9a2ccea5f8..54106fb1fd 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,4 +1,4 @@ -import {Component, OnInit, TemplateRef} from '@angular/core'; +import {Component, OnInit, TemplateRef, ElementRef} from '@angular/core'; import {EgPrintService, EgPrintRequest} from './print.service'; @Component({ @@ -11,19 +11,42 @@ export class EgPrintComponent implements OnInit { template: TemplateRef; context: any; - constructor(private print: EgPrintService) {} + constructor( + private elm: ElementRef, + private printer: EgPrintService + ) {} ngOnInit() { - this.print.onPrintRequest$.subscribe( + this.printer.onPrintRequest$.subscribe( printReq => this.handlePrintRequest(printReq)); } handlePrintRequest(printReq: EgPrintRequest) { this.template = printReq.template; - this.context = printReq.context; + this.context = printReq.contextData; - // TODO: hatch - setTimeout(() => window.print()); + // Give the template a chance to render inline before printing + setTimeout(() => this.dispatchPrint(printReq)); } + + dispatchPrint(printReq) { + /* + if (this.hatch.useHatchForPrinting) { + this.printViaHatch(); + } else { + */ + window.print(); + //} + } + + /* + printViaHatch(printReq) { + this.hatch.print({ + printContext: printReq.printContext, + content: this.elm.nativeElement.innerHTML + }); + } + */ + } 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 cc521f6795..a983c72e30 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 @@ -2,7 +2,8 @@ import {Injectable, EventEmitter, TemplateRef} from '@angular/core'; export interface EgPrintRequest { template: TemplateRef, - context: any + contextData: any, + printContext: string } @Injectable() diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 5579e25efd..b366b2cea3 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -68,7 +68,8 @@ export class EgSandboxComponent implements OnInit { doPrint() { this.printer.print({ template: this.printTemplate, - context: {world : 'world'} + contextData: {world : 'world'}, + printContext: 'default' }); } diff --git a/Open-ILS/src/eg2/src/styles.css b/Open-ILS/src/eg2/src/styles.css index 18d5f954c4..9376f6578d 100644 --- a/Open-ILS/src/eg2/src/styles.css +++ b/Open-ILS/src/eg2/src/styles.css @@ -98,16 +98,20 @@ h5 {font-size: .95rem} border-left: 8px solid #FA787E; } + + +/** + * Only display the print container when printing + */ #eg-print-container { display: none; } - @media print { - head { display: none; } /* just to be safe */ - body div:not([id="eg-print-container"]) { display:none } - div { display: none } - #eg-print-container { display: block } - #eg-print-container div { display: block } - #eg-print-container pre { border: none } + head {display: none} /* just to be safe */ + body div:not([id="eg-print-container"]) {display: none} + div {display: none} + #eg-print-container {display: block} + #eg-print-container div {display: block} + #eg-print-container pre {border: none} } -- 2.11.0