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());
+ });
});
});
}
<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
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';
@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.
private org: OrgService,
private pcrud: PcrudService,
private auth: AuthService,
+ private store: ServerStoreService,
private locale: LocaleService,
private printer: PrintService,
private samples: SampleDataService
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');
+ });
});
}
});
});
}
+
+ 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());
+ }
+ }
}
)
);
+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 (
--- /dev/null
+
+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;
<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>
// 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) {