LP1891550 Ang print context support; no-print contexts
authorBill Erickson <berickxx@gmail.com>
Mon, 17 Aug 2020 19:13:58 +0000 (15:13 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 10 Mar 2021 22:02:24 +0000 (17:02 -0500)
Adds support to the Angular server template admin page for forcing a
print context for a given template.

Adds support to the Angular print service for looking up the context of
a print template when specified by name.

Adds support to And and AngJS print settings interfaces for a "No-Print"
context, which bypasses printing when used.

Adds a new workstation setting for the Booking Capture server print
template context.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/share/print/print.component.ts
Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.html
Open-ILS/src/eg2/src/app/staff/admin/server/print-template.component.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-print-context.sql [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2
Open-ILS/web/js/ui/default/staff/services/print.js

index 6af06bd..bf0fb3a 100644 (file)
@@ -74,12 +74,32 @@ export class PrintComponent implements OnInit {
             return;
         }
 
+        // Load the configured print context.
+        let promise = Promise.resolve();
+        if (printReq.templateName) {
+            promise = this.serverStore.getItem(
+                'eg.print.template_context.' + printReq.templateName)
+            .then(setting => {
+                if (setting) {
+                    printReq.printContext = setting;
+                }
+            });
+        }
+
         this.isPrinting = true;
+        promise.then(_ => {
 
-        this.applyTemplate(printReq).then(() => {
-            // Give templates a chance to render before printing
-            setTimeout(() => {
-                this.dispatchPrint(printReq).then(_ => this.reset());
+            if (printReq.printContext === 'no-print') {
+                console.debug('Skipping print request with No-Print context');
+                this.reset();
+                return;
+            }
+
+            this.applyTemplate(printReq).then(() => {
+                // Give templates a chance to render before printing
+                setTimeout(() => {
+                    this.dispatchPrint(printReq).then(__ => this.reset());
+                });
             });
         });
     }
index 1293bc1..517ce63 100644 (file)
           <button class="btn btn-info ml-2" (click)="cloneTemplate()" i18n>
             Clone Template
           </button>
+          <span class="ml-3 mr-1" i18n>Force Print Context:</span>
+          <eg-combobox #printContextCbox (onChange)="forceContextChange($event)">
+            <eg-combobox-entry entryId="unset" entryLabel="<Unset>" i18n-entryLabel>
+            </eg-combobox-entry>
+            <eg-combobox-entry entryId="default" entryLabel="Default" i18n-entryLabel>
+            </eg-combobox-entry>
+            <eg-combobox-entry entryId="receipt" entryLabel="Receipt" i18n-entryLabel>
+            </eg-combobox-entry>
+            <eg-combobox-entry entryId="label" entryLabel="Label" i18n-entryLabel>
+            </eg-combobox-entry>
+            <eg-combobox-entry entryId="mail" entryLabel="Mail" i18n-entryLabel>
+            </eg-combobox-entry>
+            <eg-combobox-entry entryId="offline" entryLabel="Offline" i18n-entryLabel>
+            </eg-combobox-entry>
+            <eg-combobox-entry entryId="no-print" entryLabel="No-Print" i18n-entryLabel>
+            </eg-combobox-entry>
+          </eg-combobox>
           <div class="flex-1"> </div>
           <button class="btn btn-danger ml-2" (click)="deleteTemplate()" i18n>
             Delete Template
index a0d4fb9..0276005 100644 (file)
@@ -6,6 +6,7 @@ import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {PcrudService} from '@eg/core/pcrud.service';
 import {AuthService} from '@eg/core/auth.service';
 import {OrgService} from '@eg/core/org.service';
+import {ServerStoreService} from '@eg/core/server-store.service';
 import {ComboboxComponent, ComboboxEntry
     } from '@eg/share/combobox/combobox.component';
 import {PrintService} from '@eg/share/print/print.service';
@@ -41,6 +42,7 @@ export class PrintTemplateComponent implements OnInit {
     @ViewChild('tabs', { static: false }) tabs: NgbTabset;
     @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
     @ViewChild('confirmDelete', { static: true }) confirmDelete: ConfirmDialogComponent;
+    @ViewChild('printContextCbox', {static: false}) printContextCbox: ComboboxComponent;
 
     // Define some sample data that can be used for various templates
     // Data will be filled out via the sample data service.
@@ -56,6 +58,7 @@ export class PrintTemplateComponent implements OnInit {
         private org: OrgService,
         private pcrud: PcrudService,
         private auth: AuthService,
+        private store: ServerStoreService,
         private locale: LocaleService,
         private printer: PrintService,
         private samples: SampleDataService
@@ -208,6 +211,11 @@ export class PrintTemplateComponent implements OnInit {
                 this.sampleJson = JSON.stringify(data, null, 2);
                 this.refreshPreview();
             }
+
+            this.store.getItem('eg.print.template_context.' + this.template.name())
+            .then(setting => {
+                this.printContextCbox.applyEntryId(setting || 'unset');
+            });
         });
     }
 
@@ -296,6 +304,19 @@ export class PrintTemplateComponent implements OnInit {
             });
         });
     }
+
+    forceContextChange(entry: ComboboxEntry) {
+        if (entry && entry.id !== 'unset') {
+
+            this.store.setItem(
+                'eg.print.template_context.' + this.template.name(), entry.id);
+
+        } else {
+
+            this.store.removeItem(
+                'eg.print.template_context.' + this.template.name());
+        }
+    }
 }
 
 
index b92acc5..dd3f884 100644 (file)
@@ -20530,6 +20530,15 @@ VALUES (
     )
 );
 
+INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
+VALUES (
+    'eg.print.template_context.booking_capture', 'gui', 'string',
+    oils_i18n_gettext(
+        'eg.print.template_context.booking_capture',
+        'Print Template Context: booking_capture',
+        'cwst', 'label'
+    )
+);
 
 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
 VALUES (
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-print-context.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.booking-print-context.sql
new file mode 100644 (file)
index 0000000..3b9c902
--- /dev/null
@@ -0,0 +1,16 @@
+
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
+
+INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
+VALUES (
+    'eg.print.template_context.booking_capture', 'gui', 'string',
+    oils_i18n_gettext(
+        'eg.print.template_context.booking_capture',
+        'Print Template Context: booking_capture',
+        'cwst', 'label'
+    )
+);
+
+COMMIT;
index 239ec26..e21a8c6 100644 (file)
@@ -46,6 +46,7 @@
           <option value="label">[% l('Label') %]</option>
           <option value="mail">[% l('Mail') %]</option>
           <option value="offline">[% l('Offline') %]</option>
+          <option value="no-print">[% l('No-Print') %]</option>
         </select>
       </div>
     </div>
index 8e9fcf9..0345f73 100644 (file)
@@ -91,6 +91,12 @@ function($q , $window , $timeout , $http , egHatch , egAuth , egIDL , egOrg , eg
     // Template has been fetched (or no template needed) 
     // Process the template and send the result off to the printer.
     service.print_content = function(args) {
+
+        if (args.context === 'no-print') {
+            console.debug('Skipping print request with No-Print context');
+            return $q.when();
+        }
+
         return service.fleshPrintScope(args.scope)
         .then(function() { return egHatch.usePrinting(); })
         .then(function(useHatch) {