LP#1626157 more printing
authorBill Erickson <berickxx@gmail.com>
Mon, 14 May 2018 16:35:38 +0000 (12:35 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 14 May 2018 16:35:38 +0000 (12:35 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/print/print.component.ts
Open-ILS/src/eg2/src/app/share/print/print.service.ts
Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts
Open-ILS/src/eg2/src/styles.css

index 9a2ccea..54106fb 100644 (file)
@@ -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<any>;
     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
+        });
+    }
+    */
+
 }
 
index cc521f6..a983c72 100644 (file)
@@ -2,7 +2,8 @@ import {Injectable, EventEmitter, TemplateRef} from '@angular/core';
 
 export interface EgPrintRequest {
     template: TemplateRef<any>,
-    context: any
+    contextData: any,
+    printContext: string
 }
 
 @Injectable()
index 5579e25..b366b2c 100644 (file)
@@ -68,7 +68,8 @@ export class EgSandboxComponent implements OnInit {
     doPrint() {
         this.printer.print({
             template: this.printTemplate,
-            context: {world : 'world'}
+            contextData: {world : 'world'},
+            printContext: 'default'
         });
     }
 
index 18d5f95..9376f65 100644 (file)
@@ -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}
 }